mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-20 18:26:38 +08:00
版本更新 v2.1.0
This commit is contained in:
parent
687d746b1b
commit
403c12eb9c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ruoyi-vue-plus",
|
"name": "ruoyi-vue-plus",
|
||||||
"version": "2.0.0",
|
"version": "2.1.0",
|
||||||
"description": "RuoYi-Vue-Plus后台管理系统",
|
"description": "RuoYi-Vue-Plus后台管理系统",
|
||||||
"author": "LionLi",
|
"author": "LionLi",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -80,6 +80,14 @@
|
|||||||
<span>更新日志</span>
|
<span>更新日志</span>
|
||||||
</div>
|
</div>
|
||||||
<el-collapse accordion>
|
<el-collapse accordion>
|
||||||
|
<el-collapse-item title="v2.1.0 - 2021-5-17">
|
||||||
|
<ol>
|
||||||
|
<li>update swagger升级3.0.2</li>
|
||||||
|
<li>update 增强分页工具兼容性</li>
|
||||||
|
<li>update 通用Service接口 增加自定义vo转换函数</li>
|
||||||
|
<li>remove 移除ruoyi自带服务监控(Admin已全部包含)</li>
|
||||||
|
</ol>
|
||||||
|
</el-collapse-item>
|
||||||
<el-collapse-item title="v2.0.0 - 2021-5-15">
|
<el-collapse-item title="v2.0.0 - 2021-5-15">
|
||||||
<ol>
|
<ol>
|
||||||
<li>springboot 升级 2.3.10 依赖全面升级适配</li>
|
<li>springboot 升级 2.3.10 依赖全面升级适配</li>
|
||||||
@ -140,7 +148,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 版本号
|
// 版本号
|
||||||
version: "2.0.0",
|
version: "2.1.0",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -1,210 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12" class="card-box">
|
|
||||||
<el-card>
|
|
||||||
<div slot="header"><span>CPU</span></div>
|
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
|
||||||
<table cellspacing="0" style="width: 100%;">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="is-leaf"><div class="cell">属性</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">值</div></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">核心数</div></td>
|
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.cpuNum }}</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">用户使用率</div></td>
|
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.used }}%</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">系统使用率</div></td>
|
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.sys }}%</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">当前空闲率</div></td>
|
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.free }}%</div></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="12" class="card-box">
|
|
||||||
<el-card>
|
|
||||||
<div slot="header"><span>内存</span></div>
|
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
|
||||||
<table cellspacing="0" style="width: 100%;">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="is-leaf"><div class="cell">属性</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">内存</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">JVM</div></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">总内存</div></td>
|
|
||||||
<td><div class="cell" v-if="server.mem">{{ server.mem.total }}G</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.total }}M</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">已用内存</div></td>
|
|
||||||
<td><div class="cell" v-if="server.mem">{{ server.mem.used}}G</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.used}}M</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">剩余内存</div></td>
|
|
||||||
<td><div class="cell" v-if="server.mem">{{ server.mem.free }}G</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.free }}M</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">使用率</div></td>
|
|
||||||
<td><div class="cell" v-if="server.mem" :class="{'text-danger': server.mem.usage > 80}">{{ server.mem.usage }}%</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm" :class="{'text-danger': server.jvm.usage > 80}">{{ server.jvm.usage }}%</div></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="card-box">
|
|
||||||
<el-card>
|
|
||||||
<div slot="header">
|
|
||||||
<span>服务器信息</span>
|
|
||||||
</div>
|
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
|
||||||
<table cellspacing="0" style="width: 100%;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">服务器名称</div></td>
|
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.computerName }}</div></td>
|
|
||||||
<td><div class="cell">操作系统</div></td>
|
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.osName }}</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">服务器IP</div></td>
|
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.computerIp }}</div></td>
|
|
||||||
<td><div class="cell">系统架构</div></td>
|
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.osArch }}</div></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="card-box">
|
|
||||||
<el-card>
|
|
||||||
<div slot="header">
|
|
||||||
<span>Java虚拟机信息</span>
|
|
||||||
</div>
|
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
|
||||||
<table cellspacing="0" style="width: 100%;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">Java名称</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.name }}</div></td>
|
|
||||||
<td><div class="cell">Java版本</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.version }}</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class="cell">启动时间</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.startTime }}</div></td>
|
|
||||||
<td><div class="cell">运行时长</div></td>
|
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.runTime }}</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1"><div class="cell">安装路径</div></td>
|
|
||||||
<td colspan="3"><div class="cell" v-if="server.jvm">{{ server.jvm.home }}</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1"><div class="cell">项目路径</div></td>
|
|
||||||
<td colspan="3"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="24" class="card-box">
|
|
||||||
<el-card>
|
|
||||||
<div slot="header">
|
|
||||||
<span>磁盘状态</span>
|
|
||||||
</div>
|
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
|
||||||
<table cellspacing="0" style="width: 100%;">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="is-leaf"><div class="cell">盘符路径</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">文件系统</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">盘符类型</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">总大小</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">可用大小</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">已用大小</div></th>
|
|
||||||
<th class="is-leaf"><div class="cell">已用百分比</div></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody v-if="server.sysFiles">
|
|
||||||
<tr v-for="sysFile in server.sysFiles">
|
|
||||||
<td><div class="cell">{{ sysFile.dirName }}</div></td>
|
|
||||||
<td><div class="cell">{{ sysFile.sysTypeName }}</div></td>
|
|
||||||
<td><div class="cell">{{ sysFile.typeName }}</div></td>
|
|
||||||
<td><div class="cell">{{ sysFile.total }}</div></td>
|
|
||||||
<td><div class="cell">{{ sysFile.free }}</div></td>
|
|
||||||
<td><div class="cell">{{ sysFile.used }}</div></td>
|
|
||||||
<td><div class="cell" :class="{'text-danger': sysFile.usage > 80}">{{ sysFile.usage }}%</div></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { getServer } from "@/api/monitor/server";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "Server",
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
// 加载层信息
|
|
||||||
loading: [],
|
|
||||||
// 服务器信息
|
|
||||||
server: []
|
|
||||||
};
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getList();
|
|
||||||
this.openLoading();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
/** 查询服务器信息 */
|
|
||||||
getList() {
|
|
||||||
getServer().then(response => {
|
|
||||||
this.server = response.data;
|
|
||||||
this.loading.close();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 打开加载层
|
|
||||||
openLoading() {
|
|
||||||
this.loading = this.$loading({
|
|
||||||
lock: true,
|
|
||||||
text: "拼命读取中",
|
|
||||||
spinner: "el-icon-loading",
|
|
||||||
background: "rgba(0, 0, 0, 0.7)"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -20,11 +20,9 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||||
<druid.version>1.2.4</druid.version>
|
<druid.version>1.2.4</druid.version>
|
||||||
<knife4j.version>2.0.8</knife4j.version>
|
<knife4j.version>3.0.2</knife4j.version>
|
||||||
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
|
<swagger-annotations.version>1.5.22</swagger-annotations.version>
|
||||||
<fastjson.version>1.2.75</fastjson.version>
|
<fastjson.version>1.2.75</fastjson.version>
|
||||||
<oshi.version>5.6.0</oshi.version>
|
|
||||||
<jna.version>5.7.0</jna.version>
|
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<velocity.version>1.7</velocity.version>
|
<velocity.version>1.7</velocity.version>
|
||||||
<jwt.version>0.9.1</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
@ -91,25 +89,6 @@
|
|||||||
<version>${druid.version}</version>
|
<version>${druid.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 获取系统信息 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.oshi</groupId>
|
|
||||||
<artifactId>oshi-core</artifactId>
|
|
||||||
<version>${oshi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna</artifactId>
|
|
||||||
<version>${jna.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna-platform</artifactId>
|
|
||||||
<version>${jna.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--velocity代码生成使用模板 -->
|
<!--velocity代码生成使用模板 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
@ -140,6 +119,18 @@
|
|||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
<version>${knife4j.version}</version>
|
<version>${knife4j.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Mysql驱动包 -->
|
<!-- Mysql驱动包 -->
|
||||||
|
@ -9,6 +9,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +31,18 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
return BeanUtil.toBean(t, kClass);
|
return BeanUtil.toBean(t, kClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ID 查询
|
||||||
|
*
|
||||||
|
* @param id 主键ID
|
||||||
|
* @param convertor 转换函数
|
||||||
|
* @param <K> vo类型
|
||||||
|
*/
|
||||||
|
default <K> K getVoById(Serializable id, Function<T, K> convertor) {
|
||||||
|
T t = getBaseMapper().selectById(id);
|
||||||
|
return convertor.apply(t);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询(根据ID 批量查询)
|
* 查询(根据ID 批量查询)
|
||||||
*
|
*
|
||||||
@ -46,6 +59,21 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据ID 批量查询)
|
||||||
|
*
|
||||||
|
* @param convertor 转换函数
|
||||||
|
* @param idList 主键ID列表
|
||||||
|
*/
|
||||||
|
default <K> List<K> listVoByIds(Collection<? extends Serializable> idList,
|
||||||
|
Function<Collection<T>, List<K>> convertor) {
|
||||||
|
List<T> list = getBaseMapper().selectBatchIds(idList);
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertor.apply(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询(根据 columnMap 条件)
|
* 查询(根据 columnMap 条件)
|
||||||
*
|
*
|
||||||
@ -62,6 +90,21 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询(根据 columnMap 条件)
|
||||||
|
*
|
||||||
|
* @param convertor 转换函数
|
||||||
|
* @param columnMap 表字段 map 对象
|
||||||
|
*/
|
||||||
|
default <K> List<K> listVoByMap(Map<String, Object> columnMap,
|
||||||
|
Function<Collection<T>, List<K>> convertor) {
|
||||||
|
List<T> list = getBaseMapper().selectByMap(columnMap);
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertor.apply(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据 Wrapper,查询一条记录 <br/>
|
* 根据 Wrapper,查询一条记录 <br/>
|
||||||
* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
|
* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
|
||||||
@ -73,6 +116,17 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
return BeanUtil.toBean(getOne(queryWrapper, true), kClass);
|
return BeanUtil.toBean(getOne(queryWrapper, true), kClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 Wrapper,查询一条记录 <br/>
|
||||||
|
* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
|
||||||
|
*
|
||||||
|
* @param convertor 转换函数
|
||||||
|
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
||||||
|
*/
|
||||||
|
default <K> K getVoOne(Wrapper<T> queryWrapper, Function<T, K> convertor) {
|
||||||
|
return convertor.apply(getOne(queryWrapper, true));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
*
|
*
|
||||||
@ -89,6 +143,20 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
*
|
||||||
|
* @param convertor 转换函数
|
||||||
|
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
||||||
|
*/
|
||||||
|
default <K> List<K> listVo(Wrapper<T> queryWrapper, Function<Collection<T>, List<K>> convertor) {
|
||||||
|
List<T> list = getBaseMapper().selectList(queryWrapper);
|
||||||
|
if (list == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return convertor.apply(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有
|
* 查询所有
|
||||||
*
|
*
|
||||||
@ -99,6 +167,16 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
return listVo(Wrappers.emptyWrapper(), kClass);
|
return listVo(Wrappers.emptyWrapper(), kClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有
|
||||||
|
*
|
||||||
|
* @param convertor 转换函数
|
||||||
|
* @see Wrappers#emptyWrapper()
|
||||||
|
*/
|
||||||
|
default <K> List<K> listVo(Function<Collection<T>, List<K>> convertor) {
|
||||||
|
return listVo(Wrappers.emptyWrapper(), convertor);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 翻页查询
|
* 翻页查询
|
||||||
*
|
*
|
||||||
@ -107,9 +185,25 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
* @param kClass vo类型
|
* @param kClass vo类型
|
||||||
*/
|
*/
|
||||||
default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, Class<K> kClass) {
|
default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper, Class<K> kClass) {
|
||||||
PagePlus<T, K> e = getBaseMapper().selectPage(page, queryWrapper);
|
PagePlus<T, K> result = getBaseMapper().selectPage(page, queryWrapper);
|
||||||
page.recordsToVo(kClass);
|
List<K> volist = result.getRecords().stream()
|
||||||
return page;
|
.map(any -> BeanUtil.toBean(any, kClass))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
result.setRecordsVo(volist);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻页查询
|
||||||
|
*
|
||||||
|
* @param page 翻页对象
|
||||||
|
* @param queryWrapper 实体对象封装操作类
|
||||||
|
* @param convertor 转换函数
|
||||||
|
*/
|
||||||
|
default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Wrapper<T> queryWrapper,
|
||||||
|
Function<Collection<T>, List<K>> convertor) {
|
||||||
|
PagePlus<T, K> result = getBaseMapper().selectPage(page, queryWrapper);
|
||||||
|
return result.setRecordsVo(convertor.apply(result.getRecords()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,5 +216,15 @@ public interface IServicePlus<T> extends IService<T> {
|
|||||||
return pageVo(page, Wrappers.emptyWrapper(), kClass);
|
return pageVo(page, Wrappers.emptyWrapper(), kClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无条件翻页查询
|
||||||
|
*
|
||||||
|
* @param page 翻页对象
|
||||||
|
* @param convertor 转换函数
|
||||||
|
*/
|
||||||
|
default <K> PagePlus<T, K> pageVo(PagePlus<T, K> page, Function<Collection<T>, List<K>> convertor) {
|
||||||
|
return pageVo(page, Wrappers.emptyWrapper(), convertor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.common.core.page;
|
package com.ruoyi.common.core.page;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -10,34 +9,67 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class PagePlus<T,K> implements IPage<T> {
|
public class PagePlus<T,K> implements IPage<T> {
|
||||||
|
|
||||||
protected List<T> records;
|
/**
|
||||||
protected List<K> recordsVo;
|
* domain实体列表
|
||||||
protected long total;
|
*/
|
||||||
protected long size;
|
private List<T> records = Collections.emptyList();
|
||||||
protected long current;
|
|
||||||
protected List<OrderItem> orders;
|
/**
|
||||||
protected boolean optimizeCountSql;
|
* vo实体列表
|
||||||
protected boolean isSearchCount;
|
*/
|
||||||
protected boolean hitCount;
|
private List<K> recordsVo = Collections.emptyList();
|
||||||
protected String countId;
|
|
||||||
protected Long maxLimit;
|
/**
|
||||||
|
* 总数
|
||||||
|
*/
|
||||||
|
private long total = 0L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页长度
|
||||||
|
*/
|
||||||
|
private long size = 10L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前页
|
||||||
|
*/
|
||||||
|
private long current = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序字段信息
|
||||||
|
*/
|
||||||
|
private List<OrderItem> orders = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动优化 COUNT SQL
|
||||||
|
*/
|
||||||
|
private boolean optimizeCountSql = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否进行 count 查询
|
||||||
|
*/
|
||||||
|
private boolean isSearchCount = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否命中count缓存
|
||||||
|
*/
|
||||||
|
private boolean hitCount = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* countId
|
||||||
|
*/
|
||||||
|
private String countId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大limit
|
||||||
|
*/
|
||||||
|
private Long maxLimit;
|
||||||
|
|
||||||
public PagePlus() {
|
public PagePlus() {
|
||||||
this.records = Collections.emptyList();
|
|
||||||
this.recordsVo = Collections.emptyList();
|
|
||||||
this.total = 0L;
|
|
||||||
this.size = 10L;
|
|
||||||
this.current = 1L;
|
|
||||||
this.orders = new ArrayList();
|
|
||||||
this.optimizeCountSql = true;
|
|
||||||
this.isSearchCount = true;
|
|
||||||
this.hitCount = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagePlus(long current, long size) {
|
public PagePlus(long current, long size) {
|
||||||
@ -53,18 +85,9 @@ public class PagePlus<T,K> implements IPage<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PagePlus(long current, long size, long total, boolean isSearchCount) {
|
public PagePlus(long current, long size, long total, boolean isSearchCount) {
|
||||||
this.records = Collections.emptyList();
|
|
||||||
this.total = 0L;
|
|
||||||
this.size = 10L;
|
|
||||||
this.current = 1L;
|
|
||||||
this.orders = new ArrayList();
|
|
||||||
this.optimizeCountSql = true;
|
|
||||||
this.isSearchCount = true;
|
|
||||||
this.hitCount = false;
|
|
||||||
if (current > 1L) {
|
if (current > 1L) {
|
||||||
this.current = current;
|
this.current = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
this.isSearchCount = isSearchCount;
|
this.isSearchCount = isSearchCount;
|
||||||
@ -78,12 +101,6 @@ public class PagePlus<T,K> implements IPage<T> {
|
|||||||
return this.current < this.getPages();
|
return this.current < this.getPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordsToVo(Class<K> kClass) {
|
|
||||||
this.recordsVo = this.records.stream()
|
|
||||||
.map(any -> BeanUtil.toBean(any, kClass))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String countId() {
|
public String countId() {
|
||||||
return this.getCountId();
|
return this.getCountId();
|
||||||
@ -116,7 +133,7 @@ public class PagePlus<T,K> implements IPage<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSearchCount() {
|
public boolean isSearchCount() {
|
||||||
return this.total < 0L ? false : this.isSearchCount;
|
return this.total >= 0L && this.isSearchCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagePlus<T, K> setSearchCount(boolean isSearchCount) {
|
public PagePlus<T, K> setSearchCount(boolean isSearchCount) {
|
||||||
|
@ -37,9 +37,25 @@ public class PageUtils {
|
|||||||
*/
|
*/
|
||||||
public static final String IS_ASC = "isAsc";
|
public static final String IS_ASC = "isAsc";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前记录起始索引 默认值
|
||||||
|
*/
|
||||||
|
public static final int DEFAULT_PAGE_NUM = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示记录数 默认值
|
||||||
|
*/
|
||||||
|
public static final int DEFAULT_PAGE_SIZE = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 plus 分页对象
|
||||||
|
* @param <T> domain 实体
|
||||||
|
* @param <K> vo 实体
|
||||||
|
* @return 分页对象
|
||||||
|
*/
|
||||||
public static <T, K> PagePlus<T, K> buildPagePlus() {
|
public static <T, K> PagePlus<T, K> buildPagePlus() {
|
||||||
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM);
|
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
|
||||||
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE);
|
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
||||||
String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN);
|
String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN);
|
||||||
String isAsc = ServletUtils.getParameter(IS_ASC);
|
String isAsc = ServletUtils.getParameter(IS_ASC);
|
||||||
PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize);
|
PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize);
|
||||||
@ -54,9 +70,14 @@ public class PageUtils {
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建 MP 普通分页对象
|
||||||
|
* @param <T> domain 实体
|
||||||
|
* @return 分页对象
|
||||||
|
*/
|
||||||
public static <T> Page<T> buildPage() {
|
public static <T> Page<T> buildPage() {
|
||||||
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM);
|
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
|
||||||
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE);
|
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
|
||||||
String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN);
|
String orderByColumn = ServletUtils.getParameter(ORDER_BY_COLUMN);
|
||||||
String isAsc = ServletUtils.getParameter(IS_ASC);
|
String isAsc = ServletUtils.getParameter(IS_ASC);
|
||||||
Page<T> page = new Page<>(pageNum, pageSize);
|
Page<T> page = new Page<>(pageNum, pageSize);
|
||||||
|
@ -1,157 +0,0 @@
|
|||||||
package com.ruoyi.framework.web.domain;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.system.*;
|
|
||||||
import cn.hutool.system.oshi.CpuInfo;
|
|
||||||
import cn.hutool.system.oshi.OshiUtil;
|
|
||||||
import com.ruoyi.framework.web.domain.server.*;
|
|
||||||
import lombok.Data;
|
|
||||||
import oshi.hardware.GlobalMemory;
|
|
||||||
import oshi.software.os.FileSystem;
|
|
||||||
import oshi.software.os.OSFileStore;
|
|
||||||
import oshi.software.os.OperatingSystem;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务器相关信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class Server {
|
|
||||||
private static final int OSHI_WAIT_SECOND = 1000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU相关信息
|
|
||||||
*/
|
|
||||||
private Cpu cpu = new Cpu();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 內存相关信息
|
|
||||||
*/
|
|
||||||
private Mem mem = new Mem();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JVM相关信息
|
|
||||||
*/
|
|
||||||
private Jvm jvm = new Jvm();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务器相关信息
|
|
||||||
*/
|
|
||||||
private Sys sys = new Sys();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 磁盘相关信息
|
|
||||||
*/
|
|
||||||
private List<SysFile> sysFiles = new LinkedList<SysFile>();
|
|
||||||
|
|
||||||
|
|
||||||
public void copyTo() {
|
|
||||||
setCpuInfo();
|
|
||||||
setMemInfo();
|
|
||||||
setSysInfo();
|
|
||||||
setJvmInfo();
|
|
||||||
setSysFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置CPU信息
|
|
||||||
*/
|
|
||||||
private void setCpuInfo() {
|
|
||||||
CpuInfo cpuInfo = OshiUtil.getCpuInfo(OSHI_WAIT_SECOND);
|
|
||||||
cpu.setCpuNum(cpuInfo.getCpuNum());
|
|
||||||
cpu.setTotal(cpuInfo.getToTal());
|
|
||||||
cpu.setSys(cpuInfo.getSys());
|
|
||||||
cpu.setUsed(cpuInfo.getUsed());
|
|
||||||
cpu.setWait(cpuInfo.getWait());
|
|
||||||
cpu.setFree(cpuInfo.getFree());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置内存信息
|
|
||||||
*/
|
|
||||||
private void setMemInfo() {
|
|
||||||
GlobalMemory memory = OshiUtil.getMemory();
|
|
||||||
mem.setTotal(memory.getTotal());
|
|
||||||
mem.setUsed(memory.getTotal() - memory.getAvailable());
|
|
||||||
mem.setFree(memory.getAvailable());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置服务器信息
|
|
||||||
*/
|
|
||||||
private void setSysInfo() {
|
|
||||||
HostInfo hostInfo = SystemUtil.getHostInfo();
|
|
||||||
OsInfo osInfo = SystemUtil.getOsInfo();
|
|
||||||
UserInfo userInfo = SystemUtil.getUserInfo();
|
|
||||||
sys.setComputerName(hostInfo.getName());
|
|
||||||
sys.setComputerIp(hostInfo.getAddress());
|
|
||||||
sys.setOsName(osInfo.getName());
|
|
||||||
sys.setOsArch(osInfo.getArch());
|
|
||||||
sys.setUserDir(userInfo.getCurrentDir());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置Java虚拟机
|
|
||||||
*/
|
|
||||||
private void setJvmInfo() {
|
|
||||||
JavaInfo javaInfo = SystemUtil.getJavaInfo();
|
|
||||||
RuntimeInfo runtimeInfo = SystemUtil.getRuntimeInfo();
|
|
||||||
JavaRuntimeInfo javaRuntimeInfo = SystemUtil.getJavaRuntimeInfo();
|
|
||||||
jvm.setTotal(runtimeInfo.getTotalMemory());
|
|
||||||
jvm.setMax(runtimeInfo.getMaxMemory());
|
|
||||||
jvm.setFree(runtimeInfo.getFreeMemory());
|
|
||||||
jvm.setVersion(javaInfo.getVersion());
|
|
||||||
jvm.setHome(javaRuntimeInfo.getHomeDir());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置磁盘信息
|
|
||||||
*/
|
|
||||||
private void setSysFiles() {
|
|
||||||
OperatingSystem os = OshiUtil.getOs();
|
|
||||||
FileSystem fileSystem = os.getFileSystem();
|
|
||||||
List<OSFileStore> fsArray = fileSystem.getFileStores();
|
|
||||||
for (OSFileStore fs : fsArray) {
|
|
||||||
long free = fs.getUsableSpace();
|
|
||||||
long total = fs.getTotalSpace();
|
|
||||||
long used = total - free;
|
|
||||||
SysFile sysFile = new SysFile();
|
|
||||||
sysFile.setDirName(fs.getMount());
|
|
||||||
sysFile.setSysTypeName(fs.getType());
|
|
||||||
sysFile.setTypeName(fs.getName());
|
|
||||||
sysFile.setTotal(convertFileSize(total));
|
|
||||||
sysFile.setFree(convertFileSize(free));
|
|
||||||
sysFile.setUsed(convertFileSize(used));
|
|
||||||
sysFile.setUsage(NumberUtil.mul(NumberUtil.div(used, total, 4), 100));
|
|
||||||
sysFiles.add(sysFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字节转换
|
|
||||||
*
|
|
||||||
* @param size 字节大小
|
|
||||||
* @return 转换后值
|
|
||||||
*/
|
|
||||||
public String convertFileSize(long size) {
|
|
||||||
long kb = 1024;
|
|
||||||
long mb = kb * 1024;
|
|
||||||
long gb = mb * 1024;
|
|
||||||
if (size >= gb) {
|
|
||||||
return String.format("%.1f GB", (float) size / gb);
|
|
||||||
} else if (size >= mb) {
|
|
||||||
float f = (float) size / mb;
|
|
||||||
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
|
|
||||||
} else if (size >= kb) {
|
|
||||||
float f = (float) size / kb;
|
|
||||||
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
|
|
||||||
} else {
|
|
||||||
return String.format("%d B", size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
package com.ruoyi.framework.web.domain.server;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU相关信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class Cpu {
|
|
||||||
/**
|
|
||||||
* 核心数
|
|
||||||
*/
|
|
||||||
private int cpuNum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU总的使用率
|
|
||||||
*/
|
|
||||||
private double total;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU系统使用率
|
|
||||||
*/
|
|
||||||
private double sys;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU用户使用率
|
|
||||||
*/
|
|
||||||
private double used;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU当前等待率
|
|
||||||
*/
|
|
||||||
private double wait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CPU当前空闲率
|
|
||||||
*/
|
|
||||||
private double free;
|
|
||||||
|
|
||||||
public int getCpuNum() {
|
|
||||||
return cpuNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuNum(int cpuNum) {
|
|
||||||
this.cpuNum = cpuNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTotal() {
|
|
||||||
return NumberUtil.round(NumberUtil.mul(total, 100), 2).doubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotal(double total) {
|
|
||||||
this.total = total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getSys() {
|
|
||||||
return NumberUtil.round(NumberUtil.mul(sys / total, 100), 2).doubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSys(double sys) {
|
|
||||||
this.sys = sys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getUsed() {
|
|
||||||
return NumberUtil.round(NumberUtil.mul(used / total, 100), 2).doubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsed(double used) {
|
|
||||||
this.used = used;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getWait() {
|
|
||||||
return NumberUtil.round(NumberUtil.mul(wait / total, 100), 2).doubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWait(double wait) {
|
|
||||||
this.wait = wait;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getFree() {
|
|
||||||
return NumberUtil.round(NumberUtil.mul(free / total, 100), 2).doubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFree(double free) {
|
|
||||||
this.free = free;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
package com.ruoyi.framework.web.domain.server;
|
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.BetweenFormatter;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JVM相关信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class Jvm {
|
|
||||||
/**
|
|
||||||
* 当前JVM占用的内存总数(M)
|
|
||||||
*/
|
|
||||||
private double total;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JVM最大可用内存总数(M)
|
|
||||||
*/
|
|
||||||
private double max;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JVM空闲内存(M)
|
|
||||||
*/
|
|
||||||
private double free;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK版本
|
|
||||||
*/
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK路径
|
|
||||||
*/
|
|
||||||
private String home;
|
|
||||||
|
|
||||||
public double getTotal() {
|
|
||||||
return NumberUtil.div(total, (1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotal(double total) {
|
|
||||||
this.total = total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMax() {
|
|
||||||
return NumberUtil.div(max, (1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMax(double max) {
|
|
||||||
this.max = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getFree() {
|
|
||||||
return NumberUtil.div(free, (1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFree(double free) {
|
|
||||||
this.free = free;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getUsed() {
|
|
||||||
return NumberUtil.div(total - free, (1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getUsage() {
|
|
||||||
return NumberUtil.mul(NumberUtil.div(total - free, total, 4), 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取JDK名称
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return ManagementFactory.getRuntimeMXBean().getVmName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVersion(String version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHome() {
|
|
||||||
return home;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHome(String home) {
|
|
||||||
this.home = home;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK启动时间
|
|
||||||
*/
|
|
||||||
public String getStartTime()
|
|
||||||
{
|
|
||||||
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JDK运行时间
|
|
||||||
*/
|
|
||||||
public String getRunTime()
|
|
||||||
{
|
|
||||||
return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
package com.ruoyi.framework.web.domain.server;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 內存相关信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class Mem
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 内存总量
|
|
||||||
*/
|
|
||||||
private double total;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已用内存
|
|
||||||
*/
|
|
||||||
private double used;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 剩余内存
|
|
||||||
*/
|
|
||||||
private double free;
|
|
||||||
|
|
||||||
public double getTotal()
|
|
||||||
{
|
|
||||||
return NumberUtil.div(total, (1024 * 1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotal(long total)
|
|
||||||
{
|
|
||||||
this.total = total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getUsed()
|
|
||||||
{
|
|
||||||
return NumberUtil.div(used, (1024 * 1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsed(long used)
|
|
||||||
{
|
|
||||||
this.used = used;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getFree()
|
|
||||||
{
|
|
||||||
return NumberUtil.div(free, (1024 * 1024 * 1024), 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFree(long free)
|
|
||||||
{
|
|
||||||
this.free = free;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getUsage()
|
|
||||||
{
|
|
||||||
return NumberUtil.mul(NumberUtil.div(used, total, 4), 100);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
package com.ruoyi.framework.web.domain.server;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统相关信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class Sys
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 服务器名称
|
|
||||||
*/
|
|
||||||
private String computerName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务器Ip
|
|
||||||
*/
|
|
||||||
private String computerIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 项目路径
|
|
||||||
*/
|
|
||||||
private String userDir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作系统
|
|
||||||
*/
|
|
||||||
private String osName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统架构
|
|
||||||
*/
|
|
||||||
private String osArch;
|
|
||||||
|
|
||||||
public String getComputerName()
|
|
||||||
{
|
|
||||||
return computerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComputerName(String computerName)
|
|
||||||
{
|
|
||||||
this.computerName = computerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComputerIp()
|
|
||||||
{
|
|
||||||
return computerIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComputerIp(String computerIp)
|
|
||||||
{
|
|
||||||
this.computerIp = computerIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserDir()
|
|
||||||
{
|
|
||||||
return userDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserDir(String userDir)
|
|
||||||
{
|
|
||||||
this.userDir = userDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOsName()
|
|
||||||
{
|
|
||||||
return osName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsName(String osName)
|
|
||||||
{
|
|
||||||
this.osName = osName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOsArch()
|
|
||||||
{
|
|
||||||
return osArch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsArch(String osArch)
|
|
||||||
{
|
|
||||||
this.osArch = osArch;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package com.ruoyi.framework.web.domain.server;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统文件相关信息
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class SysFile
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 盘符路径
|
|
||||||
*/
|
|
||||||
private String dirName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 盘符类型
|
|
||||||
*/
|
|
||||||
private String sysTypeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件类型
|
|
||||||
*/
|
|
||||||
private String typeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总大小
|
|
||||||
*/
|
|
||||||
private String total;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 剩余大小
|
|
||||||
*/
|
|
||||||
private String free;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已经使用量
|
|
||||||
*/
|
|
||||||
private String used;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 资源的使用率
|
|
||||||
*/
|
|
||||||
private double usage;
|
|
||||||
|
|
||||||
public String getDirName()
|
|
||||||
{
|
|
||||||
return dirName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDirName(String dirName)
|
|
||||||
{
|
|
||||||
this.dirName = dirName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSysTypeName()
|
|
||||||
{
|
|
||||||
return sysTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSysTypeName(String sysTypeName)
|
|
||||||
{
|
|
||||||
this.sysTypeName = sysTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTypeName()
|
|
||||||
{
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTypeName(String typeName)
|
|
||||||
{
|
|
||||||
this.typeName = typeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTotal()
|
|
||||||
{
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotal(String total)
|
|
||||||
{
|
|
||||||
this.total = total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFree()
|
|
||||||
{
|
|
||||||
return free;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFree(String free)
|
|
||||||
{
|
|
||||||
this.free = free;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsed()
|
|
||||||
{
|
|
||||||
return used;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsed(String used)
|
|
||||||
{
|
|
||||||
this.used = used;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getUsage()
|
|
||||||
{
|
|
||||||
return usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsage(double usage)
|
|
||||||
{
|
|
||||||
this.usage = usage;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.ruoyi.web.controller.monitor;
|
|
||||||
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.framework.web.domain.Server;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务器监控
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/monitor/server")
|
|
||||||
public class ServerController
|
|
||||||
{
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
|
||||||
@GetMapping()
|
|
||||||
public AjaxResult getInfo() throws Exception
|
|
||||||
{
|
|
||||||
Server server = new Server();
|
|
||||||
server.copyTo();
|
|
||||||
return AjaxResult.success(server);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,166 +0,0 @@
|
|||||||
package com.ruoyi.web.controller.tool;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.Validator;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* swagger 用户测试方法
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Api("用户信息管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/test/user")
|
|
||||||
public class TestController extends BaseController
|
|
||||||
{
|
|
||||||
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
|
|
||||||
{
|
|
||||||
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
|
|
||||||
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户列表")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public AjaxResult userList()
|
|
||||||
{
|
|
||||||
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
|
|
||||||
return AjaxResult.success(userList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("获取用户详细")
|
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
|
||||||
@GetMapping("/{userId}")
|
|
||||||
public AjaxResult getUser(@PathVariable Integer userId)
|
|
||||||
{
|
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
|
||||||
{
|
|
||||||
return AjaxResult.success(users.get(userId));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户不存在");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("新增用户")
|
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
|
||||||
@PostMapping("/save")
|
|
||||||
public AjaxResult save(UserEntity user)
|
|
||||||
{
|
|
||||||
if (Validator.isNull(user) || Validator.isNull(user.getUserId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户ID不能为空");
|
|
||||||
}
|
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("更新用户")
|
|
||||||
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
|
|
||||||
@PutMapping("/update")
|
|
||||||
public AjaxResult update(UserEntity user)
|
|
||||||
{
|
|
||||||
if (Validator.isNull(user) || Validator.isNull(user.getUserId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户ID不能为空");
|
|
||||||
}
|
|
||||||
if (users.isEmpty() || !users.containsKey(user.getUserId()))
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户不存在");
|
|
||||||
}
|
|
||||||
users.remove(user.getUserId());
|
|
||||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("删除用户信息")
|
|
||||||
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
|
|
||||||
@DeleteMapping("/{userId}")
|
|
||||||
public AjaxResult delete(@PathVariable Integer userId)
|
|
||||||
{
|
|
||||||
if (!users.isEmpty() && users.containsKey(userId))
|
|
||||||
{
|
|
||||||
users.remove(userId);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return AjaxResult.error("用户不存在");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiModel("用户实体")
|
|
||||||
class UserEntity
|
|
||||||
{
|
|
||||||
@ApiModelProperty("用户ID")
|
|
||||||
private Integer userId;
|
|
||||||
|
|
||||||
@ApiModelProperty("用户名称")
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@ApiModelProperty("用户密码")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@ApiModelProperty("用户手机")
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
public UserEntity()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity(Integer userId, String username, String password, String mobile)
|
|
||||||
{
|
|
||||||
this.userId = userId;
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
this.mobile = mobile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getUserId()
|
|
||||||
{
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserId(Integer userId)
|
|
||||||
{
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername()
|
|
||||||
{
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username)
|
|
||||||
{
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword()
|
|
||||||
{
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password)
|
|
||||||
{
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMobile()
|
|
||||||
{
|
|
||||||
return mobile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMobile(String mobile)
|
|
||||||
{
|
|
||||||
this.mobile = mobile;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,6 +5,8 @@ import com.ruoyi.common.config.RuoYiConfig;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
@ -14,7 +16,7 @@ import springfox.documentation.service.*;
|
|||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,8 +27,10 @@ import java.util.List;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableSwagger2WebMvc
|
@EnableSwagger2
|
||||||
@EnableKnife4j
|
@EnableKnife4j
|
||||||
|
@ConditionalOnClass({Docket.class, ApiInfoBuilder.class})
|
||||||
|
@ConditionalOnProperty(prefix = "swagger", value = "enable", matchIfMissing = true)
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
/**
|
/**
|
||||||
* 系统基础配置
|
* 系统基础配置
|
||||||
@ -34,12 +38,6 @@ public class SwaggerConfig {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RuoYiConfig ruoyiConfig;
|
private RuoYiConfig ruoyiConfig;
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否开启swagger
|
|
||||||
*/
|
|
||||||
@Value("${swagger.enabled}")
|
|
||||||
private boolean enabled;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置请求的统一前缀
|
* 设置请求的统一前缀
|
||||||
*/
|
*/
|
||||||
@ -70,8 +68,6 @@ public class SwaggerConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi() {
|
public Docket createRestApi() {
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
// 是否启用Swagger
|
|
||||||
.enable(enabled)
|
|
||||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
// 设置哪些接口暴露给Swagger展示
|
// 设置哪些接口暴露给Swagger展示
|
||||||
@ -85,15 +81,14 @@ public class SwaggerConfig {
|
|||||||
.build()
|
.build()
|
||||||
/* 设置安全模式,swagger可以设置访问token */
|
/* 设置安全模式,swagger可以设置访问token */
|
||||||
.securitySchemes(securitySchemes())
|
.securitySchemes(securitySchemes())
|
||||||
.securityContexts(securityContexts())
|
.securityContexts(securityContexts());
|
||||||
.pathMapping(pathMapping);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||||
*/
|
*/
|
||||||
private List<ApiKey> securitySchemes() {
|
private List<SecurityScheme> securitySchemes() {
|
||||||
List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
|
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
|
||||||
return apiKeyList;
|
return apiKeyList;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user