Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
mayuanfei 2023-03-07 13:44:51 +08:00
commit 2e6a981edd
95 changed files with 1735 additions and 1038 deletions

12
pom.xml
View File

@ -14,7 +14,7 @@
<properties> <properties>
<ruoyi-vue-plus.version>4.5.0</ruoyi-vue-plus.version> <ruoyi-vue-plus.version>4.5.0</ruoyi-vue-plus.version>
<spring-boot.version>2.7.7</spring-boot.version> <spring-boot.version>2.7.9</spring-boot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version> <java.version>1.8</java.version>
@ -22,15 +22,15 @@
<spring-boot.mybatis>2.2.2</spring-boot.mybatis> <spring-boot.mybatis>2.2.2</spring-boot.mybatis>
<springdoc.version>1.6.14</springdoc.version> <springdoc.version>1.6.14</springdoc.version>
<poi.version>5.2.3</poi.version> <poi.version>5.2.3</poi.version>
<easyexcel.version>3.1.5</easyexcel.version> <easyexcel.version>3.2.1</easyexcel.version>
<velocity.version>2.3</velocity.version> <velocity.version>2.3</velocity.version>
<satoken.version>1.34.0</satoken.version> <satoken.version>1.34.0</satoken.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version> <mybatis-plus.version>3.5.3.1</mybatis-plus.version>
<p6spy.version>3.9.1</p6spy.version> <p6spy.version>3.9.1</p6spy.version>
<hutool.version>5.8.11</hutool.version> <hutool.version>5.8.14</hutool.version>
<okhttp.version>4.10.0</okhttp.version> <okhttp.version>4.10.0</okhttp.version>
<spring-boot-admin.version>2.7.10</spring-boot-admin.version> <spring-boot-admin.version>2.7.10</spring-boot-admin.version>
<redisson.version>3.19.1</redisson.version> <redisson.version>3.20.0</redisson.version>
<lock4j.version>2.2.3</lock4j.version> <lock4j.version>2.2.3</lock4j.version>
<dynamic-ds.version>3.5.2</dynamic-ds.version> <dynamic-ds.version>3.5.2</dynamic-ds.version>
<alibaba-ttl.version>2.14.2</alibaba-ttl.version> <alibaba-ttl.version>2.14.2</alibaba-ttl.version>
@ -42,10 +42,10 @@
<snakeyaml.version>1.33</snakeyaml.version> <snakeyaml.version>1.33</snakeyaml.version>
<!-- OSS 配置 --> <!-- OSS 配置 -->
<aws-java-sdk-s3.version>1.12.373</aws-java-sdk-s3.version> <aws-java-sdk-s3.version>1.12.400</aws-java-sdk-s3.version>
<!-- SMS 配置 --> <!-- SMS 配置 -->
<aliyun.sms.version>2.0.23</aliyun.sms.version> <aliyun.sms.version>2.0.23</aliyun.sms.version>
<tencent.sms.version>3.1.660</tencent.sms.version> <tencent.sms.version>3.1.687</tencent.sms.version>
</properties> </properties>
<profiles> <profiles>

View File

@ -79,7 +79,7 @@ public class SysConfigController extends BaseController {
@Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysConfig config) { public R<Void> add(@Validated @RequestBody SysConfig config) {
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { if (!configService.checkConfigKeyUnique(config)) {
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
configService.insertConfig(config); configService.insertConfig(config);
@ -93,7 +93,7 @@ public class SysConfigController extends BaseController {
@Log(title = "参数管理", businessType = BusinessType.UPDATE) @Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public R<Void> edit(@Validated @RequestBody SysConfig config) { public R<Void> edit(@Validated @RequestBody SysConfig config) {
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) { if (!configService.checkConfigKeyUnique(config)) {
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
configService.updateConfig(config); configService.updateConfig(config);

View File

@ -1,7 +1,7 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.convert.Convert;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -49,7 +49,7 @@ public class SysDeptController extends BaseController {
public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { public R<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept()); List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().equals(deptId) depts.removeIf(d -> d.getDeptId().equals(deptId)
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); || StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
return R.ok(depts); return R.ok(depts);
} }
@ -72,7 +72,7 @@ public class SysDeptController extends BaseController {
@Log(title = "部门管理", businessType = BusinessType.INSERT) @Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysDept dept) { public R<Void> add(@Validated @RequestBody SysDept dept) {
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { if (!deptService.checkDeptNameUnique(dept)) {
return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
@ -87,7 +87,7 @@ public class SysDeptController extends BaseController {
public R<Void> edit(@Validated @RequestBody SysDept dept) { public R<Void> edit(@Validated @RequestBody SysDept dept) {
Long deptId = dept.getDeptId(); Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { if (!deptService.checkDeptNameUnique(dept)) {
return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} else if (dept.getParentId().equals(deptId)) { } else if (dept.getParentId().equals(deptId)) {
return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");

View File

@ -69,7 +69,7 @@ public class SysDictTypeController extends BaseController {
@Log(title = "字典类型", businessType = BusinessType.INSERT) @Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysDictType dict) { public R<Void> add(@Validated @RequestBody SysDictType dict) {
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { if (!dictTypeService.checkDictTypeUnique(dict)) {
return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); return R.fail("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
dictTypeService.insertDictType(dict); dictTypeService.insertDictType(dict);
@ -83,7 +83,7 @@ public class SysDictTypeController extends BaseController {
@Log(title = "字典类型", businessType = BusinessType.UPDATE) @Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public R<Void> edit(@Validated @RequestBody SysDictType dict) { public R<Void> edit(@Validated @RequestBody SysDictType dict) {
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict))) { if (!dictTypeService.checkDictTypeUnique(dict)) {
return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); return R.fail("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
dictTypeService.updateDictType(dict); dictTypeService.updateDictType(dict);

View File

@ -82,7 +82,7 @@ public class SysMenuController extends BaseController {
@Log(title = "菜单管理", businessType = BusinessType.INSERT) @Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysMenu menu) { public R<Void> add(@Validated @RequestBody SysMenu menu) {
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { if (!menuService.checkMenuNameUnique(menu)) {
return R.fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return R.fail("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
return R.fail("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头"); return R.fail("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
@ -97,7 +97,7 @@ public class SysMenuController extends BaseController {
@Log(title = "菜单管理", businessType = BusinessType.UPDATE) @Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public R<Void> edit(@Validated @RequestBody SysMenu menu) { public R<Void> edit(@Validated @RequestBody SysMenu menu) {
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { if (!menuService.checkMenuNameUnique(menu)) {
return R.fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return R.fail("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) { } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) {
return R.fail("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头"); return R.fail("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");

View File

@ -69,9 +69,9 @@ public class SysPostController extends BaseController {
@Log(title = "岗位管理", businessType = BusinessType.INSERT) @Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysPost post) { public R<Void> add(@Validated @RequestBody SysPost post) {
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { if (!postService.checkPostNameUnique(post)) {
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { } else if (!postService.checkPostCodeUnique(post)) {
return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); return R.fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
} }
return toAjax(postService.insertPost(post)); return toAjax(postService.insertPost(post));
@ -84,9 +84,9 @@ public class SysPostController extends BaseController {
@Log(title = "岗位管理", businessType = BusinessType.UPDATE) @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public R<Void> edit(@Validated @RequestBody SysPost post) { public R<Void> edit(@Validated @RequestBody SysPost post) {
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { if (!postService.checkPostNameUnique(post)) {
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
} else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { } else if (!postService.checkPostCodeUnique(post)) {
return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
} }
return toAjax(postService.updatePost(post)); return toAjax(postService.updatePost(post));

View File

@ -58,12 +58,10 @@ public class SysProfileController extends BaseController {
@Log(title = "个人信息", businessType = BusinessType.UPDATE) @Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public R<Void> updateProfile(@RequestBody SysUser user) { public R<Void> updateProfile(@RequestBody SysUser user) {
if (StringUtils.isNotEmpty(user.getPhonenumber()) if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
} }
if (StringUtils.isNotEmpty(user.getEmail()) if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
} }
user.setUserId(getUserId()); user.setUserId(getUserId());

View File

@ -1,8 +1,11 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil; import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
@ -84,9 +87,9 @@ public class SysRoleController extends BaseController {
@Log(title = "角色管理", businessType = BusinessType.INSERT) @Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysRole role) { public R<Void> add(@Validated @RequestBody SysRole role) {
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { if (!roleService.checkRoleNameUnique(role)) {
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); return R.fail("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { } else if (!roleService.checkRoleKeyUnique(role)) {
return R.fail("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); return R.fail("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
return toAjax(roleService.insertRole(role)); return toAjax(roleService.insertRole(role));
@ -102,20 +105,32 @@ public class SysRoleController extends BaseController {
public R<Void> edit(@Validated @RequestBody SysRole role) { public R<Void> edit(@Validated @RequestBody SysRole role) {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { if (!roleService.checkRoleNameUnique(role)) {
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); return R.fail("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { } else if (!roleService.checkRoleKeyUnique(role)) {
return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); return R.fail("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
if (roleService.updateRole(role) > 0) { if (roleService.updateRole(role) > 0) {
// 更新缓存用户权限 List<String> keys = StpUtil.searchTokenValue("", 0, -1, false);
LoginUser loginUser = getLoginUser(); if (CollUtil.isEmpty(keys)) {
SysUser sysUser = userService.selectUserById(loginUser.getUserId()); return R.ok();
if (ObjectUtil.isNotNull(sysUser) && !sysUser.isAdmin()) {
loginUser.setMenuPermission(permissionService.getMenuPermission(sysUser));
LoginHelper.setLoginUser(loginUser);
} }
// 角色关联的在线用户量过大会导致redis阻塞卡顿 谨慎操作
keys.parallelStream().forEach(key -> {
String token = key.replace(CacheConstants.LOGIN_TOKEN_KEY, "");
// 如果已经过期则跳过
if (StpUtil.stpLogic.getTokenActivityTimeoutByToken(token) < -1) {
return;
}
LoginUser loginUser = LoginHelper.getLoginUser(token);
if (loginUser.getRoles().stream().anyMatch(r -> r.getRoleId().equals(role.getRoleId()))) {
try {
StpUtil.logoutByTokenValue(token);
} catch (NotLoginException ignored) {
}
}
});
return R.ok(); return R.ok();
} }
return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); return R.fail("修改角色'" + role.getRoleName() + "'失败,请联系管理员");

View File

@ -136,13 +136,11 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.INSERT) @Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public R<Void> add(@Validated @RequestBody SysUser user) { public R<Void> add(@Validated @RequestBody SysUser user) {
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) { if (!userService.checkUserNameUnique(user)) {
return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
} else if (StringUtils.isNotEmpty(user.getEmail()) } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
} }
user.setPassword(BCrypt.hashpw(user.getPassword())); user.setPassword(BCrypt.hashpw(user.getPassword()));
@ -158,13 +156,11 @@ public class SysUserController extends BaseController {
public R<Void> edit(@Validated @RequestBody SysUser user) { public R<Void> edit(@Validated @RequestBody SysUser user) {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); userService.checkUserDataScope(user.getUserId());
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) { if (!userService.checkUserNameUnique(user)) {
return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
} else if (StringUtils.isNotEmpty(user.getEmail()) } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
} }
return toAjax(userService.updateUser(user)); return toAjax(userService.updateUser(user));

View File

@ -86,15 +86,17 @@ spring:
# 最小空闲线程数量 # 最小空闲线程数量
minIdle: 10 minIdle: 10
# 配置获取连接等待超时的时间 # 配置获取连接等待超时的时间
connectionTimeout: 10000 connectionTimeout: 30000
# 校验超时时间 # 校验超时时间
validationTimeout: 5000 validationTimeout: 5000
# 空闲连接存活最大时间默认10分钟 # 空闲连接存活最大时间默认10分钟
idleTimeout: 60000 idleTimeout: 600000
# 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟 # 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟
maxLifetime: 900000 maxLifetime: 1800000
# 连接测试query配置检测连接是否有效 # 连接测试query配置检测连接是否有效
connectionTestQuery: SELECT 1 connectionTestQuery: SELECT 1
# 多久检查一次连接的活性
keepaliveTime: 30000
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉) --- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring: spring:

View File

@ -89,15 +89,17 @@ spring:
# 最小空闲线程数量 # 最小空闲线程数量
minIdle: 10 minIdle: 10
# 配置获取连接等待超时的时间 # 配置获取连接等待超时的时间
connectionTimeout: 10000 connectionTimeout: 30000
# 校验超时时间 # 校验超时时间
validationTimeout: 5000 validationTimeout: 5000
# 空闲连接存活最大时间默认10分钟 # 空闲连接存活最大时间默认10分钟
idleTimeout: 60000 idleTimeout: 600000
# 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟 # 此属性控制池中连接的最长生命周期值0表示无限生命周期默认30分钟
maxLifetime: 900000 maxLifetime: 1800000
# 连接测试query配置检测连接是否有效 # 连接测试query配置检测连接是否有效
connectionTestQuery: SELECT 1 connectionTestQuery: SELECT 1
# 多久检查一次连接的活性
keepaliveTime: 30000
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉) --- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring: spring:

View File

@ -128,8 +128,10 @@ security:
- /**/*.html - /**/*.html
- /**/*.css - /**/*.css
- /**/*.js - /**/*.js
# swagger 文档配置 # 公共路径
- /favicon.ico - /favicon.ico
- /error
# swagger 文档配置
- /*/api-docs - /*/api-docs
- /*/api-docs/** - /*/api-docs/**
# actuator 监控配置 # actuator 监控配置
@ -196,8 +198,6 @@ mybatis-encryptor:
# Swagger配置 # Swagger配置
swagger: swagger:
# 是否开启swagger
enabled: true
info: info:
# 标题 # 标题
title: '标题:${ruoyi.name}后台管理系统_接口文档' title: '标题:${ruoyi.name}后台管理系统_接口文档'
@ -219,6 +219,9 @@ swagger:
name: ${sa-token.token-name} name: ${sa-token.token-name}
springdoc: springdoc:
api-docs:
# 是否开启接口文档
enabled: true
swagger-ui: swagger-ui:
# 持久化认证数据 # 持久化认证数据
persistAuthorization: true persistAuthorization: true

View File

@ -13,7 +13,9 @@ import java.lang.annotation.Target;
* 字典数据映射注解 * 字典数据映射注解
* *
* @author itino * @author itino
* @deprecated 建议使用通用翻译注解
*/ */
@Deprecated
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD}) @Target({ElementType.FIELD, ElementType.METHOD})
@JacksonAnnotationsInside @JacksonAnnotationsInside

View File

@ -1,5 +1,7 @@
package com.ruoyi.common.annotation; package com.ruoyi.common.annotation;
import com.ruoyi.common.utils.StringUtils;
import java.lang.annotation.*; import java.lang.annotation.*;
/** /**
@ -25,6 +27,6 @@ public @interface ExcelDictFormat {
/** /**
* 分隔符读取字符串组内容 * 分隔符读取字符串组内容
*/ */
String separator() default ","; String separator() default StringUtils.SEPARATOR;
} }

View File

@ -0,0 +1,30 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.*;
/**
* 枚举格式化
*
* @author Liang
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface ExcelEnumFormat {
/**
* 字典枚举类型
*/
Class<? extends Enum<?>> enumClass();
/**
* 字典枚举类中对应的code属性名称默认为code
*/
String codeField() default "code";
/**
* 字典枚举类中对应的text属性名称默认为text
*/
String textField() default "text";
}

View File

@ -38,4 +38,10 @@ public @interface Log {
* 是否保存响应的参数 * 是否保存响应的参数
*/ */
boolean isSaveResponseData() default true; boolean isSaveResponseData() default true;
/**
* 排除指定的请求参数
*/
String[] excludeParamNames() default {};
} }

View File

@ -1,6 +1,5 @@
package com.ruoyi.common.annotation; package com.ruoyi.common.annotation;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.enums.LimitType; import com.ruoyi.common.enums.LimitType;
import java.lang.annotation.*; import java.lang.annotation.*;
@ -15,9 +14,10 @@ import java.lang.annotation.*;
@Documented @Documented
public @interface RateLimiter { public @interface RateLimiter {
/** /**
* 限流key * 限流key,支持使用Spring el表达式来动态获取方法上的参数值
* 格式类似于 #code.id #{#code}
*/ */
String key() default CacheConstants.RATE_LIMIT_KEY; String key() default "";
/** /**
* 限流时间,单位秒 * 限流时间,单位秒
@ -33,4 +33,9 @@ public @interface RateLimiter {
* 限流类型 * 限流类型
*/ */
LimitType limitType() default LimitType.DEFAULT; LimitType limitType() default LimitType.DEFAULT;
/**
* 提示消息 支持国际化 格式为 {code}
*/
String message() default "{rate.limiter.message}";
} }

View File

@ -0,0 +1,39 @@
package com.ruoyi.common.annotation;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ruoyi.common.translation.handler.TranslationHandler;
import java.lang.annotation.*;
/**
* 通用翻译注解
*
* @author Lion Li
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@Documented
@JacksonAnnotationsInside
@JsonSerialize(using = TranslationHandler.class)
public @interface Translation {
/**
* 类型 (需与实现类上的 {@link com.ruoyi.common.annotation.TranslationType} 注解type对应)
* <p>
* 默认取当前字段的值 如果设置了 @{@link Translation#mapper()} 则取映射字段的值
*/
String type();
/**
* 映射字段 (如果不为空则取此字段的值)
*/
String mapper() default "";
/**
* 其他条件 例如: 字典type(sys_user_sex)
*/
String other() default "";
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.*;
/**
* 翻译类型注解 (标注到{@link com.ruoyi.common.translation.TranslationInterface} 的实现类)
*
* @author Lion Li
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
public @interface TranslationType {
/**
* 类型
*/
String type();
}

View File

@ -30,6 +30,16 @@ public interface CacheNames {
*/ */
String SYS_DICT = "sys_dict"; String SYS_DICT = "sys_dict";
/**
* 用户账户
*/
String SYS_USER_NAME = "sys_user_name#30d";
/**
* 部门
*/
String SYS_DEPT = "sys_dept#30d";
/** /**
* OSS内容 * OSS内容
*/ */

View File

@ -0,0 +1,30 @@
package com.ruoyi.common.constant;
/**
* 翻译常量
*
* @author Lion Li
*/
public interface TransConstant {
/**
* 用户id转账号
*/
String USER_ID_TO_NAME = "user_id_to_name";
/**
* 部门id转名称
*/
String DEPT_ID_TO_NAME = "dept_id_to_name";
/**
* 字典type转label
*/
String DICT_TYPE_TO_LABEL = "dict_type_to_label";
/**
* ossId转url
*/
String OSS_ID_TO_URL = "oss_id_to_url";
}

View File

@ -0,0 +1,75 @@
package com.ruoyi.common.convert;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.ruoyi.common.annotation.ExcelEnumFormat;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
* 枚举格式化转换处理
*
* @author Liang
*/
@Slf4j
public class ExcelEnumConvert implements Converter<Object> {
@Override
public Class<Object> supportJavaTypeKey() {
return Object.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return null;
}
@Override
public Object convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
Object codeValue = cellData.getData();
// 如果是空值
if (ObjectUtil.isNull(codeValue)) {
return null;
}
Map<Object, String> enumValueMap = beforeConvert(contentProperty);
String textValue = enumValueMap.get(codeValue);
return Convert.convert(contentProperty.getField().getType(), textValue);
}
@Override
public WriteCellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
if (ObjectUtil.isNull(object)) {
return new WriteCellData<>("");
}
Map<Object, String> enumValueMap = beforeConvert(contentProperty);
String value = Convert.toStr(enumValueMap.get(object), "");
return new WriteCellData<>(value);
}
private Map<Object, String> beforeConvert(ExcelContentProperty contentProperty) {
ExcelEnumFormat anno = getAnnotation(contentProperty.getField());
Map<Object, String> enumValueMap = new HashMap<>();
Enum<?>[] enumConstants = anno.enumClass().getEnumConstants();
for (Enum<?> enumConstant : enumConstants) {
Object codeValue = ReflectUtils.invokeGetter(enumConstant, anno.codeField());
String textValue = ReflectUtils.invokeGetter(enumConstant, anno.textField());
enumValueMap.put(codeValue, textValue);
}
return enumValueMap;
}
private ExcelEnumFormat getAnnotation(Field field) {
return AnnotationUtil.getAnnotation(field, ExcelEnumFormat.class);
}
}

View File

@ -87,8 +87,8 @@ public class PageQuery implements Serializable {
// 兼容前端排序类型 // 兼容前端排序类型
isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"}); isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
String[] orderByArr = orderBy.split(","); String[] orderByArr = orderBy.split(StringUtils.SEPARATOR);
String[] isAscArr = isAsc.split(","); String[] isAscArr = isAsc.split(StringUtils.SEPARATOR);
if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) { if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
throw new ServiceException("排序参数有误"); throw new ServiceException("排序参数有误");
} }

View File

@ -17,7 +17,6 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.util.Set;
/** /**
* 角色表 sys_role * 角色表 sys_role
@ -115,12 +114,6 @@ public class SysRole extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private Long[] deptIds; private Long[] deptIds;
/**
* 角色菜单权限
*/
@TableField(exist = false)
private Set<String> permissions;
public SysRole(Long roleId) { public SysRole(Long roleId) {
this.roleId = roleId; this.roleId = roleId;
} }

View File

@ -1,7 +1,6 @@
package com.ruoyi.common.core.domain.model; package com.ruoyi.common.core.domain.model;
import com.ruoyi.common.core.domain.dto.RoleDTO; import com.ruoyi.common.core.domain.dto.RoleDTO;
import com.ruoyi.common.helper.LoginHelper;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -111,7 +110,7 @@ public class LoginUser implements Serializable {
if (userId == null) { if (userId == null) {
throw new IllegalArgumentException("用户ID不能为空"); throw new IllegalArgumentException("用户ID不能为空");
} }
return userType + LoginHelper.JOIN_CODE + userId; return userType + ":" + userId;
} }
} }

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.core.service;
/**
* 通用 部门服务
*
* @author Lion Li
*/
public interface DeptService {
/**
* 通过部门ID查询部门名称
*
* @param deptIds 部门ID串逗号分隔
* @return 部门名称串逗号分隔
*/
String selectDeptNameByIds(String deptIds);
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.core.service;
/**
* 通用 OSS服务
*
* @author Lion Li
*/
public interface OssService {
/**
* 通过ossId查询对应的url
*
* @param ossIds ossId串逗号分隔
* @return url串逗号分隔
*/
String selectUrlByIds(String ossIds);
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.core.service;
/**
* 通用 用户服务
*
* @author Lion Li
*/
public interface UserService {
/**
* 通过用户ID查询用户账户
*
* @param userId 用户ID
* @return 用户账户
*/
String selectUserNameById(Long userId);
}

View File

@ -25,7 +25,7 @@ public class XssFilter implements Filter {
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
String tempExcludes = filterConfig.getInitParameter("excludes"); String tempExcludes = filterConfig.getInitParameter("excludes");
if (StringUtils.isNotEmpty(tempExcludes)) { if (StringUtils.isNotEmpty(tempExcludes)) {
String[] url = tempExcludes.split(","); String[] url = tempExcludes.split(StringUtils.SEPARATOR);
for (int i = 0; url != null && i < url.length; i++) { for (int i = 0; url != null && i < url.length; i++) {
excludes.add(url[i]); excludes.add(url[i]);
} }

View File

@ -3,6 +3,8 @@ package com.ruoyi.common.helper;
import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.context.model.SaStorage; import cn.dev33.satoken.context.model.SaStorage;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -44,4 +46,19 @@ public class DataPermissionHelper {
} }
throw new NullPointerException("data permission context type exception"); throw new NullPointerException("data permission context type exception");
} }
/**
* 开启忽略数据权限(开启后需手动调用 {@link #disableIgnore()} 关闭)
*/
public static void enableIgnore() {
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().dataPermission(true).build());
}
/**
* 关闭忽略数据权限
*/
public static void disableIgnore() {
InterceptorIgnoreHelper.clearIgnoreStrategy();
}
} }

View File

@ -1,25 +1,24 @@
package com.ruoyi.common.helper; package com.ruoyi.common.helper;
import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.DeviceType; import com.ruoyi.common.enums.DeviceType;
import com.ruoyi.common.enums.UserType; import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.exception.UtilException;
import com.ruoyi.common.utils.StringUtils;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* 登录鉴权助手 * 登录鉴权助手
* * <p>
* user_type 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app * user_type 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app
* deivce 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios * deivce 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios
* 可以组成 用户类型与设备类型多对多的 权限灵活控制 * 可以组成 用户类型与设备类型多对多的 权限灵活控制
* * <p>
* 多用户体系 针对 多种用户类型 但权限控制不一致 * 多用户体系 针对 多种用户类型 但权限控制不一致
* 可以组成 多用户类型表与多设备类型 分别控制权限 * 可以组成 多用户类型表与多设备类型 分别控制权限
* *
@ -28,8 +27,8 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class LoginHelper { public class LoginHelper {
public static final String JOIN_CODE = ":";
public static final String LOGIN_USER_KEY = "loginUser"; public static final String LOGIN_USER_KEY = "loginUser";
public static final String USER_KEY = "userId";
/** /**
* 登录系统 * 登录系统
@ -37,9 +36,7 @@ public class LoginHelper {
* @param loginUser 登录用户信息 * @param loginUser 登录用户信息
*/ */
public static void login(LoginUser loginUser) { public static void login(LoginUser loginUser) {
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser); loginByDevice(loginUser, null);
StpUtil.login(loginUser.getLoginId());
setLoginUser(loginUser);
} }
/** /**
@ -50,14 +47,11 @@ public class LoginHelper {
*/ */
public static void loginByDevice(LoginUser loginUser, DeviceType deviceType) { public static void loginByDevice(LoginUser loginUser, DeviceType deviceType) {
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser); SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
StpUtil.login(loginUser.getLoginId(), deviceType.getDevice()); SaLoginModel model = new SaLoginModel();
setLoginUser(loginUser); if (ObjectUtil.isNotNull(deviceType)) {
} model.setDevice(deviceType.getDevice());
}
/** StpUtil.login(loginUser.getLoginId(), model.setExtra(USER_KEY, loginUser.getUserId()));
* 设置用户数据(多级缓存)
*/
public static void setLoginUser(LoginUser loginUser) {
StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser); StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
} }
@ -74,27 +68,24 @@ public class LoginHelper {
return loginUser; return loginUser;
} }
/**
* 获取用户基于token
*/
public static LoginUser getLoginUser(String token) {
return (LoginUser) StpUtil.getTokenSessionByToken(token).get(LOGIN_USER_KEY);
}
/** /**
* 获取用户id * 获取用户id
*/ */
public static Long getUserId() { public static Long getUserId() {
LoginUser loginUser = getLoginUser(); Long userId;
if (ObjectUtil.isNull(loginUser)) { try {
String loginId = StpUtil.getLoginIdAsString(); userId = Convert.toLong(StpUtil.getExtra(USER_KEY));
String userId = null; } catch (Exception e) {
for (UserType value : UserType.values()) { return null;
if (StringUtils.contains(loginId, value.getUserType())) {
String[] strs = StringUtils.split(loginId, JOIN_CODE);
// 用户id在总是在最后
userId = strs[strs.length - 1];
}
}
if (StringUtils.isBlank(userId)) {
throw new UtilException("登录用户: LoginId异常 => " + loginId);
}
return Long.parseLong(userId);
} }
return loginUser.getUserId(); return userId;
} }
/** /**

View File

@ -22,7 +22,9 @@ import java.util.Objects;
* 字典数据json序列化工具 * 字典数据json序列化工具
* *
* @author itino * @author itino
* @deprecated 建议使用通用翻译注解
*/ */
@Deprecated
@Slf4j @Slf4j
public class DictDataJsonSerializer extends JsonSerializer<String> implements ContextualSerializer { public class DictDataJsonSerializer extends JsonSerializer<String> implements ContextualSerializer {

View File

@ -0,0 +1,17 @@
package com.ruoyi.common.translation;
/**
* 翻译接口 (实现类需标注 {@link com.ruoyi.common.annotation.TranslationType} 注解标明翻译类型)
*
* @author Lion Li
*/
public interface TranslationInterface<T> {
/**
* 翻译
*
* @param key 需要被翻译的键(不为空)
* @return 返回键对应的值
*/
T translation(Object key, String other);
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.translation.handler;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import java.util.List;
/**
* Bean 序列化修改器 解决 Null 被单独处理问题
*
* @author Lion Li
*/
public class TranslationBeanSerializerModifier extends BeanSerializerModifier {
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
List<BeanPropertyWriter> beanProperties) {
for (BeanPropertyWriter writer : beanProperties) {
// 如果序列化器为 TranslationHandler 的话 Null 值也交给他处理
if (writer.getSerializer() instanceof TranslationHandler) {
writer.assignNullSerializer(writer.getSerializer());
}
}
return beanProperties;
}
}

View File

@ -0,0 +1,65 @@
package com.ruoyi.common.translation.handler;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import com.ruoyi.common.annotation.Translation;
import com.ruoyi.common.translation.TranslationInterface;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
* 翻译处理器
*
* @author Lion Li
*/
@Slf4j
public class TranslationHandler extends JsonSerializer<Object> implements ContextualSerializer {
/**
* 全局翻译实现类映射器
*/
public static final Map<String, TranslationInterface<?>> TRANSLATION_MAPPER = new ConcurrentHashMap<>();
private Translation translation;
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
TranslationInterface<?> trans = TRANSLATION_MAPPER.get(translation.type());
if (ObjectUtil.isNotNull(trans)) {
// 如果映射字段不为空 则取映射字段的值
if (StringUtils.isNotBlank(translation.mapper())) {
value = ReflectUtils.invokeGetter(gen.getCurrentValue(), translation.mapper());
}
// 如果为 null 直接写出
if (ObjectUtil.isNull(value)) {
gen.writeNull();
return;
}
Object result = trans.translation(value, translation.other());
gen.writeObject(result);
} else {
gen.writeObject(value);
}
}
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
Translation translation = property.getAnnotation(Translation.class);
if (Objects.nonNull(translation)) {
this.translation = translation;
return this;
}
return prov.findValueSerializer(property.getType(), property);
}
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.common.translation.impl;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.constant.TransConstant;
import com.ruoyi.common.core.service.DeptService;
import com.ruoyi.common.translation.TranslationInterface;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
/**
* 部门翻译实现
*
* @author Lion Li
*/
@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.DEPT_ID_TO_NAME)
public class DeptNameTranslationImpl implements TranslationInterface<String> {
private final DeptService deptService;
public String translation(Object key, String other) {
return deptService.selectDeptNameByIds(key.toString());
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.translation.impl;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.constant.TransConstant;
import com.ruoyi.common.core.service.DictService;
import com.ruoyi.common.translation.TranslationInterface;
import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
/**
* 字典翻译实现
*
* @author Lion Li
*/
@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.DICT_TYPE_TO_LABEL)
public class DictTypeTranslationImpl implements TranslationInterface<String> {
private final DictService dictService;
public String translation(Object key, String other) {
if (key instanceof String && StringUtils.isNotBlank(other)) {
return dictService.getDictLabel(other, key.toString());
}
return null;
}
}

View File

@ -0,0 +1,25 @@
package com.ruoyi.common.translation.impl;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.constant.TransConstant;
import com.ruoyi.common.core.service.OssService;
import com.ruoyi.common.translation.TranslationInterface;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
/**
* OSS翻译实现
*
* @author Lion Li
*/
@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.OSS_ID_TO_URL)
public class OssUrlTranslationImpl implements TranslationInterface<String> {
private final OssService ossService;
public String translation(Object key, String other) {
return ossService.selectUrlByIds(key.toString());
}
}

View File

@ -0,0 +1,28 @@
package com.ruoyi.common.translation.impl;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.constant.TransConstant;
import com.ruoyi.common.core.service.UserService;
import com.ruoyi.common.translation.TranslationInterface;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
/**
* 用户名翻译实现
*
* @author Lion Li
*/
@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.USER_ID_TO_NAME)
public class UserNameTranslationImpl implements TranslationInterface<String> {
private final UserService userService;
public String translation(Object key, String other) {
if (key instanceof Long) {
return userService.selectUserNameById((Long) key);
}
return null;
}
}

View File

@ -94,7 +94,7 @@ public class ServletUtils extends ServletUtil {
public static Map<String, String> getParamMap(ServletRequest request) { public static Map<String, String> getParamMap(ServletRequest request) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) { for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ",")); params.put(entry.getKey(), StringUtils.join(entry.getValue(), StringUtils.SEPARATOR));
} }
return params; return params;
} }

View File

@ -41,7 +41,7 @@ public class StreamUtils {
* @return 拼接后的list * @return 拼接后的list
*/ */
public static <E> String join(Collection<E> collection, Function<E, String> function) { public static <E> String join(Collection<E> collection, Function<E, String> function) {
return join(collection, function, ","); return join(collection, function, StringUtils.SEPARATOR);
} }
/** /**

View File

@ -1,16 +1,16 @@
package com.ruoyi.common.utils; package com.ruoyi.common.utils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.Validator; import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet; import java.util.function.Function;
import java.util.List; import java.util.stream.Collectors;
import java.util.Set;
/** /**
* 字符串工具类 * 字符串工具类
@ -20,6 +20,8 @@ import java.util.Set;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class StringUtils extends org.apache.commons.lang3.StringUtils { public class StringUtils extends org.apache.commons.lang3.StringUtils {
public static final String SEPARATOR = ",";
/** /**
* 获取参数不为空值 * 获取参数不为空值
* *
@ -224,7 +226,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* *
* @param pattern 匹配规则 * @param pattern 匹配规则
* @param url 需要匹配的url * @param url 需要匹配的url
* @return
*/ */
public static boolean isMatch(String pattern, String url) { public static boolean isMatch(String pattern, String url) {
AntPathMatcher matcher = new AntPathMatcher(); AntPathMatcher matcher = new AntPathMatcher();
@ -234,23 +235,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
/** /**
* 数字左边补齐0使之达到指定长度注意如果数字转换为字符串后长度大于size则只保留 最后size个字符 * 数字左边补齐0使之达到指定长度注意如果数字转换为字符串后长度大于size则只保留 最后size个字符
* *
* @param num 数字对象 * @param num 数字对象
* @param size 字符串指定长度 * @param size 字符串指定长度
* @return 返回数字的字符串格式该字符串为指定长度 * @return 返回数字的字符串格式该字符串为指定长度
*/ */
public static final String padl(final Number num, final int size) { public static String padl(final Number num, final int size) {
return padl(num.toString(), size, '0'); return padl(num.toString(), size, '0');
} }
/** /**
* 字符串左补齐如果原始字符串s长度大于size则只保留最后size个字符 * 字符串左补齐如果原始字符串s长度大于size则只保留最后size个字符
* *
* @param s 原始字符串 * @param s 原始字符串
* @param size 字符串指定长度 * @param size 字符串指定长度
* @param c 用于补齐的字符 * @param c 用于补齐的字符
* @return 返回指定长度的字符串由原字符串左补齐或截取得到 * @return 返回指定长度的字符串由原字符串左补齐或截取得到
*/ */
public static final String padl(final String s, final int size, final char c) { public static String padl(final String s, final int size, final char c) {
final StringBuilder sb = new StringBuilder(size); final StringBuilder sb = new StringBuilder(size);
if (s != null) { if (s != null) {
final int len = s.length(); final int len = s.length();
@ -270,4 +271,55 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return sb.toString(); return sb.toString();
} }
/**
* 切分字符串(分隔符默认逗号)
*
* @param str 被切分的字符串
* @return 分割后的数据列表
*/
public static List<String> splitList(String str) {
return splitTo(str, Convert::toStr);
}
/**
* 切分字符串
*
* @param str 被切分的字符串
* @param separator 分隔符
* @return 分割后的数据列表
*/
public static List<String> splitList(String str, String separator) {
return splitTo(str, separator, Convert::toStr);
}
/**
* 切分字符串自定义转换(分隔符默认逗号)
*
* @param str 被切分的字符串
* @param mapper 自定义转换
* @return 分割后的数据列表
*/
public static <T> List<T> splitTo(String str, Function<? super Object, T> mapper) {
return splitTo(str, SEPARATOR, mapper);
}
/**
* 切分字符串自定义转换
*
* @param str 被切分的字符串
* @param separator 分隔符
* @param mapper 自定义转换
* @return 分割后的数据列表
*/
public static <T> List<T> splitTo(String str, String separator, Function<? super Object, T> mapper) {
if (isBlank(str)) {
return new ArrayList<>(0);
}
return StrUtil.split(str, separator)
.stream()
.filter(Objects::nonNull)
.map(mapper)
.collect(Collectors.toList());
}
} }

View File

@ -270,7 +270,7 @@ public class ExcelUtil {
*/ */
public static String convertByExp(String propertyValue, String converterExp, String separator) { public static String convertByExp(String propertyValue, String converterExp, String separator) {
StringBuilder propertyString = new StringBuilder(); StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(","); String[] convertSource = converterExp.split(StringUtils.SEPARATOR);
for (String item : convertSource) { for (String item : convertSource) {
String[] itemArray = item.split("="); String[] itemArray = item.split("=");
if (StringUtils.containsAny(propertyValue, separator)) { if (StringUtils.containsAny(propertyValue, separator)) {
@ -299,7 +299,7 @@ public class ExcelUtil {
*/ */
public static String reverseByExp(String propertyValue, String converterExp, String separator) { public static String reverseByExp(String propertyValue, String converterExp, String separator) {
StringBuilder propertyString = new StringBuilder(); StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(","); String[] convertSource = converterExp.split(StringUtils.SEPARATOR);
for (String item : convertSource) { for (String item : convertSource) {
String[] itemArray = item.split("="); String[] itemArray = item.split("=");
if (StringUtils.containsAny(propertyValue, separator)) { if (StringUtils.containsAny(propertyValue, separator)) {

View File

@ -112,7 +112,7 @@ public class LogAspect {
// 是否需要保存request参数和值 // 是否需要保存request参数和值
if (log.isSaveRequestData()) { if (log.isSaveRequestData()) {
// 获取参数的信息传入到数据库中 // 获取参数的信息传入到数据库中
setRequestValue(joinPoint, operLog); setRequestValue(joinPoint, operLog, log.excludeParamNames());
} }
// 是否需要保存response参数和值 // 是否需要保存response参数和值
if (log.isSaveResponseData() && ObjectUtil.isNotNull(jsonResult)) { if (log.isSaveResponseData() && ObjectUtil.isNotNull(jsonResult)) {
@ -126,14 +126,16 @@ public class LogAspect {
* @param operLog 操作日志 * @param operLog 操作日志
* @throws Exception 异常 * @throws Exception 异常
*/ */
private void setRequestValue(JoinPoint joinPoint, OperLogEvent operLog) throws Exception { private void setRequestValue(JoinPoint joinPoint, OperLogEvent operLog, String[] excludeParamNames) throws Exception {
Map<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
String requestMethod = operLog.getRequestMethod(); String requestMethod = operLog.getRequestMethod();
if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) { if (MapUtil.isEmpty(paramsMap)
String params = argsArrayToString(joinPoint.getArgs()); && HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) {
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
operLog.setOperParam(StringUtils.substring(params, 0, 2000)); operLog.setOperParam(StringUtils.substring(params, 0, 2000));
} else { } else {
Map<String, String> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
MapUtil.removeAny(paramsMap, EXCLUDE_PROPERTIES); MapUtil.removeAny(paramsMap, EXCLUDE_PROPERTIES);
MapUtil.removeAny(paramsMap, excludeParamNames);
operLog.setOperParam(StringUtils.substring(JsonUtils.toJsonString(paramsMap), 0, 2000)); operLog.setOperParam(StringUtils.substring(JsonUtils.toJsonString(paramsMap), 0, 2000));
} }
} }
@ -141,7 +143,7 @@ public class LogAspect {
/** /**
* 参数拼装 * 参数拼装
*/ */
private String argsArrayToString(Object[] paramsArray) { private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames) {
StringBuilder params = new StringBuilder(); StringBuilder params = new StringBuilder();
if (paramsArray != null && paramsArray.length > 0) { if (paramsArray != null && paramsArray.length > 0) {
for (Object o : paramsArray) { for (Object o : paramsArray) {
@ -151,6 +153,7 @@ public class LogAspect {
Dict dict = JsonUtils.parseMap(str); Dict dict = JsonUtils.parseMap(str);
if (MapUtil.isNotEmpty(dict)) { if (MapUtil.isNotEmpty(dict)) {
MapUtil.removeAny(dict, EXCLUDE_PROPERTIES); MapUtil.removeAny(dict, EXCLUDE_PROPERTIES);
MapUtil.removeAny(dict, excludeParamNames);
str = JsonUtils.toJsonString(dict); str = JsonUtils.toJsonString(dict);
} }
params.append(str).append(" "); params.append(str).append(" ");

View File

@ -1,10 +1,13 @@
package com.ruoyi.framework.aspectj; package com.ruoyi.framework.aspectj;
import cn.hutool.core.util.ArrayUtil;
import com.ruoyi.common.annotation.RateLimiter; import com.ruoyi.common.annotation.RateLimiter;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.enums.LimitType; import com.ruoyi.common.enums.LimitType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.redis.RedisUtils; import com.ruoyi.common.utils.redis.RedisUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
@ -12,6 +15,14 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.redisson.api.RateType; import org.redisson.api.RateType;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParserContext;
import org.springframework.expression.common.TemplateParserContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -26,6 +37,23 @@ import java.lang.reflect.Method;
@Component @Component
public class RateLimiterAspect { public class RateLimiterAspect {
/**
* 定义spel表达式解析器
*/
private final ExpressionParser parser = new SpelExpressionParser();
/**
* 定义spel解析模版
*/
private final ParserContext parserContext = new TemplateParserContext();
/**
* 定义spel上下文对象进行解析
*/
private final EvaluationContext context = new StandardEvaluationContext();
/**
* 方法参数解析器
*/
private final ParameterNameDiscoverer pnd = new DefaultParameterNameDiscoverer();
@Before("@annotation(rateLimiter)") @Before("@annotation(rateLimiter)")
public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable { public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable {
int time = rateLimiter.time(); int time = rateLimiter.time();
@ -38,29 +66,56 @@ public class RateLimiterAspect {
} }
long number = RedisUtils.rateLimiter(combineKey, rateType, count, time); long number = RedisUtils.rateLimiter(combineKey, rateType, count, time);
if (number == -1) { if (number == -1) {
throw new ServiceException(MessageUtils.message("rate.limiter.message")); String message = rateLimiter.message();
if (StringUtils.startsWith(message, "{") && StringUtils.endsWith(message, "}")) {
message = MessageUtils.message(StringUtils.substring(message, 1, message.length() - 1));
}
throw new ServiceException(message);
} }
log.info("限制令牌 => {}, 剩余令牌 => {}, 缓存key => '{}'", count, number, combineKey); log.info("限制令牌 => {}, 剩余令牌 => {}, 缓存key => '{}'", count, number, combineKey);
} catch (ServiceException e) {
throw e;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("服务器限流异常,请稍候再试"); if (e instanceof ServiceException) {
throw e;
} else {
throw new RuntimeException("服务器限流异常,请稍候再试");
}
} }
} }
public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) { public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) {
StringBuilder stringBuffer = new StringBuilder(rateLimiter.key()); String key = rateLimiter.key();
if (rateLimiter.limitType() == LimitType.IP) { // 获取方法(通过方法签名来获取)
// 获取请求ip
stringBuffer.append(ServletUtils.getClientIP()).append("-");
} else if (rateLimiter.limitType() == LimitType.CLUSTER) {
// 获取客户端实例id
stringBuffer.append(RedisUtils.getClient().getId()).append("-");
}
MethodSignature signature = (MethodSignature) point.getSignature(); MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod(); Method method = signature.getMethod();
Class<?> targetClass = method.getDeclaringClass(); Class<?> targetClass = method.getDeclaringClass();
stringBuffer.append(targetClass.getName()).append("-").append(method.getName()); // 判断是否是spel格式
return stringBuffer.toString(); if (StringUtils.containsAny(key, "#")) {
// 获取参数值
Object[] args = point.getArgs();
// 获取方法上参数的名称
String[] parameterNames = pnd.getParameterNames(method);
if (ArrayUtil.isEmpty(parameterNames)) {
throw new ServiceException("限流key解析异常!请联系管理员!");
}
for (int i = 0; i < parameterNames.length; i++) {
context.setVariable(parameterNames[i], args[i]);
}
// 解析返回给key
try {
key = parser.parseExpression(key, parserContext).getValue(context, String.class) + ":";
} catch (Exception e) {
throw new ServiceException("限流key解析异常!请联系管理员!");
}
}
StringBuilder stringBuffer = new StringBuilder(CacheConstants.RATE_LIMIT_KEY);
stringBuffer.append(ServletUtils.getRequest().getRequestURI()).append(":");
if (rateLimiter.limitType() == LimitType.IP) {
// 获取请求ip
stringBuffer.append(ServletUtils.getClientIP()).append(":");
} else if (rateLimiter.limitType() == LimitType.CLUSTER) {
// 获取客户端实例id
stringBuffer.append(RedisUtils.getClient().getId()).append(":");
}
return stringBuffer.append(key).toString();
} }
} }

View File

@ -32,7 +32,7 @@ public class FilterConfig {
FilterRegistrationBean registration = new FilterRegistrationBean(); FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST); registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter()); registration.setFilter(new XssFilter());
registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), ",")); registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), StringUtils.SEPARATOR));
registration.setName("xssFilter"); registration.setName("xssFilter");
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE); registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
Map<String, String> initParameters = new HashMap<String, String>(); Map<String, String> initParameters = new HashMap<String, String>();

View File

@ -1,11 +1,17 @@
package com.ruoyi.framework.config; package com.ruoyi.framework.config;
import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.interceptor.SaInterceptor; import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.jwt.StpLogicJwtForSimple; import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.router.SaRouter; import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpLogic; import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.config.properties.SecurityProperties; import com.ruoyi.framework.config.properties.SecurityProperties;
import com.ruoyi.framework.handler.AllUrlHandler;
import com.ruoyi.framework.satoken.dao.PlusSaTokenDao;
import com.ruoyi.framework.satoken.service.SaPermissionImpl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -32,10 +38,11 @@ public class SaTokenConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
// 注册路由拦截器自定义验证规则 // 注册路由拦截器自定义验证规则
registry.addInterceptor(new SaInterceptor(handler -> { registry.addInterceptor(new SaInterceptor(handler -> {
AllUrlHandler allUrlHandler = SpringUtils.getBean(AllUrlHandler.class);
// 登录验证 -- 排除多个路径 // 登录验证 -- 排除多个路径
SaRouter SaRouter
// 获取所有的 // 获取所有的
.match("/**") .match(allUrlHandler.getUrls())
// 对未排除的路径进行检查 // 对未排除的路径进行检查
.check(() -> { .check(() -> {
// 检查是否登录 是否有token // 检查是否登录 是否有token
@ -59,4 +66,20 @@ public class SaTokenConfig implements WebMvcConfigurer {
return new StpLogicJwtForSimple(); return new StpLogicJwtForSimple();
} }
/**
* 权限接口实现(使用bean注入方便用户替换)
*/
@Bean
public StpInterface stpInterface() {
return new SaPermissionImpl();
}
/**
* 自定义dao层存储
*/
@Bean
public SaTokenDao saTokenDao() {
return new PlusSaTokenDao();
}
} }

View File

@ -33,7 +33,7 @@ import java.util.Set;
@RequiredArgsConstructor @RequiredArgsConstructor
@Configuration @Configuration
@AutoConfigureBefore(SpringDocConfiguration.class) @AutoConfigureBefore(SpringDocConfiguration.class)
@ConditionalOnProperty(name = "swagger.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true)
public class SwaggerConfig { public class SwaggerConfig {
private final SwaggerProperties swaggerProperties; private final SwaggerProperties swaggerProperties;

View File

@ -0,0 +1,50 @@
package com.ruoyi.framework.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.translation.TranslationInterface;
import com.ruoyi.common.translation.handler.TranslationBeanSerializerModifier;
import com.ruoyi.common.translation.handler.TranslationHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 翻译模块配置类
*
* @author Lion Li
*/
@Slf4j
@Configuration
public class TranslationConfig {
@Autowired
private List<TranslationInterface<?>> list;
@Autowired
private ObjectMapper objectMapper;
@PostConstruct
public void init() {
Map<String, TranslationInterface<?>> map = new HashMap<>(list.size());
for (TranslationInterface<?> trans : list) {
if (trans.getClass().isAnnotationPresent(TranslationType.class)) {
TranslationType annotation = trans.getClass().getAnnotation(TranslationType.class);
map.put(annotation.type(), trans);
} else {
log.warn(trans.getClass().getName() + " 翻译实现类未标注 TranslationType 注解!");
}
}
TranslationHandler.TRANSLATION_MAPPER.putAll(map);
// 设置 Bean 序列化修改器
objectMapper.setSerializerFactory(
objectMapper.getSerializerFactory()
.withSerializerModifier(new TranslationBeanSerializerModifier()));
}
}

View File

@ -23,11 +23,6 @@ import java.util.List;
@ConfigurationProperties(prefix = "swagger") @ConfigurationProperties(prefix = "swagger")
public class SwaggerProperties { public class SwaggerProperties {
/**
* 是否开启 openApi 文档
*/
private Boolean enabled = true;
/** /**
* 文档基本信息 * 文档基本信息
*/ */

View File

@ -55,11 +55,11 @@ public class MybatisDecryptInterceptor implements Interceptor {
* @param sourceObject 待加密对象 * @param sourceObject 待加密对象
*/ */
private void decryptHandler(Object sourceObject) { private void decryptHandler(Object sourceObject) {
if (sourceObject instanceof Map) { if (sourceObject instanceof Map<?, ?>) {
((Map<?, Object>) sourceObject).values().forEach(this::decryptHandler); ((Map<?, ?>) sourceObject).values().forEach(this::decryptHandler);
return; return;
} }
if (sourceObject instanceof List) { if (sourceObject instanceof List<?>) {
// 判断第一个元素是否含有注解如果没有直接返回提高效率 // 判断第一个元素是否含有注解如果没有直接返回提高效率
Object firstItem = ((List<?>) sourceObject).get(0); Object firstItem = ((List<?>) sourceObject).get(0);
if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) { if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {

View File

@ -65,13 +65,12 @@ public class MybatisEncryptInterceptor implements Interceptor {
* *
* @param sourceObject 待加密对象 * @param sourceObject 待加密对象
*/ */
@SuppressWarnings("unchecked cast")
private void encryptHandler(Object sourceObject) { private void encryptHandler(Object sourceObject) {
if (sourceObject instanceof Map) { if (sourceObject instanceof Map<?, ?>) {
((Map<?, Object>) sourceObject).values().forEach(this::encryptHandler); ((Map<?, ?>) sourceObject).values().forEach(this::encryptHandler);
return; return;
} }
if (sourceObject instanceof List) { if (sourceObject instanceof List<?>) {
// 判断第一个元素是否含有注解如果没有直接返回提高效率 // 判断第一个元素是否含有注解如果没有直接返回提高效率
Object firstItem = ((List<?>) sourceObject).get(0); Object firstItem = ((List<?>) sourceObject).get(0);
if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) { if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {

View File

@ -0,0 +1,41 @@
package com.ruoyi.framework.handler;
import cn.hutool.core.util.ReUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import java.util.*;
import java.util.regex.Pattern;
/**
* 获取所有Url配置
*
* @author Lion Li
*/
@Data
@Component
public class AllUrlHandler implements InitializingBean {
private static final Pattern PATTERN = Pattern.compile("\\{(.*?)\\}");
private List<String> urls = new ArrayList<>();
@Override
public void afterPropertiesSet() {
Set<String> set = new HashSet<>();
RequestMappingHandlerMapping mapping = SpringUtils.getBean("requestMappingHandlerMapping", RequestMappingHandlerMapping.class);
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
map.keySet().forEach(info -> {
// 获取注解上边的 path 替代 path variable *
Objects.requireNonNull(info.getPathPatternsCondition().getPatterns())
.forEach(url -> set.add(ReUtil.replaceAll(url.getPatternString(), PATTERN, "*")));
});
urls.addAll(set);
}
}

View File

@ -3,7 +3,6 @@ package com.ruoyi.framework.satoken.dao;
import cn.dev33.satoken.dao.SaTokenDao; import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.util.SaFoxUtil; import cn.dev33.satoken.util.SaFoxUtil;
import com.ruoyi.common.utils.redis.RedisUtils; import com.ruoyi.common.utils.redis.RedisUtils;
import org.springframework.stereotype.Component;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
@ -15,7 +14,6 @@ import java.util.List;
* *
* @author Lion Li * @author Lion Li
*/ */
@Component
public class PlusSaTokenDao implements SaTokenDao { public class PlusSaTokenDao implements SaTokenDao {
/** /**

View File

@ -4,7 +4,6 @@ import cn.dev33.satoken.stp.StpInterface;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.UserType; import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.helper.LoginHelper;
import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -14,7 +13,6 @@ import java.util.List;
* *
* @author Lion Li * @author Lion Li
*/ */
@Component
public class SaPermissionImpl implements StpInterface { public class SaPermissionImpl implements StpInterface {
/** /**

View File

@ -212,7 +212,7 @@ public class GenTableColumn extends BaseEntity {
if (StringUtils.isNotEmpty(value)) { if (StringUtils.isNotEmpty(value)) {
Object startStr = value.subSequence(0, 1); Object startStr = value.subSequence(0, 1);
String endStr = value.substring(1); String endStr = value.substring(1);
sb.append("").append(startStr).append("=").append(endStr).append(","); sb.append(StringUtils.EMPTY).append(startStr).append("=").append(endStr).append(StringUtils.SEPARATOR);
} }
} }
return sb.deleteCharAt(sb.length() - 1).toString(); return sb.deleteCharAt(sb.length() - 1).toString();

View File

@ -58,7 +58,7 @@ public class GenUtils {
column.setHtmlType(GenConstants.HTML_INPUT); column.setHtmlType(GenConstants.HTML_INPUT);
// 如果是浮点型 统一用BigDecimal // 如果是浮点型 统一用BigDecimal
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ","); String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), StringUtils.SEPARATOR);
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) { if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
column.setJavaType(GenConstants.TYPE_BIGDECIMAL); column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
} }
@ -167,7 +167,7 @@ public class GenUtils {
boolean autoRemovePre = GenConfig.getAutoRemovePre(); boolean autoRemovePre = GenConfig.getAutoRemovePre();
String tablePrefix = GenConfig.getTablePrefix(); String tablePrefix = GenConfig.getTablePrefix();
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) { if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
String[] searchList = StringUtils.split(tablePrefix, ","); String[] searchList = StringUtils.split(tablePrefix, StringUtils.SEPARATOR);
tableName = replaceFirst(tableName, searchList); tableName = replaceFirst(tableName, searchList);
} }
return StringUtils.convertToCamelCase(tableName); return StringUtils.convertToCamelCase(tableName);
@ -184,7 +184,7 @@ public class GenUtils {
String text = replacementm; String text = replacementm;
for (String searchString : searchList) { for (String searchString : searchList) {
if (replacementm.startsWith(searchString)) { if (replacementm.startsWith(searchString)) {
text = replacementm.replaceFirst(searchString, ""); text = replacementm.replaceFirst(searchString, StringUtils.EMPTY);
break; break;
} }
} }

View File

@ -232,7 +232,7 @@ public class VelocityUtils {
public static HashSet<String> getImportList(GenTable genTable) { public static HashSet<String> getImportList(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns(); List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable(); GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>(); HashSet<String> importList = new HashSet<>();
if (ObjectUtil.isNotNull(subGenTable)) { if (ObjectUtil.isNotNull(subGenTable)) {
importList.add("java.util.List"); importList.add("java.util.List");
} }

View File

@ -540,7 +540,7 @@ function submitForm() {
/** 删除按钮操作 */ /** 删除按钮操作 */
function handleDelete(row) { function handleDelete(row) {
const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value; const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?').then(function() { proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
loading.value = true; loading.value = true;
return del${BusinessName}(_${pkColumn.javaField}s); return del${BusinessName}(_${pkColumn.javaField}s);
}).then(() => { }).then(() => {

View File

@ -183,6 +183,12 @@ public class OssClient {
return configKey; return configKey;
} }
/**
* 获取私有URL链接
*
* @param objectKey 对象KEY
* @param second 授权时间
*/
public String getPrivateUrl(String objectKey, Integer second) { public String getPrivateUrl(String objectKey, Integer second) {
GeneratePresignedUrlRequest generatePresignedUrlRequest = GeneratePresignedUrlRequest generatePresignedUrlRequest =
new GeneratePresignedUrlRequest(properties.getBucketName(), objectKey) new GeneratePresignedUrlRequest(properties.getBucketName(), objectKey)
@ -192,6 +198,13 @@ public class OssClient {
return url.toString(); return url.toString();
} }
/**
* 检查配置是否相同
*/
public boolean checkPropertiesSame(OssProperties properties) {
return this.properties.equals(properties);
}
/** /**
* 获取当前桶权限类型 * 获取当前桶权限类型
* *

View File

@ -24,21 +24,6 @@ public class OssFactory {
private static final Map<String, OssClient> CLIENT_CACHE = new ConcurrentHashMap<>(); private static final Map<String, OssClient> CLIENT_CACHE = new ConcurrentHashMap<>();
/**
* 初始化工厂
*/
public static void init() {
log.info("初始化OSS工厂");
RedisUtils.subscribe(OssConstant.DEFAULT_CONFIG_KEY, String.class, configKey -> {
OssClient client = getClient(configKey);
// 未初始化不处理
if (client != null) {
refresh(configKey);
log.info("订阅刷新OSS配置 => " + configKey);
}
});
}
/** /**
* 获取默认实例 * 获取默认实例
*/ */
@ -55,25 +40,24 @@ public class OssFactory {
* 根据类型获取实例 * 根据类型获取实例
*/ */
public static OssClient instance(String configKey) { public static OssClient instance(String configKey) {
OssClient client = getClient(configKey);
if (client == null) {
refresh(configKey);
return getClient(configKey);
}
return client;
}
private static void refresh(String configKey) {
String json = CacheUtils.get(CacheNames.SYS_OSS_CONFIG, configKey); String json = CacheUtils.get(CacheNames.SYS_OSS_CONFIG, configKey);
if (json == null) { if (json == null) {
throw new OssException("系统异常, '" + configKey + "'配置信息不存在!"); throw new OssException("系统异常, '" + configKey + "'配置信息不存在!");
} }
OssProperties properties = JsonUtils.parseObject(json, OssProperties.class); OssProperties properties = JsonUtils.parseObject(json, OssProperties.class);
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties)); OssClient client = CLIENT_CACHE.get(configKey);
} if (client == null) {
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties));
private static OssClient getClient(String configKey) { log.info("创建OSS实例 key => {}", configKey);
return CLIENT_CACHE.get(configKey); return CLIENT_CACHE.get(configKey);
}
// 配置不相同则重新构建
if (!client.checkPropertiesSame(properties)) {
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties));
log.info("重载OSS实例 key => {}", configKey);
return CLIENT_CACHE.get(configKey);
}
return client;
} }
} }

View File

@ -53,7 +53,7 @@ public class TencentSmsTemplate implements SmsTemplate {
throw new SmsException("模板ID不能为空"); throw new SmsException("模板ID不能为空");
} }
SendSmsRequest req = new SendSmsRequest(); SendSmsRequest req = new SendSmsRequest();
Set<String> set = Arrays.stream(phones.split(",")).map(p -> "+86" + p).collect(Collectors.toSet()); Set<String> set = Arrays.stream(phones.split(StringUtils.SEPARATOR)).map(p -> "+86" + p).collect(Collectors.toSet());
req.setPhoneNumberSet(ArrayUtil.toArray(set, String.class)); req.setPhoneNumberSet(ArrayUtil.toArray(set, String.class));
if (CollUtil.isNotEmpty(param)) { if (CollUtil.isNotEmpty(param)) {
req.setTemplateParamSet(ArrayUtil.toArray(param.values(), String.class)); req.setTemplateParamSet(ArrayUtil.toArray(param.values(), String.class));

View File

@ -13,22 +13,31 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class SysOssBo extends BaseEntity { public class SysOssBo extends BaseEntity {
/**
* ossId
*/
private Long ossId;
/** /**
* 文件名 * 文件名
*/ */
private String fileName; private String fileName;
/** /**
* 原名 * 原名
*/ */
private String originalName; private String originalName;
/** /**
* 文件后缀名 * 文件后缀名
*/ */
private String fileSuffix; private String fileSuffix;
/** /**
* URL地址 * URL地址
*/ */
private String url; private String url;
/** /**
* 服务商 * 服务商
*/ */

View File

@ -91,6 +91,6 @@ public interface ISysConfigService {
* @param config 参数信息 * @param config 参数信息
* @return 结果 * @return 结果
*/ */
String checkConfigKeyUnique(SysConfig config); boolean checkConfigKeyUnique(SysConfig config);
} }

View File

@ -81,7 +81,7 @@ public interface ISysDeptService {
* @param dept 部门信息 * @param dept 部门信息
* @return 结果 * @return 结果
*/ */
String checkDeptNameUnique(SysDept dept); boolean checkDeptNameUnique(SysDept dept);
/** /**
* 校验部门是否有数据权限 * 校验部门是否有数据权限

View File

@ -100,5 +100,5 @@ public interface ISysDictTypeService {
* @param dictType 字典类型 * @param dictType 字典类型
* @return 结果 * @return 结果
*/ */
String checkDictTypeUnique(SysDictType dictType); boolean checkDictTypeUnique(SysDictType dictType);
} }

View File

@ -133,5 +133,5 @@ public interface ISysMenuService {
* @param menu 菜单信息 * @param menu 菜单信息
* @return 结果 * @return 结果
*/ */
String checkMenuNameUnique(SysMenu menu); boolean checkMenuNameUnique(SysMenu menu);
} }

View File

@ -53,7 +53,7 @@ public interface ISysPostService {
* @param post 岗位信息 * @param post 岗位信息
* @return 结果 * @return 结果
*/ */
String checkPostNameUnique(SysPost post); boolean checkPostNameUnique(SysPost post);
/** /**
* 校验岗位编码 * 校验岗位编码
@ -61,7 +61,7 @@ public interface ISysPostService {
* @param post 岗位信息 * @param post 岗位信息
* @return 结果 * @return 结果
*/ */
String checkPostCodeUnique(SysPost post); boolean checkPostCodeUnique(SysPost post);
/** /**
* 通过岗位ID查询岗位使用数量 * 通过岗位ID查询岗位使用数量

View File

@ -71,7 +71,7 @@ public interface ISysRoleService {
* @param role 角色信息 * @param role 角色信息
* @return 结果 * @return 结果
*/ */
String checkRoleNameUnique(SysRole role); boolean checkRoleNameUnique(SysRole role);
/** /**
* 校验角色权限是否唯一 * 校验角色权限是否唯一
@ -79,7 +79,7 @@ public interface ISysRoleService {
* @param role 角色信息 * @param role 角色信息
* @return 结果 * @return 结果
*/ */
String checkRoleKeyUnique(SysRole role); boolean checkRoleKeyUnique(SysRole role);
/** /**
* 校验角色是否允许操作 * 校验角色是否允许操作

View File

@ -86,7 +86,7 @@ public interface ISysUserService {
* @param user 用户信息 * @param user 用户信息
* @return 结果 * @return 结果
*/ */
String checkUserNameUnique(SysUser user); boolean checkUserNameUnique(SysUser user);
/** /**
* 校验手机号码是否唯一 * 校验手机号码是否唯一
@ -94,7 +94,7 @@ public interface ISysUserService {
* @param user 用户信息 * @param user 用户信息
* @return 结果 * @return 结果
*/ */
String checkPhoneUnique(SysUser user); boolean checkPhoneUnique(SysUser user);
/** /**
* 校验email是否唯一 * 校验email是否唯一
@ -102,7 +102,7 @@ public interface ISysUserService {
* @param user 用户信息 * @param user 用户信息
* @return 结果 * @return 结果
*/ */
String checkEmailUnique(SysUser user); boolean checkEmailUnique(SysUser user);
/** /**
* 校验用户是否允许操作 * 校验用户是否允许操作

View File

@ -1,12 +1,10 @@
package com.ruoyi.system.service; package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -28,7 +26,7 @@ public class SysPermissionService {
* @return 角色权限信息 * @return 角色权限信息
*/ */
public Set<String> getRolePermission(SysUser user) { public Set<String> getRolePermission(SysUser user) {
Set<String> roles = new HashSet<String>(); Set<String> roles = new HashSet<>();
// 管理员拥有所有权限 // 管理员拥有所有权限
if (user.isAdmin()) { if (user.isAdmin()) {
roles.add("admin"); roles.add("admin");
@ -45,22 +43,12 @@ public class SysPermissionService {
* @return 菜单权限信息 * @return 菜单权限信息
*/ */
public Set<String> getMenuPermission(SysUser user) { public Set<String> getMenuPermission(SysUser user) {
Set<String> perms = new HashSet<String>(); Set<String> perms = new HashSet<>();
// 管理员拥有所有权限 // 管理员拥有所有权限
if (user.isAdmin()) { if (user.isAdmin()) {
perms.add("*:*:*"); perms.add("*:*:*");
} else { } else {
List<SysRole> roles = user.getRoles(); perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
if (!roles.isEmpty() && roles.size() > 1) {
// 多角色设置permissions属性以便数据权限匹配权限
for (SysRole role : roles) {
Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
role.setPermissions(rolePerms);
perms.addAll(rolePerms);
}
} else {
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
}
} }
return perms; return perms;
} }

View File

@ -54,7 +54,7 @@ public class SysRegisterService {
sysUser.setPassword(BCrypt.hashpw(password)); sysUser.setPassword(BCrypt.hashpw(password));
sysUser.setUserType(userType); sysUser.setUserType(userType);
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(sysUser))) { if (!userService.checkUserNameUnique(sysUser)) {
throw new UserException("user.register.save.error", username); throw new UserException("user.register.save.error", username);
} }
boolean regFlag = userService.registerUser(sysUser); boolean regFlag = userService.registerUser(sysUser);

View File

@ -204,13 +204,13 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkConfigKeyUnique(SysConfig config) { public boolean checkConfigKeyUnique(SysConfig config) {
Long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId(); long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey())); SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey()));
if (ObjectUtil.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { if (ObjectUtil.isNotNull(info) && info.getConfigId() != configId) {
return UserConstants.NOT_UNIQUE; return false;
} }
return UserConstants.UNIQUE; return true;
} }
/** /**

View File

@ -6,20 +6,26 @@ import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ruoyi.common.constant.CacheNames;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.service.DeptService;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.helper.DataBaseHelper; import com.ruoyi.common.helper.DataBaseHelper;
import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.TreeBuildUtils; import com.ruoyi.common.utils.TreeBuildUtils;
import com.ruoyi.common.utils.redis.CacheUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,7 +39,7 @@ import java.util.List;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class SysDeptServiceImpl implements ISysDeptService { public class SysDeptServiceImpl implements ISysDeptService, DeptService {
private final SysDeptMapper baseMapper; private final SysDeptMapper baseMapper;
private final SysRoleMapper roleMapper; private final SysRoleMapper roleMapper;
@ -106,15 +112,37 @@ public class SysDeptServiceImpl implements ISysDeptService {
* @param deptId 部门ID * @param deptId 部门ID
* @return 部门信息 * @return 部门信息
*/ */
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override @Override
public SysDept selectDeptById(Long deptId) { public SysDept selectDeptById(Long deptId) {
SysDept dept = baseMapper.selectById(deptId); SysDept dept = baseMapper.selectById(deptId);
if (ObjectUtil.isNull(dept)) {
return null;
}
SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>() SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId())); .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null); dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
return dept; return dept;
} }
/**
* 通过部门ID查询部门名称
*
* @param deptIds 部门ID串逗号分隔
* @return 部门名称串逗号分隔
*/
@Override
public String selectDeptNameByIds(String deptIds) {
List<String> list = new ArrayList<>();
for (Long id : StringUtils.splitTo(deptIds, Convert::toLong)) {
SysDept dept = SpringUtils.getAopProxy(this).selectDeptById(id);
if (ObjectUtil.isNotNull(dept)) {
list.add(dept.getDeptName());
}
}
return String.join(StringUtils.SEPARATOR, list);
}
/** /**
* 根据ID查询所有子部门数正常状态 * 根据ID查询所有子部门数正常状态
* *
@ -159,15 +187,12 @@ public class SysDeptServiceImpl implements ISysDeptService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkDeptNameUnique(SysDept dept) { public boolean checkDeptNameUnique(SysDept dept) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getDeptName, dept.getDeptName()) .eq(SysDept::getDeptName, dept.getDeptName())
.eq(SysDept::getParentId, dept.getParentId()) .eq(SysDept::getParentId, dept.getParentId())
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId())); .ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
@ -200,7 +225,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增"); throw new ServiceException("部门停用,不允许新增");
} }
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
return baseMapper.insert(dept); return baseMapper.insert(dept);
} }
@ -210,12 +235,13 @@ public class SysDeptServiceImpl implements ISysDeptService {
* @param dept 部门信息 * @param dept 部门信息
* @return 结果 * @return 结果
*/ */
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#dept.deptId")
@Override @Override
public int updateDept(SysDept dept) { public int updateDept(SysDept dept) {
SysDept newParentDept = baseMapper.selectById(dept.getParentId()); SysDept newParentDept = baseMapper.selectById(dept.getParentId());
SysDept oldDept = baseMapper.selectById(dept.getDeptId()); SysDept oldDept = baseMapper.selectById(dept.getDeptId());
if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) { if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String newAncestors = newParentDept.getAncestors() + StringUtils.SEPARATOR + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors(); String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors); dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
@ -259,8 +285,10 @@ public class SysDeptServiceImpl implements ISysDeptService {
dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
list.add(dept); list.add(dept);
} }
if (list.size() > 0) { if (CollUtil.isNotEmpty(list)) {
baseMapper.updateBatchById(list); if (baseMapper.updateBatchById(list)) {
list.forEach(dept -> CacheUtils.evict(CacheNames.SYS_DEPT, dept.getDeptId()));
}
} }
} }
@ -270,6 +298,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
* @param deptId 部门ID * @param deptId 部门ID
* @return 结果 * @return 结果
*/ */
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override @Override
public int deleteDeptById(Long deptId) { public int deleteDeptById(Long deptId) {
return baseMapper.deleteById(deptId); return baseMapper.deleteById(deptId);

View File

@ -216,14 +216,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkDictTypeUnique(SysDictType dict) { public boolean checkDictTypeUnique(SysDictType dict) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>()
.eq(SysDictType::getDictType, dict.getDictType()) .eq(SysDictType::getDictType, dict.getDictType())
.ne(ObjectUtil.isNotNull(dict.getDictId()), SysDictType::getDictId, dict.getDictId())); .ne(ObjectUtil.isNotNull(dict.getDictId()), SysDictType::getDictId, dict.getDictId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**

View File

@ -92,7 +92,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
for (String perm : perms) { for (String perm : perms) {
if (StringUtils.isNotEmpty(perm)) { if (StringUtils.isNotEmpty(perm)) {
permsSet.addAll(Arrays.asList(perm.trim().split(","))); permsSet.addAll(StringUtils.splitList(perm.trim()));
} }
} }
return permsSet; return permsSet;
@ -110,7 +110,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
for (String perm : perms) { for (String perm : perms) {
if (StringUtils.isNotEmpty(perm)) { if (StringUtils.isNotEmpty(perm)) {
permsSet.addAll(Arrays.asList(perm.trim().split(","))); permsSet.addAll(StringUtils.splitList(perm.trim()));
} }
} }
return permsSet; return permsSet;
@ -153,7 +153,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
*/ */
@Override @Override
public List<RouterVo> buildMenus(List<SysMenu> menus) { public List<RouterVo> buildMenus(List<SysMenu> menus) {
List<RouterVo> routers = new LinkedList<RouterVo>(); List<RouterVo> routers = new LinkedList<>();
for (SysMenu menu : menus) { for (SysMenu menu : menus) {
RouterVo router = new RouterVo(); RouterVo router = new RouterVo();
router.setHidden("1".equals(menu.getVisible())); router.setHidden("1".equals(menu.getVisible()));
@ -163,13 +163,13 @@ public class SysMenuServiceImpl implements ISysMenuService {
router.setQuery(menu.getQueryParam()); router.setQuery(menu.getQueryParam());
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
List<SysMenu> cMenus = menu.getChildren(); List<SysMenu> cMenus = menu.getChildren();
if (!cMenus.isEmpty() && UserConstants.TYPE_DIR.equals(menu.getMenuType())) { if (CollUtil.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
router.setAlwaysShow(true); router.setAlwaysShow(true);
router.setRedirect("noRedirect"); router.setRedirect("noRedirect");
router.setChildren(buildMenus(cMenus)); router.setChildren(buildMenus(cMenus));
} else if (isMenuFrame(menu)) { } else if (isMenuFrame(menu)) {
router.setMeta(null); router.setMeta(null);
List<RouterVo> childrenList = new ArrayList<RouterVo>(); List<RouterVo> childrenList = new ArrayList<>();
RouterVo children = new RouterVo(); RouterVo children = new RouterVo();
children.setPath(menu.getPath()); children.setPath(menu.getPath());
children.setComponent(menu.getComponent()); children.setComponent(menu.getComponent());
@ -181,7 +181,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
} else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) { } else if (menu.getParentId().intValue() == 0 && isInnerLink(menu)) {
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
router.setPath("/"); router.setPath("/");
List<RouterVo> childrenList = new ArrayList<RouterVo>(); List<RouterVo> childrenList = new ArrayList<>();
RouterVo children = new RouterVo(); RouterVo children = new RouterVo();
String routerPath = innerLinkReplaceEach(menu.getPath()); String routerPath = innerLinkReplaceEach(menu.getPath());
children.setPath(routerPath); children.setPath(routerPath);
@ -287,15 +287,12 @@ public class SysMenuServiceImpl implements ISysMenuService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkMenuNameUnique(SysMenu menu) { public boolean checkMenuNameUnique(SysMenu menu) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
.eq(SysMenu::getMenuName, menu.getMenuName()) .eq(SysMenu::getMenuName, menu.getMenuName())
.eq(SysMenu::getParentId, menu.getParentId()) .eq(SysMenu::getParentId, menu.getParentId())
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId())); .ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
@ -394,7 +391,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
* @return String * @return String
*/ */
public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) { public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) {
List<SysMenu> returnList = new ArrayList<SysMenu>(); List<SysMenu> returnList = new ArrayList<>();
for (SysMenu t : list) { for (SysMenu t : list) {
// 根据传入的某个父节点ID,遍历该父节点的所有子节点 // 根据传入的某个父节点ID,遍历该父节点的所有子节点
if (t.getParentId() == parentId) { if (t.getParentId() == parentId) {
@ -433,7 +430,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
* 判断是否有子节点 * 判断是否有子节点
*/ */
private boolean hasChild(List<SysMenu> list, SysMenu t) { private boolean hasChild(List<SysMenu> list, SysMenu t) {
return getChildList(list, t).size() > 0; return CollUtil.isNotEmpty(getChildList(list, t));
} }
/** /**

View File

@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.CacheNames; import com.ruoyi.common.constant.CacheNames;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
@ -16,9 +15,7 @@ import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.redis.CacheUtils; import com.ruoyi.common.utils.redis.CacheUtils;
import com.ruoyi.common.utils.redis.RedisUtils; import com.ruoyi.common.utils.redis.RedisUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.oss.constant.OssConstant; import com.ruoyi.oss.constant.OssConstant;
import com.ruoyi.oss.factory.OssFactory;
import com.ruoyi.system.domain.SysOssConfig; import com.ruoyi.system.domain.SysOssConfig;
import com.ruoyi.system.domain.bo.SysOssConfigBo; import com.ruoyi.system.domain.bo.SysOssConfigBo;
import com.ruoyi.system.domain.vo.SysOssConfigVo; import com.ruoyi.system.domain.vo.SysOssConfigVo;
@ -26,7 +23,6 @@ import com.ruoyi.system.mapper.SysOssConfigMapper;
import com.ruoyi.system.service.ISysOssConfigService; import com.ruoyi.system.service.ISysOssConfigService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -59,10 +55,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
if ("0".equals(config.getStatus())) { if ("0".equals(config.getStatus())) {
RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, configKey); RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, configKey);
} }
SpringUtils.context().publishEvent(config); CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
} }
// 初始化OSS工厂
OssFactory.init();
} }
@Override @Override
@ -92,7 +86,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
validEntityBeforeSave(config); validEntityBeforeSave(config);
boolean flag = baseMapper.insert(config) > 0; boolean flag = baseMapper.insert(config) > 0;
if (flag) { if (flag) {
SpringUtils.context().publishEvent(config); CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
} }
return flag; return flag;
} }
@ -109,7 +103,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId()); luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
boolean flag = baseMapper.update(config, luw) > 0; boolean flag = baseMapper.update(config, luw) > 0;
if (flag) { if (flag) {
SpringUtils.context().publishEvent(config); CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
} }
return flag; return flag;
} }
@ -118,8 +112,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
* 保存前的数据校验 * 保存前的数据校验
*/ */
private void validEntityBeforeSave(SysOssConfig entity) { private void validEntityBeforeSave(SysOssConfig entity) {
if (StringUtils.isNotEmpty(entity.getConfigKey()) if (StringUtils.isNotEmpty(entity.getConfigKey()) && !checkConfigKeyUnique(entity)) {
&& UserConstants.NOT_UNIQUE.equals(checkConfigKeyUnique(entity))) {
throw new ServiceException("操作配置'" + entity.getConfigKey() + "'失败, 配置key已存在!"); throw new ServiceException("操作配置'" + entity.getConfigKey() + "'失败, 配置key已存在!");
} }
} }
@ -147,15 +140,15 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
/** /**
* 判断configKey是否唯一 * 判断configKey是否唯一
*/ */
private String checkConfigKeyUnique(SysOssConfig sysOssConfig) { private boolean checkConfigKeyUnique(SysOssConfig sysOssConfig) {
long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId(); long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>() SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey) .select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey())); .eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) { if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
return UserConstants.NOT_UNIQUE; return false;
} }
return UserConstants.UNIQUE; return true;
} }
/** /**
@ -174,16 +167,4 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
return row; return row;
} }
/**
* 更新配置缓存
*
* @param config 配置
*/
@EventListener
public void updateConfigCache(SysOssConfig config) {
CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
RedisUtils.publish(OssConstant.DEFAULT_CONFIG_KEY, config.getConfigKey(), msg -> {
log.info("发布刷新OSS配置 => " + msg);
});
}
} }

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.CacheNames; import com.ruoyi.common.constant.CacheNames;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.service.OssService;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.BeanCopyUtils; import com.ruoyi.common.utils.BeanCopyUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
@ -31,10 +33,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -44,7 +43,7 @@ import java.util.stream.Collectors;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class SysOssServiceImpl implements ISysOssService { public class SysOssServiceImpl implements ISysOssService, OssService {
private final SysOssMapper baseMapper; private final SysOssMapper baseMapper;
@ -69,6 +68,18 @@ public class SysOssServiceImpl implements ISysOssService {
return list; return list;
} }
@Override
public String selectUrlByIds(String ossIds) {
List<String> list = new ArrayList<>();
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
if (ObjectUtil.isNotNull(vo)) {
list.add(this.matchingUrl(vo).getUrl());
}
}
return String.join(StringUtils.SEPARATOR, list);
}
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) { private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
Map<String, Object> params = bo.getParams(); Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery();

View File

@ -3,7 +3,6 @@ package com.ruoyi.system.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
@ -94,14 +93,11 @@ public class SysPostServiceImpl implements ISysPostService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkPostNameUnique(SysPost post) { public boolean checkPostNameUnique(SysPost post) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
.eq(SysPost::getPostName, post.getPostName()) .eq(SysPost::getPostName, post.getPostName())
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId())); .ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
@ -111,14 +107,11 @@ public class SysPostServiceImpl implements ISysPostService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkPostCodeUnique(SysPost post) { public boolean checkPostCodeUnique(SysPost post) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
.eq(SysPost::getPostCode, post.getPostCode()) .eq(SysPost::getPostCode, post.getPostCode())
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId())); .ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**

View File

@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
@ -14,6 +13,8 @@ import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StreamUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleDept;
import com.ruoyi.system.domain.SysRoleMenu; import com.ruoyi.system.domain.SysRoleMenu;
import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.domain.SysUserRole;
@ -106,7 +107,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
Set<String> permsSet = new HashSet<>(); Set<String> permsSet = new HashSet<>();
for (SysRole perm : perms) { for (SysRole perm : perms) {
if (ObjectUtil.isNotNull(perm)) { if (ObjectUtil.isNotNull(perm)) {
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); permsSet.addAll(StringUtils.splitList(perm.getRoleKey().trim()));
} }
} }
return permsSet; return permsSet;
@ -151,14 +152,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkRoleNameUnique(SysRole role) { public boolean checkRoleNameUnique(SysRole role) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
.eq(SysRole::getRoleName, role.getRoleName()) .eq(SysRole::getRoleName, role.getRoleName())
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId())); .ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
@ -168,14 +166,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkRoleKeyUnique(SysRole role) { public boolean checkRoleKeyUnique(SysRole role) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
.eq(SysRole::getRoleKey, role.getRoleKey()) .eq(SysRole::getRoleKey, role.getRoleKey())
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId())); .ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
@ -397,14 +392,13 @@ public class SysRoleServiceImpl implements ISysRoleService {
public int insertAuthUsers(Long roleId, Long[] userIds) { public int insertAuthUsers(Long roleId, Long[] userIds) {
// 新增用户与角色管理 // 新增用户与角色管理
int rows = 1; int rows = 1;
List<SysUserRole> list = new ArrayList<SysUserRole>(); List<SysUserRole> list = StreamUtils.toList(Arrays.asList(userIds), userId -> {
for (Long userId : userIds) {
SysUserRole ur = new SysUserRole(); SysUserRole ur = new SysUserRole();
ur.setUserId(userId); ur.setUserId(userId);
ur.setRoleId(roleId); ur.setRoleId(roleId);
list.add(ur); return ur;
} });
if (list.size() > 0) { if (CollUtil.isNotEmpty(list)) {
rows = userRoleMapper.insertBatch(list) ? list.size() : 0; rows = userRoleMapper.insertBatch(list) ? list.size() : 0;
} }
return rows; return rows;

View File

@ -9,12 +9,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.constant.CacheNames;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.service.UserService;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.helper.DataBaseHelper; import com.ruoyi.common.helper.DataBaseHelper;
import com.ruoyi.common.helper.LoginHelper; import com.ruoyi.common.helper.LoginHelper;
@ -27,10 +29,10 @@ import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -43,7 +45,7 @@ import java.util.Map;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class SysUserServiceImpl implements ISysUserService { public class SysUserServiceImpl implements ISysUserService, UserService {
private final SysUserMapper baseMapper; private final SysUserMapper baseMapper;
private final SysDeptMapper deptMapper; private final SysDeptMapper deptMapper;
@ -197,48 +199,37 @@ public class SysUserServiceImpl implements ISysUserService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public String checkUserNameUnique(SysUser user) { public boolean checkUserNameUnique(SysUser user) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getUserName, user.getUserName()) .eq(SysUser::getUserName, user.getUserName())
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
* 校验手机号码是否唯一 * 校验手机号码是否唯一
* *
* @param user 用户信息 * @param user 用户信息
* @return
*/ */
@Override @Override
public String checkPhoneUnique(SysUser user) { public boolean checkPhoneUnique(SysUser user) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getPhonenumber, user.getPhonenumber()) .eq(SysUser::getPhonenumber, user.getPhonenumber())
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
* 校验email是否唯一 * 校验email是否唯一
* *
* @param user 用户信息 * @param user 用户信息
* @return
*/ */
@Override @Override
public String checkEmailUnique(SysUser user) { public boolean checkEmailUnique(SysUser user) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getEmail, user.getEmail()) .eq(SysUser::getEmail, user.getEmail())
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId())); .ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
if (exist) { return !exist;
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
} }
/** /**
@ -417,13 +408,12 @@ public class SysUserServiceImpl implements ISysUserService {
Long[] posts = user.getPostIds(); Long[] posts = user.getPostIds();
if (ArrayUtil.isNotEmpty(posts)) { if (ArrayUtil.isNotEmpty(posts)) {
// 新增用户与岗位管理 // 新增用户与岗位管理
List<SysUserPost> list = new ArrayList<>(posts.length); List<SysUserPost> list = StreamUtils.toList(Arrays.asList(posts), postId -> {
for (Long postId : posts) {
SysUserPost up = new SysUserPost(); SysUserPost up = new SysUserPost();
up.setUserId(user.getUserId()); up.setUserId(user.getUserId());
up.setPostId(postId); up.setPostId(postId);
list.add(up); return up;
} });
userPostMapper.insertBatch(list); userPostMapper.insertBatch(list);
} }
} }
@ -437,13 +427,12 @@ public class SysUserServiceImpl implements ISysUserService {
public void insertUserRole(Long userId, Long[] roleIds) { public void insertUserRole(Long userId, Long[] roleIds) {
if (ArrayUtil.isNotEmpty(roleIds)) { if (ArrayUtil.isNotEmpty(roleIds)) {
// 新增用户与角色管理 // 新增用户与角色管理
List<SysUserRole> list = new ArrayList<>(roleIds.length); List<SysUserRole> list = StreamUtils.toList(Arrays.asList(roleIds), roleId -> {
for (Long roleId : roleIds) {
SysUserRole ur = new SysUserRole(); SysUserRole ur = new SysUserRole();
ur.setUserId(userId); ur.setUserId(userId);
ur.setRoleId(roleId); ur.setRoleId(roleId);
list.add(ur); return ur;
} });
userRoleMapper.insertBatch(list); userRoleMapper.insertBatch(list);
} }
} }
@ -485,4 +474,12 @@ public class SysUserServiceImpl implements ISysUserService {
return baseMapper.deleteBatchIds(ids); return baseMapper.deleteBatchIds(ids);
} }
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
@Override
public String selectUserNameById(Long userId) {
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getUserName).eq(SysUser::getUserId, userId));
return ObjectUtil.isNull(sysUser) ? null : sysUser.getUserName();
}
} }

View File

@ -86,17 +86,17 @@
<select id="selectPageUserList" resultMap="SysUserResult"> <select id="selectPageUserList" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex,
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader
sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>
<select id="selectUserList" resultMap="SysUserResult"> <select id="selectUserList" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex,
u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader
sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id left join sys_dept d on u.dept_id = d.dept_id
${ew.getCustomSqlSegment} ${ew.getCustomSqlSegment}
</select> </select>

View File

@ -40,7 +40,7 @@
"clipboard": "2.0.8", "clipboard": "2.0.8",
"core-js": "3.25.3", "core-js": "3.25.3",
"echarts": "5.4.0", "echarts": "5.4.0",
"element-ui": "2.15.10", "element-ui": "2.15.12",
"file-saver": "2.0.5", "file-saver": "2.0.5",
"fuse.js": "6.4.3", "fuse.js": "6.4.3",
"highlight.js": "9.18.5", "highlight.js": "9.18.5",

View File

@ -87,7 +87,7 @@ export default {
}, },
isFirstView() { isFirstView() {
try { try {
return this.selectedTag.fullPath === this.visitedViews[1].fullPath || this.selectedTag.fullPath === '/index' return this.selectedTag.fullPath === '/index' || this.selectedTag.fullPath === this.visitedViews[1].fullPath
} catch (err) { } catch (err) {
return false return false
} }

View File

@ -8,7 +8,7 @@ import { isRelogin } from '@/utils/request'
NProgress.configure({ showSpinner: false }) NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] const whiteList = ['/login', '/register']
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()

View File

@ -17,9 +17,9 @@ export default {
url: url, url: url,
responseType: 'blob', responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() } headers: { 'Authorization': 'Bearer ' + getToken() }
}).then(async (res) => { }).then((res) => {
const isLogin = await blobValidate(res.data); const isBlob = blobValidate(res.data);
if (isLogin) { if (isBlob) {
const blob = new Blob([res.data], { type: 'application/octet-stream' }) const blob = new Blob([res.data], { type: 'application/octet-stream' })
this.saveAs(blob, decodeURIComponent(res.headers['download-filename'])) this.saveAs(blob, decodeURIComponent(res.headers['download-filename']))
} else { } else {
@ -42,9 +42,9 @@ export default {
'Authorization': 'Bearer ' + getToken(), 'Authorization': 'Bearer ' + getToken(),
'datasource': localStorage.getItem("dataName") 'datasource': localStorage.getItem("dataName")
} }
}).then(async (res) => { }).then((res) => {
const isLogin = await blobValidate(res.data); const isBlob = blobValidate(res.data);
if (isLogin) { if (isBlob) {
const blob = new Blob([res.data], { type: 'application/zip' }) const blob = new Blob([res.data], { type: 'application/zip' })
this.saveAs(blob, name) this.saveAs(blob, name)
} else { } else {

View File

@ -74,7 +74,7 @@ service.interceptors.response.use(res => {
// 获取错误信息 // 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default'] const msg = errorCode[code] || res.data.msg || errorCode['default']
// 二进制数据则直接返回 // 二进制数据则直接返回
if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){ if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data return res.data
} }
if (code === 401) { if (code === 401) {
@ -127,8 +127,8 @@ export function download(url, params, filename, config) {
responseType: 'blob', responseType: 'blob',
...config ...config
}).then(async (data) => { }).then(async (data) => {
const isLogin = await blobValidate(data); const isBlob = blobValidate(data);
if (isLogin) { if (isBlob) {
const blob = new Blob([data]) const blob = new Blob([data])
saveAs(blob, filename) saveAs(blob, filename)
} else { } else {

View File

@ -228,12 +228,6 @@ export function tansParams(params) {
} }
// 验证是否为blob格式 // 验证是否为blob格式
export async function blobValidate(data) { export function blobValidate(data) {
try { return data.type !== 'application/json'
const text = await data.text();
JSON.parse(text);
return false;
} catch (error) {
return true;
}
} }

View File

@ -56,7 +56,7 @@
</el-form> </el-form>
<!-- 底部 --> <!-- 底部 -->
<div class="el-login-footer"> <div class="el-login-footer">
<span>Copyright © 2018-2022 ruoyi.vip All Rights Reserved.</span> <span>Copyright © 2018-2023 ruoyi.vip All Rights Reserved.</span>
</div> </div>
</div> </div>
</template> </template>

View File

@ -3,7 +3,7 @@
<el-row> <el-row>
<el-col :span="24" class="card-box"> <el-col :span="24" class="card-box">
<el-card> <el-card>
<div slot="header"><span>基本信息</span></div> <div slot="header"><span><i class="el-icon-monitor"></i> 基本信息</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium"> <div class="el-table el-table--enable-row-hover el-table--medium">
<table cellspacing="0" style="width: 100%"> <table cellspacing="0" style="width: 100%">
<tbody> <tbody>
@ -45,7 +45,7 @@
<el-col :span="12" class="card-box"> <el-col :span="12" class="card-box">
<el-card> <el-card>
<div slot="header"><span>命令统计</span></div> <div slot="header"><span><i class="el-icon-pie-chart"></i> 命令统计</span></div>
<div class="el-table el-table--enable-row-hover el-table--medium"> <div class="el-table el-table--enable-row-hover el-table--medium">
<div ref="commandstats" style="height: 420px" /> <div ref="commandstats" style="height: 420px" />
</div> </div>
@ -54,9 +54,7 @@
<el-col :span="12" class="card-box"> <el-col :span="12" class="card-box">
<el-card> <el-card>
<div slot="header"> <div slot="header"><span><i class="el-icon-odometer"></i> 内存信息</span></div>
<span>内存信息</span>
</div>
<div class="el-table el-table--enable-row-hover el-table--medium"> <div class="el-table el-table--enable-row-hover el-table--medium">
<div ref="usedmemory" style="height: 420px" /> <div ref="usedmemory" style="height: 420px" />
</div> </div>

View File

@ -4,7 +4,7 @@
<el-col :span="8"> <el-col :span="8">
<el-card style="height: calc(100vh - 125px)"> <el-card style="height: calc(100vh - 125px)">
<div slot="header"> <div slot="header">
<span>缓存列表</span> <span><i class="el-icon-collection"></i> 缓存列表</span>
<el-button <el-button
style="float: right; padding: 3px 0" style="float: right; padding: 3px 0"
type="text" type="text"
@ -62,7 +62,7 @@
<el-col :span="8"> <el-col :span="8">
<el-card style="height: calc(100vh - 125px)"> <el-card style="height: calc(100vh - 125px)">
<div slot="header"> <div slot="header">
<span>键名列表</span> <span><i class="el-icon-key"></i> 键名列表</span>
<el-button <el-button
style="float: right; padding: 3px 0" style="float: right; padding: 3px 0"
type="text" type="text"
@ -112,7 +112,7 @@
<el-col :span="8"> <el-col :span="8">
<el-card :bordered="false" style="height: calc(100vh - 125px)"> <el-card :bordered="false" style="height: calc(100vh - 125px)">
<div slot="header"> <div slot="header">
<span>缓存内容</span> <span><i class="el-icon-document"></i> 缓存内容</span>
<el-button <el-button
style="float: right; padding: 3px 0" style="float: right; padding: 3px 0"
type="text" type="text"

View File

@ -61,7 +61,7 @@
</el-form> </el-form>
<!-- 底部 --> <!-- 底部 -->
<div class="el-register-footer"> <div class="el-register-footer">
<span>Copyright © 2018-2022 ruoyi.vip All Rights Reserved.</span> <span>Copyright © 2018-2023 ruoyi.vip All Rights Reserved.</span>
</div> </div>
</div> </div>
</template> </template>

View File

@ -107,7 +107,7 @@
<el-table-column label="参数主键" align="center" prop="configId" /> <el-table-column label="参数主键" align="center" prop="configId" />
<el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" /> <el-table-column label="参数名称" align="center" prop="configName" :show-overflow-tooltip="true" />
<el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" /> <el-table-column label="参数键名" align="center" prop="configKey" :show-overflow-tooltip="true" />
<el-table-column label="参数键值" align="center" prop="configValue" /> <el-table-column label="参数键值" align="center" prop="configValue" :show-overflow-tooltip="true" />
<el-table-column label="系统内置" align="center" prop="configType"> <el-table-column label="系统内置" align="center" prop="configType">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.configType"/> <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.configType"/>

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
CREATE TABLE [test_demo] CREATE TABLE test_demo
( (
[id] bigint NOT NULL, id bigint NOT NULL,
[dept_id] bigint NULL, dept_id bigint NULL,
[user_id] bigint NULL, user_id bigint NULL,
[order_num] int DEFAULT ((0)) NULL, order_num int DEFAULT ((0)) NULL,
[test_key] nvarchar(255) NULL, test_key nvarchar(255) NULL,
[value] nvarchar(255) NULL, value nvarchar(255) NULL,
[version] int DEFAULT ((0)) NULL, version int DEFAULT ((0)) NULL,
[create_time] datetime2(0) NULL, create_time datetime2(0) NULL,
[create_by] nvarchar(64) NULL, create_by nvarchar(64) NULL,
[update_time] datetime2(0) NULL, update_time datetime2(0) NULL,
[update_by] nvarchar(64) NULL, update_by nvarchar(64) NULL,
[del_flag] int DEFAULT ((0)) NULL, del_flag int DEFAULT ((0)) NULL,
CONSTRAINT [PK__test_dem__3213E83F176051C8] PRIMARY KEY CLUSTERED ([id]) CONSTRAINT PK__test_dem__3213E83F176051C8 PRIMARY KEY CLUSTERED (id)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY] ON [PRIMARY]
) )
@ -109,20 +109,20 @@ EXEC sp_addextendedproperty
'TABLE', N'test_demo' 'TABLE', N'test_demo'
GO GO
CREATE TABLE [test_tree] CREATE TABLE test_tree
( (
[id] bigint NOT NULL, id bigint NOT NULL,
[parent_id] bigint DEFAULT ((0)) NULL, parent_id bigint DEFAULT ((0)) NULL,
[dept_id] bigint NULL, dept_id bigint NULL,
[user_id] bigint NULL, user_id bigint NULL,
[tree_name] nvarchar(255) NULL, tree_name nvarchar(255) NULL,
[version] int DEFAULT ((0)) NULL, version int DEFAULT ((0)) NULL,
[create_time] datetime2(0) NULL, create_time datetime2(0) NULL,
[create_by] nvarchar(64) NULL, create_by nvarchar(64) NULL,
[update_time] datetime2(0) NULL, update_time datetime2(0) NULL,
[update_by] nvarchar(64) NULL, update_by nvarchar(64) NULL,
[del_flag] int DEFAULT ((0)) NULL, del_flag int DEFAULT ((0)) NULL,
CONSTRAINT [PK__test_tre__3213E83FC75A1B63] PRIMARY KEY CLUSTERED ([id]) CONSTRAINT PK__test_tre__3213E83FC75A1B63 PRIMARY KEY CLUSTERED (id)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY] ON [PRIMARY]
) )
@ -212,267 +212,267 @@ EXEC sp_addextendedproperty
'TABLE', N'test_tree' 'TABLE', N'test_tree'
GO GO
INSERT [sys_user] ([user_id], [dept_id], [user_name], [nick_name], [user_type], [email], [phonenumber], [sex], [avatar], [password], [status], [del_flag], [login_ip], [login_date], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (3, 108, N'test', N'本部门及以下 密码666666', N'sys_user', N'', N'', N'0', N'', N'$2a$10$b8yUzN0C71sbz.PhNOCgJe.Tu1yWC3RNrTyjSQ8p1W0.aaUXUJ.Ne', N'0', N'0', N'127.0.0.1', getdate(), N'admin', getdate(), N'test', getdate(), NULL); INSERT sys_user VALUES (3, 108, N'test', N'本部门及以下 密码666666', N'sys_user', N'', N'', N'0', N'', N'$2a$10$b8yUzN0C71sbz.PhNOCgJe.Tu1yWC3RNrTyjSQ8p1W0.aaUXUJ.Ne', N'0', N'0', N'127.0.0.1', getdate(), N'admin', getdate(), N'test', getdate(), NULL);
GO GO
INSERT [sys_user] ([user_id], [dept_id], [user_name], [nick_name], [user_type], [email], [phonenumber], [sex], [avatar], [password], [status], [del_flag], [login_ip], [login_date], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (4, 102, N'test1', N'仅本人 密码666666', N'sys_user', N'', N'', N'0', N'', N'$2a$10$b8yUzN0C71sbz.PhNOCgJe.Tu1yWC3RNrTyjSQ8p1W0.aaUXUJ.Ne', N'0', N'0', N'127.0.0.1', getdate(), N'admin', getdate(), N'test1', getdate(), NULL); INSERT sys_user VALUES (4, 102, N'test1', N'仅本人 密码666666', N'sys_user', N'', N'', N'0', N'', N'$2a$10$b8yUzN0C71sbz.PhNOCgJe.Tu1yWC3RNrTyjSQ8p1W0.aaUXUJ.Ne', N'0', N'0', N'127.0.0.1', getdate(), N'admin', getdate(), N'test1', getdate(), NULL);
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (5, N'测试菜单', 0, 5, N'demo', NULL, 1, 0, N'M', N'0', N'0', NULL, N'star', N'admin', getdate(), NULL, NULL, N''); INSERT sys_menu VALUES (5, N'测试菜单', 0, 5, N'demo', NULL, 1, 0, N'M', N'0', N'0', NULL, N'star', N'admin', getdate(), NULL, NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1500, N'测试单表', 5, 1, N'demo', N'demo/demo/index', 1, 0, N'C', N'0', N'0', N'demo:demo:list', N'#', N'admin', getdate(), N'', NULL, N'测试单表菜单'); INSERT sys_menu VALUES (1500, N'测试单表', 5, 1, N'demo', N'demo/demo/index', 1, 0, N'C', N'0', N'0', N'demo:demo:list', N'#', N'admin', getdate(), N'', NULL, N'测试单表菜单');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1501, N'测试单表查询', 1500, 1, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:query', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1501, N'测试单表查询', 1500, 1, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:query', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1502, N'测试单表新增', 1500, 2, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:add', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1502, N'测试单表新增', 1500, 2, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:add', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1503, N'测试单表修改', 1500, 3, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:edit', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1503, N'测试单表修改', 1500, 3, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:edit', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1504, N'测试单表删除', 1500, 4, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:remove', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1504, N'测试单表删除', 1500, 4, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:remove', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1505, N'测试单表导出', 1500, 5, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:export', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1505, N'测试单表导出', 1500, 5, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:demo:export', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1506, N'测试树表', 5, 1, N'tree', N'demo/tree/index', 1, 0, N'C', N'0', N'0', N'demo:tree:list', N'#', N'admin', getdate(), N'', NULL, N'测试树表菜单'); INSERT sys_menu VALUES (1506, N'测试树表', 5, 1, N'tree', N'demo/tree/index', 1, 0, N'C', N'0', N'0', N'demo:tree:list', N'#', N'admin', getdate(), N'', NULL, N'测试树表菜单');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1507, N'测试树表查询', 1506, 1, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:query', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1507, N'测试树表查询', 1506, 1, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:query', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1508, N'测试树表新增', 1506, 2, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:add', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1508, N'测试树表新增', 1506, 2, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:add', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1509, N'测试树表修改', 1506, 3, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:edit', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1509, N'测试树表修改', 1506, 3, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:edit', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1510, N'测试树表删除', 1506, 4, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:remove', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1510, N'测试树表删除', 1506, 4, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:remove', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_menu] ([menu_id], [menu_name], [parent_id], [order_num], [path], [component], [is_frame], [is_cache], [menu_type], [visible], [status], [perms], [icon], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (1511, N'测试树表导出', 1506, 5, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:export', N'#', N'admin', getdate(), N'', NULL, N''); INSERT sys_menu VALUES (1511, N'测试树表导出', 1506, 5, N'#', N'', 1, 0, N'F', N'0', N'0', N'demo:tree:export', N'#', N'admin', getdate(), N'', NULL, N'');
GO GO
INSERT [sys_role] ([role_id], [role_name], [role_key], [role_sort], [data_scope], [menu_check_strictly], [dept_check_strictly], [status], [del_flag], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (3, N'本部门及以下', N'test1', 3, N'4', 1, 1, N'0', N'0', N'admin', getdate(), N'admin', NULL, NULL); INSERT sys_role VALUES (3, N'本部门及以下', N'test1', 3, N'4', 1, 1, N'0', N'0', N'admin', getdate(), N'admin', NULL, NULL);
GO GO
INSERT [sys_role] ([role_id], [role_name], [role_key], [role_sort], [data_scope], [menu_check_strictly], [dept_check_strictly], [status], [del_flag], [create_by], [create_time], [update_by], [update_time], [remark]) VALUES (4, N'仅本人', N'test2', 4, N'5', 1, 1, N'0', N'0', N'admin', getdate(), N'admin', NULL, NULL); INSERT sys_role VALUES (4, N'仅本人', N'test2', 4, N'5', 1, 1, N'0', N'0', N'admin', getdate(), N'admin', NULL, NULL);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1); INSERT sys_role_menu VALUES (3, 1);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 5); INSERT sys_role_menu VALUES (3, 5);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 100); INSERT sys_role_menu VALUES (3, 100);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 101); INSERT sys_role_menu VALUES (3, 101);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 102); INSERT sys_role_menu VALUES (3, 102);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 103); INSERT sys_role_menu VALUES (3, 103);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 104); INSERT sys_role_menu VALUES (3, 104);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 105); INSERT sys_role_menu VALUES (3, 105);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 106); INSERT sys_role_menu VALUES (3, 106);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 107); INSERT sys_role_menu VALUES (3, 107);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 108); INSERT sys_role_menu VALUES (3, 108);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 500); INSERT sys_role_menu VALUES (3, 500);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 501); INSERT sys_role_menu VALUES (3, 501);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1001); INSERT sys_role_menu VALUES (3, 1001);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1002); INSERT sys_role_menu VALUES (3, 1002);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1003); INSERT sys_role_menu VALUES (3, 1003);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1004); INSERT sys_role_menu VALUES (3, 1004);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1005); INSERT sys_role_menu VALUES (3, 1005);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1006); INSERT sys_role_menu VALUES (3, 1006);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1007); INSERT sys_role_menu VALUES (3, 1007);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1008); INSERT sys_role_menu VALUES (3, 1008);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1009); INSERT sys_role_menu VALUES (3, 1009);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1010); INSERT sys_role_menu VALUES (3, 1010);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1011); INSERT sys_role_menu VALUES (3, 1011);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1012); INSERT sys_role_menu VALUES (3, 1012);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1013); INSERT sys_role_menu VALUES (3, 1013);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1014); INSERT sys_role_menu VALUES (3, 1014);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1015); INSERT sys_role_menu VALUES (3, 1015);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1016); INSERT sys_role_menu VALUES (3, 1016);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1017); INSERT sys_role_menu VALUES (3, 1017);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1018); INSERT sys_role_menu VALUES (3, 1018);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1019); INSERT sys_role_menu VALUES (3, 1019);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1020); INSERT sys_role_menu VALUES (3, 1020);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1021); INSERT sys_role_menu VALUES (3, 1021);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1022); INSERT sys_role_menu VALUES (3, 1022);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1023); INSERT sys_role_menu VALUES (3, 1023);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1024); INSERT sys_role_menu VALUES (3, 1024);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1025); INSERT sys_role_menu VALUES (3, 1025);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1026); INSERT sys_role_menu VALUES (3, 1026);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1027); INSERT sys_role_menu VALUES (3, 1027);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1028); INSERT sys_role_menu VALUES (3, 1028);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1029); INSERT sys_role_menu VALUES (3, 1029);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1030); INSERT sys_role_menu VALUES (3, 1030);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1031); INSERT sys_role_menu VALUES (3, 1031);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1032); INSERT sys_role_menu VALUES (3, 1032);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1033); INSERT sys_role_menu VALUES (3, 1033);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1034); INSERT sys_role_menu VALUES (3, 1034);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1035); INSERT sys_role_menu VALUES (3, 1035);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1036); INSERT sys_role_menu VALUES (3, 1036);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1037); INSERT sys_role_menu VALUES (3, 1037);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1038); INSERT sys_role_menu VALUES (3, 1038);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1039); INSERT sys_role_menu VALUES (3, 1039);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1040); INSERT sys_role_menu VALUES (3, 1040);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1041); INSERT sys_role_menu VALUES (3, 1041);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1042); INSERT sys_role_menu VALUES (3, 1042);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1043); INSERT sys_role_menu VALUES (3, 1043);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1044); INSERT sys_role_menu VALUES (3, 1044);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1045); INSERT sys_role_menu VALUES (3, 1045);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1500); INSERT sys_role_menu VALUES (3, 1500);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1501); INSERT sys_role_menu VALUES (3, 1501);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1502); INSERT sys_role_menu VALUES (3, 1502);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1503); INSERT sys_role_menu VALUES (3, 1503);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1504); INSERT sys_role_menu VALUES (3, 1504);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1505); INSERT sys_role_menu VALUES (3, 1505);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1506); INSERT sys_role_menu VALUES (3, 1506);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1507); INSERT sys_role_menu VALUES (3, 1507);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1508); INSERT sys_role_menu VALUES (3, 1508);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1509); INSERT sys_role_menu VALUES (3, 1509);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1510); INSERT sys_role_menu VALUES (3, 1510);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (3, 1511); INSERT sys_role_menu VALUES (3, 1511);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 5); INSERT sys_role_menu VALUES (4, 5);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1500); INSERT sys_role_menu VALUES (4, 1500);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1501); INSERT sys_role_menu VALUES (4, 1501);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1502); INSERT sys_role_menu VALUES (4, 1502);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1503); INSERT sys_role_menu VALUES (4, 1503);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1504); INSERT sys_role_menu VALUES (4, 1504);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1505); INSERT sys_role_menu VALUES (4, 1505);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1506); INSERT sys_role_menu VALUES (4, 1506);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1507); INSERT sys_role_menu VALUES (4, 1507);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1508); INSERT sys_role_menu VALUES (4, 1508);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1509); INSERT sys_role_menu VALUES (4, 1509);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1510); INSERT sys_role_menu VALUES (4, 1510);
GO GO
INSERT [sys_role_menu] ([role_id], [menu_id]) VALUES (4, 1511); INSERT sys_role_menu VALUES (4, 1511);
GO GO
INSERT [sys_user_role] ([user_id], [role_id]) VALUES (3, 3); INSERT sys_user_role VALUES (3, 3);
GO GO
INSERT [sys_user_role] ([user_id], [role_id]) VALUES (4, 4); INSERT sys_user_role VALUES (4, 4);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (1, 102, 4, 1, N'测试数据权限', N'测试', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (1, 102, 4, 1, N'测试数据权限', N'测试', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (2, 102, 3, 2, N'子节点1', N'111', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (2, 102, 3, 2, N'子节点1', N'111', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (3, 102, 3, 3, N'子节点2', N'222', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (3, 102, 3, 3, N'子节点2', N'222', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (4, 108, 4, 4, N'测试数据', N'demo', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (4, 108, 4, 4, N'测试数据', N'demo', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (5, 108, 3, 13, N'子节点11', N'1111', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (5, 108, 3, 13, N'子节点11', N'1111', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (6, 108, 3, 12, N'子节点22', N'2222', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (6, 108, 3, 12, N'子节点22', N'2222', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (7, 108, 3, 11, N'子节点33', N'3333', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (7, 108, 3, 11, N'子节点33', N'3333', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (8, 108, 3, 10, N'子节点44', N'4444', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (8, 108, 3, 10, N'子节点44', N'4444', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (9, 108, 3, 9, N'子节点55', N'5555', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (9, 108, 3, 9, N'子节点55', N'5555', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (10, 108, 3, 8, N'子节点66', N'6666', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (10, 108, 3, 8, N'子节点66', N'6666', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (11, 108, 3, 7, N'子节点77', N'7777', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (11, 108, 3, 7, N'子节点77', N'7777', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (12, 108, 3, 6, N'子节点88', N'8888', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (12, 108, 3, 6, N'子节点88', N'8888', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_demo] ([id], [dept_id], [user_id], [order_num], [test_key], [value], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (13, 108, 3, 5, N'子节点99', N'9999', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_demo VALUES (13, 108, 3, 5, N'子节点99', N'9999', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (1, 0, 102, 4, N'测试数据权限', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (1, 0, 102, 4, N'测试数据权限', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (2, 1, 102, 3, N'子节点1', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (2, 1, 102, 3, N'子节点1', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (3, 2, 102, 3, N'子节点2', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (3, 2, 102, 3, N'子节点2', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (4, 0, 108, 4, N'测试树1', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (4, 0, 108, 4, N'测试树1', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (5, 4, 108, 3, N'子节点11', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (5, 4, 108, 3, N'子节点11', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (6, 4, 108, 3, N'子节点22', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (6, 4, 108, 3, N'子节点22', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (7, 4, 108, 3, N'子节点33', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (7, 4, 108, 3, N'子节点33', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (8, 5, 108, 3, N'子节点44', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (8, 5, 108, 3, N'子节点44', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (9, 6, 108, 3, N'子节点55', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (9, 6, 108, 3, N'子节点55', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (10, 7, 108, 3, N'子节点66', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (10, 7, 108, 3, N'子节点66', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (11, 7, 108, 3, N'子节点77', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (11, 7, 108, 3, N'子节点77', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (12, 10, 108, 3, N'子节点88', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (12, 10, 108, 3, N'子节点88', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO
INSERT [test_tree] ([id], [parent_id], [dept_id], [user_id], [tree_name], [version], [create_time], [create_by], [update_time], [update_by], [del_flag]) VALUES (13, 10, 108, 3, N'子节点99', 0, getdate(), N'admin', NULL, NULL, 0); INSERT test_tree VALUES (13, 10, 108, 3, N'子节点99', 0, getdate(), N'admin', NULL, NULL, 0);
GO GO