1. 增加 swagger 菜单

2. 增加 spring boot admin 菜单
This commit is contained in:
YunaiV 2021-02-20 16:17:26 +08:00
parent 80544e43af
commit d50fa8ed22
29 changed files with 60 additions and 284 deletions

View File

@ -43,8 +43,7 @@
- admin/admin123
演示地址http://vue.ruoyi.vip
文档地址http://doc.ruoyi.vip
演示地址:<http://dashboard.yudao.iocoder.cn>
## 演示图

View File

@ -1,22 +0,0 @@
package com.ruoyi.web.controller.tool;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.core.controller.BaseController;
/**
* swagger 接口
*
* @author ruoyi
*/
@Controller
@RequestMapping("/tool/swagger")
public class SwaggerController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:swagger:view')")
@GetMapping()
public String index() {
return redirect("/swagger-ui.html");
}
}

View File

@ -2,7 +2,7 @@
```bash
# 克隆项目
git clone https://gitee.com/y_project/RuoYi-Vue
git clone https://github.com/YunaiV/ruoyi-vue-pro
# 进入项目目录
cd ruoyi-ui
@ -27,4 +27,4 @@ npm run build:stage
# 构建生产环境
npm run build:prod
```
```

View File

@ -33,7 +33,7 @@
],
"repository": {
"type": "git",
"url": "https://gitee.com/y_project/RuoYi-Vue.git"
"url": "https://github.com/YunaiV/ruoyi-vue-pro"
},
"dependencies": {
"@riophae/vue-treeselect": "0.4.0",

View File

@ -1,9 +0,0 @@
import request from '@/utils/request'
// 查询服务器详细
export function getServer() {
return request({
url: '/monitor/server',
method: 'get'
})
}

View File

@ -6,10 +6,10 @@
<script>
export default {
name: 'RuoYiGit',
name: 'YudaoGit',
data() {
return {
url: 'https://gitee.com/y_project/RuoYi-Vue'
url: 'https://github.com/YunaiV/ruoyi-vue-proe'
}
},
methods: {
@ -18,4 +18,4 @@ export default {
}
}
}
</script>
</script>

View File

@ -55,7 +55,7 @@
size="mini"
icon="el-icon-cloudy"
plain
@click="goTarget('https://gitee.com/y_project/RuoYi-Vue')"
@click="goTarget('https://gitee.com/zhijiantianya/ruoyi-vue-pro')"
>访问码云</el-button
>
<el-button

View File

@ -1,210 +1,32 @@
<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 v-loading="loading" :style="'height:'+ height">
<iframe ref="iframe" :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
</div>
</template>
<script>
import { getServer } from "@/api/monitor/server";
export default {
name: "Server",
data() {
return {
//
loading: [],
//
server: []
src: process.env.VUE_APP_BASE_API + "/admin",
height: document.documentElement.clientHeight - 94.5 + "px;",
loading: true
};
},
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)"
});
}
mounted: function() {
const that = this;
setTimeout(() => {
//
that.$refs["iframe"].contentWindow.document.getElementsByClassName('navbar-item')[2].click();
//
this.loading = false;
}, 230);
//
window.onresize = function temp() {
that.height = document.documentElement.clientHeight - 94.5 + "px;";
};
}
};
</script>
</script>

View File

@ -48,7 +48,7 @@
</el-form>
<!-- 底部 -->
<div class="el-login-footer">
<span>Copyright © 2018-2020 ruoyi.vip All Rights Reserved.</span>
<span>Copyright © 2020-2021 iocoder.cn All Rights Reserved.</span>
</div>
</div>
</template>

View File

@ -8,7 +8,7 @@ export default {
name: "Swagger",
data() {
return {
src: process.env.VUE_APP_BASE_API + "/swagger-ui.html",
src: process.env.VUE_APP_BASE_API + "/doc.html",
height: document.documentElement.clientHeight - 94.5 + "px;",
loading: true
};

View File

@ -22,7 +22,7 @@ import java.util.Properties;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api("Redis 监控 API")
@Api(tags = "Redis 监控")
@RestController
@RequestMapping("/infra/redis")
public class RedisController {

View File

@ -31,7 +31,7 @@ import static cn.iocoder.dashboard.framework.security.core.util.SecurityUtils.ge
import static cn.iocoder.dashboard.util.servlet.ServletUtils.getClientIP;
import static cn.iocoder.dashboard.util.servlet.ServletUtils.getUserAgent;
@Api("认证 API")
@Api(tags = "认证")
@RestController
@RequestMapping("/")
public class SysAuthController {

View File

@ -27,7 +27,7 @@ import java.util.Map;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
import static cn.iocoder.dashboard.util.collection.CollectionUtils.convertList;
@Api("用户 Session API")
@Api(tags = "用户 Session")
@RestController
@RequestMapping("/system/user-session")
public class SysUserSessionController {

View File

@ -13,7 +13,7 @@ import javax.annotation.Resource;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "验证码 API")
@Api(tags = "验证码")
@RestController
@RequestMapping("/system/captcha")
public class SysCaptchaController {

View File

@ -20,7 +20,7 @@ import java.io.IOException;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "文件 API")
@Api(tags = "文件存储")
@RestController
@RequestMapping("/system/file")
@Slf4j

View File

@ -18,7 +18,7 @@ import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "部门 API")
@Api(tags = "部门")
@RestController
@RequestMapping("/system/dept")
public class SysDeptController {

View File

@ -23,7 +23,7 @@ import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "岗位 API")
@Api(tags = "岗位")
@RestController
@RequestMapping("/system/post")
public class SysPostController {

View File

@ -20,7 +20,7 @@ import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "字典数据 API")
@Api(tags = "字典数据")
@RestController
@RequestMapping("/system/dict-data")
public class SysDictDataController {

View File

@ -20,7 +20,7 @@ import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "字典类型 API")
@Api(tags = "字典类型")
@RestController
@RequestMapping("/system/dict-type")
public class SysDictTypeController {

View File

@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Api(tags = "登陆日志 API")
@Api(tags = "登陆日志")
@RestController
@RequestMapping("/system/login-log")
public class SysLoginLogController {

View File

@ -35,7 +35,7 @@ import java.util.Map;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Api(tags = "操作日志 API")
@Api(tags = "操作日志")
@RestController
@RequestMapping("/system/operate-log")
public class SysOperateLogController {

View File

@ -18,7 +18,7 @@ import javax.annotation.Resource;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "通知公告 API")
@Api(tags = "通知公告")
@RestController
@RequestMapping("/system/notice")
public class SysNoticeController {

View File

@ -18,7 +18,7 @@ import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "菜单 API")
@Api(tags = "菜单")
@RestController
@RequestMapping("/system/menu")
public class SysMenuController {

View File

@ -21,7 +21,7 @@ import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
*
* @author 芋道源码
*/
@Api(tags = "权限 API")
@Api(tags = "权限")
@RestController
@RequestMapping("/system/permission")
public class SysPermissionController {

View File

@ -23,7 +23,7 @@ import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "角色 API")
@Api(tags = "角色")
@RestController
@RequestMapping("/system/role")
public class SysRoleController {

View File

@ -30,7 +30,7 @@ import java.util.*;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "用户 API")
@Api(tags = "用户")
@RestController
@RequestMapping("/system/user")
public class SysUserController {

View File

@ -37,7 +37,7 @@ import java.util.Set;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
@Api(tags = "代码生成器 API")
@Api(tags = "代码生成器")
@RestController
@RequestMapping("/tool/codegen")
@Validated
@ -49,8 +49,8 @@ public class ToolCodegenController {
@GetMapping("/db/table/list")
@ApiOperation(value = "获得数据库自带的表定义列表", notes = "会过滤掉已经导入 Codegen 的表")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableName", required = true, example = "yudao", dataTypeClass = String.class),
@ApiImplicitParam(name = "tableComment", required = true, example = "芋道", dataTypeClass = String.class)
@ApiImplicitParam(name = "tableName", value = "表名,模糊匹配", required = true, example = "yudao", dataTypeClass = String.class),
@ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", required = true, example = "芋道", dataTypeClass = String.class)
})
@PreAuthorize("@ss.hasPermission('tool:codegen:query')")
public CommonResult<List<ToolSchemaTableRespVO>> getSchemaTableList(
@ -74,7 +74,7 @@ public class ToolCodegenController {
@GetMapping("/detail")
@ApiOperation("获得表和字段的明细")
@ApiImplicitParam(name = "tableId", required = true, example = "表编号", dataTypeClass = Long.class)
@ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('tool:codegen:query')")
public CommonResult<ToolCodegenDetailRespVO> getCodegenDetail(@RequestParam("tableId") Long tableId) {
ToolCodegenTableDO table = codegenService.getCodegenTablePage(tableId);
@ -84,7 +84,7 @@ public class ToolCodegenController {
}
@ApiOperation("基于数据库的表结构,创建代码生成器的表和字段定义")
@ApiImplicitParam(name = "tableNames", required = true, example = "sys_user", dataTypeClass = List.class)
@ApiImplicitParam(name = "tableNames", value = "表名数组", required = true, example = "sys_user", dataTypeClass = List.class)
@PostMapping("/create-list-from-db")
@PreAuthorize("@ss.hasPermission('tool:codegen:create')")
public CommonResult<List<Long>> createCodegenListFromDB(@RequestParam("tableNames") List<String> tableNames) {
@ -92,7 +92,7 @@ public class ToolCodegenController {
}
@ApiOperation("基于 SQL 建表语句,创建代码生成器的表和字段定义")
@ApiImplicitParam(name = "SQL 建表语句", required = true, example = "sql", dataTypeClass = String.class)
@ApiImplicitParam(name = "sql", value = "SQL 建表语句", required = true, example = "sql", dataTypeClass = String.class)
@PostMapping("/create-list-from-sql")
@PreAuthorize("@ss.hasPermission('tool:codegen:create')")
public CommonResult<Long> createCodegenListFromSQL(@RequestParam("sql") String sql) {
@ -109,7 +109,7 @@ public class ToolCodegenController {
@ApiOperation("基于数据库的表结构,同步数据库的表和字段定义")
@PutMapping("/sync-from-db")
@ApiImplicitParam(name = "tableId", required = true, example = "表编号", dataTypeClass = Long.class)
@ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('tool:codegen:update')")
public CommonResult<Boolean> syncCodegenFromDB(@RequestParam("tableId") Long tableId) {
codegenService.syncCodegenFromDB(tableId);
@ -119,8 +119,8 @@ public class ToolCodegenController {
@ApiOperation("基于 SQL 建表语句,同步数据库的表和字段定义")
@PutMapping("/sync-from-sql")
@ApiImplicitParams({
@ApiImplicitParam(name = "tableId", required = true, example = "表编号", dataTypeClass = Long.class),
@ApiImplicitParam(name = "SQL 建表语句", required = true, example = "sql", dataTypeClass = String.class)
@ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class),
@ApiImplicitParam(name = "sql", value = "SQL 建表语句", required = true, example = "sql", dataTypeClass = String.class)
})
@PreAuthorize("@ss.hasPermission('tool:codegen:update')")
public CommonResult<Boolean> syncCodegenFromSQL(@RequestParam("tableId") Long tableId,
@ -131,7 +131,7 @@ public class ToolCodegenController {
@ApiOperation("删除数据库的表和字段定义")
@DeleteMapping("/delete")
@ApiImplicitParam(name = "tableId", required = true, example = "表编号", dataTypeClass = Long.class)
@ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('tool:codegen:delete')")
public CommonResult<Boolean> deleteCodegen(@RequestParam("tableId") Long tableId) {
codegenService.deleteCodegen(tableId);
@ -140,7 +140,7 @@ public class ToolCodegenController {
@ApiOperation("预览生成代码")
@GetMapping("/preview")
@ApiImplicitParam(name = "tableId", required = true, example = "表编号", dataTypeClass = Long.class)
@ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('tool:codegen:preview')")
public CommonResult<List<ToolCodegenPreviewRespVO>> previewCodegen(@RequestParam("tableId") Long tableId) {
Map<String, String> codes = codegenService.generationCodes(tableId);
@ -149,7 +149,7 @@ public class ToolCodegenController {
@ApiOperation("下载生成代码")
@GetMapping("/download")
@ApiImplicitParam(name = "tableId", required = true, example = "表编号", dataTypeClass = Long.class)
@ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('tool:codegen:download')")
public void downloadCodegen(@RequestParam("tableId") Long tableId,
HttpServletResponse response) throws IOException {
@ -164,18 +164,4 @@ public class ToolCodegenController {
ServletUtils.writeAttachment(response, "codegen.zip", outputStream.toByteArray());
}
// /**
// * 查询数据表字段列表
// */
// @PreAuthorize("@ss.hasPermi('tool:gen:list')")
// @GetMapping(value = "/column/{talbleId}")
// public TableDataInfo columnList(Long tableId) {
// TableDataInfo dataInfo = new TableDataInfo();
// List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
// dataInfo.setRows(list);
// dataInfo.setTotal(list.size());
// return dataInfo;
// }
//
}

View File

@ -75,7 +75,7 @@ spring:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
url: http://127.0.0.1:8080/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
# Spring Boot Admin Server 服务端的相关配置
context-path: /admin # 配置 Spring

View File

@ -75,7 +75,7 @@ spring:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
url: http://127.0.0.1:8080/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
# Spring Boot Admin Server 服务端的相关配置
context-path: /admin # 配置 Spring