diff --git a/.run/ruoyi-monitor-admin.run.xml b/.run/ruoyi-monitor-admin.run.xml index b2bf329bb..fc7e8a34f 100644 --- a/.run/ruoyi-monitor-admin.run.xml +++ b/.run/ruoyi-monitor-admin.run.xml @@ -2,7 +2,7 @@ - diff --git a/.run/ruoyi-server.run.xml b/.run/ruoyi-server.run.xml index 7dc652824..394b23a7e 100644 --- a/.run/ruoyi-server.run.xml +++ b/.run/ruoyi-server.run.xml @@ -2,7 +2,7 @@ - diff --git a/.run/ruoyi-xxl-job-admin.run.xml b/.run/ruoyi-xxl-job-admin.run.xml index 47b662a58..2aeab19ed 100644 --- a/.run/ruoyi-xxl-job-admin.run.xml +++ b/.run/ruoyi-xxl-job-admin.run.xml @@ -2,7 +2,7 @@ - diff --git a/README.md b/README.md index 7f3782076..2d8cb9677 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://gitee.com/dromara/RuoYi-Vue-Plus/blob/master/LICENSE) [![使用IntelliJ IDEA开发维护](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
-[![RuoYi-Vue-Plus](https://img.shields.io/badge/RuoYi_Vue_Plus-4.8.0-success.svg)](https://gitee.com/dromara/RuoYi-Vue-Plus) +[![RuoYi-Vue-Plus](https://img.shields.io/badge/RuoYi_Vue_Plus-4.8.1-success.svg)](https://gitee.com/dromara/RuoYi-Vue-Plus) [![Spring Boot](https://img.shields.io/badge/Spring%20Boot-2.7-blue.svg)]() [![JDK-8+](https://img.shields.io/badge/JDK-8-green.svg)]() [![JDK-11](https://img.shields.io/badge/JDK-11-green.svg)]() diff --git a/pom.xml b/pom.xml index 9184209d5..4aba6eb4a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,15 +6,15 @@ com.ruoyi ruoyi-vue-plus - 4.8.0 + 4.8.1 RuoYi-Vue-Plus https://gitee.com/dromara/RuoYi-Vue-Plus RuoYi-Vue-Plus后台管理系统 - 4.8.0 - 2.7.13 + 4.8.1 + 2.7.16 UTF-8 UTF-8 1.8 @@ -22,20 +22,20 @@ 2.2.2 1.6.15 5.2.3 - 3.3.1 + 3.3.2 2.3 - 1.35.0.RC - 3.5.3.1 + 1.36.0 + 3.5.3.2 3.9.1 - 5.8.18 + 5.8.20 4.10.0 - 2.7.10 + 2.7.11 3.20.1 2.2.3 3.5.2 2.14.2 2.4.0 - 1.18.26 + 1.18.30 1.72 2.7.0 diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 2d70db620..fc71bc4fd 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 jar diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 512c644c4..a54483cfd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -91,9 +91,12 @@ public R edit(@Validated @RequestBody SysDept dept) { return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(deptId)) { return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); - } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) - && deptService.selectNormalChildrenDeptById(deptId) > 0) { - return R.fail("该部门包含未停用的子部门!"); + } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())) { + if (deptService.selectNormalChildrenDeptById(deptId) > 0) { + return R.fail("该部门包含未停用的子部门!"); + } else if (deptService.checkDeptExistUser(deptId)) { + return R.fail("该部门下存在已分配用户,不能禁用!"); + } } return toAjax(deptService.updateDept(dept)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index 4036364fa..429256a47 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -88,6 +88,9 @@ public R edit(@Validated @RequestBody SysPost post) { return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (!postService.checkPostCodeUnique(post)) { return R.fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + } else if (UserConstants.POST_DISABLE.equals(post.getStatus()) + && postService.countUserPostById(post.getPostId()) > 0) { + return R.fail("该岗位下存在已分配用户,不能禁用!"); } return toAjax(postService.updatePost(post)); } @@ -109,7 +112,9 @@ public R remove(@PathVariable Long[] postIds) { */ @GetMapping("/optionselect") public R> optionselect() { - List posts = postService.selectPostAll(); + SysPost post = new SysPost(); + post.setStatus(UserConstants.POST_NORMAL); + List posts = postService.selectPostList(post); return R.ok(posts); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index 9e646ec2c..707c003a7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -78,8 +78,8 @@ public R updateProfile(@RequestBody SysUser user) { /** * 重置密码 * - * @param newPassword 旧密码 - * @param oldPassword 新密码 + * @param newPassword 新密码 + * @param oldPassword 旧密码 */ @Log(title = "个人信息", businessType = BusinessType.UPDATE) @PutMapping("/updatePwd") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 0b91c50b9..d055e713a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -21,6 +21,7 @@ import com.ruoyi.common.utils.StreamUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.vo.SysUserExportVo; import com.ruoyi.system.domain.vo.SysUserImportVo; import com.ruoyi.system.listener.SysUserImportListener; @@ -117,9 +118,13 @@ public void importTemplate(HttpServletResponse response) { public R> getInfo(@PathVariable(value = "userId", required = false) Long userId) { userService.checkUserDataScope(userId); Map ajax = new HashMap<>(); - List roles = roleService.selectRoleAll(); + SysRole role = new SysRole(); + role.setStatus(UserConstants.ROLE_NORMAL); + SysPost post = new SysPost(); + post.setStatus(UserConstants.POST_NORMAL); + List roles = roleService.selectRoleList(role); ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin())); - ajax.put("posts", postService.selectPostAll()); + ajax.put("posts", postService.selectPostList(post)); if (ObjectUtil.isNotNull(userId)) { SysUser sysUser = userService.selectUserById(userId); ajax.put("user", sysUser); @@ -136,6 +141,7 @@ public R> getInfo(@PathVariable(value = "userId", required = @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping public R add(@Validated @RequestBody SysUser user) { + deptService.checkDeptDataScope(user.getDeptId()); if (!userService.checkUserNameUnique(user)) { return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { @@ -156,6 +162,7 @@ public R add(@Validated @RequestBody SysUser user) { public R edit(@Validated @RequestBody SysUser user) { userService.checkUserAllowed(user); userService.checkUserDataScope(user.getUserId()); + deptService.checkDeptDataScope(user.getDeptId()); if (!userService.checkUserNameUnique(user)) { return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index ffbc1c81a..c1cca7e9c 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -19,8 +19,8 @@ xxl.job: executor: # 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册 appname: xxl-job-executor - # 执行器端口号 执行器从9101开始往后写 - port: 9101 + # 28080 端口 随着主应用端口飘逸 避免集群冲突 + port: 2${server.port} # 执行器注册:默认IP:PORT address: # 执行器IP:默认自动获取IP diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index 6292ceab6..ca9072ef5 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -22,8 +22,8 @@ xxl.job: executor: # 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册 appname: xxl-job-executor - # 执行器端口号 执行器从9101开始往后写 - port: 9101 + # 28080 端口 随着主应用端口飘逸 避免集群冲突 + port: 2${server.port} # 执行器注册:默认IP:PORT address: # 执行器IP:默认自动获取IP diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index cec277bed..77a9ea2ce 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -5,11 +5,7 @@ ruoyi: # 版本 version: ${ruoyi-vue-plus.version} # 版权年份 - copyrightYear: 2022 - # 实例演示开关 - demoEnabled: true - # 获取ip地址开关 - addressEnabled: true + copyrightYear: 2023 # 缓存懒加载 cacheLazy: false @@ -107,6 +103,8 @@ sa-token: # 多端不同 token 有效期 可查看 LoginHelper.loginByDevice 方法自定义 # token最低活跃时间 (指定时间无操作就过期) 单位: 秒 active-timeout: 1800 + # 允许动态设置 token 有效期 + dynamic-active-timeout: true # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) is-concurrent: true # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token) diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index b1ae8c99c..6e0a17d74 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java index 8ce7a8c4f..70c3d2946 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java @@ -1,7 +1,6 @@ package com.ruoyi.common.config; import lombok.Data; -import lombok.Getter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -31,24 +30,9 @@ public class RuoYiConfig { */ private String copyrightYear; - /** - * 实例演示开关 - */ - private boolean demoEnabled; - /** * 缓存懒加载 */ private boolean cacheLazy; - /** - * 获取地址开关 - */ - @Getter - private static boolean addressEnabled; - - public void setAddressEnabled(boolean addressEnabled) { - RuoYiConfig.addressEnabled = addressEnabled; - } - } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java index 569c5dafa..61552f8fc 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java @@ -52,6 +52,16 @@ public interface UserConstants { */ String DEPT_DISABLE = "1"; + /** + * 岗位正常状态 + */ + String POST_NORMAL = "0"; + + /** + * 岗位停用状态 + */ + String POST_DISABLE = "1"; + /** * 字典正常状态 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java index 0a8539ad6..20b05d82f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mapper/BaseMapperPlus.java @@ -180,12 +180,12 @@ default

> P selectVoPage(IPage page, Wrapper wrapper) { * 分页查询VO */ default > P selectVoPage(IPage page, Wrapper wrapper, Class voClass) { - IPage pageData = this.selectPage(page, wrapper); - IPage voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal()); - if (CollUtil.isEmpty(pageData.getRecords())) { + List list = this.selectList(page, wrapper); + IPage voPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal()); + if (CollUtil.isEmpty(list)) { return (P) voPage; } - voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass)); + voPage.setRecords(BeanCopyUtils.copyList(list, voClass)); return (P) voPage; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/AesEncryptor.java b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/AesEncryptor.java index ee4d82665..72521454d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/AesEncryptor.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/AesEncryptor.java @@ -1,14 +1,9 @@ package com.ruoyi.common.encrypt.encryptor; -import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.crypto.SecureUtil; -import cn.hutool.crypto.symmetric.AES; import com.ruoyi.common.encrypt.EncryptContext; import com.ruoyi.common.enums.AlgorithmType; import com.ruoyi.common.enums.EncodeType; - -import java.nio.charset.StandardCharsets; +import com.ruoyi.common.utils.EncryptUtils; /** * AES算法实现 @@ -18,20 +13,11 @@ */ public class AesEncryptor extends AbstractEncryptor { - private final AES aes; + private final EncryptContext context; public AesEncryptor(EncryptContext context) { super(context); - String password = context.getPassword(); - if (StrUtil.isBlank(password)) { - throw new IllegalArgumentException("AES没有获得秘钥信息"); - } - // aes算法的秘钥要求是16位、24位、32位 - int[] array = {16, 24, 32}; - if (!ArrayUtil.contains(array, password.length())) { - throw new IllegalArgumentException("AES秘钥长度应该为16位、24位、32位,实际为" + password.length() + "位"); - } - aes = SecureUtil.aes(context.getPassword().getBytes(StandardCharsets.UTF_8)); + this.context = context; } /** @@ -51,9 +37,9 @@ public AlgorithmType algorithm() { @Override public String encrypt(String value, EncodeType encodeType) { if (encodeType == EncodeType.HEX) { - return aes.encryptHex(value); + return EncryptUtils.encryptByAesHex(value, context.getPassword()); } else { - return aes.encryptBase64(value); + return EncryptUtils.encryptByAes(value, context.getPassword()); } } @@ -64,6 +50,6 @@ public String encrypt(String value, EncodeType encodeType) { */ @Override public String decrypt(String value) { - return this.aes.decryptStr(value); + return EncryptUtils.decryptByAes(value, context.getPassword()); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Base64Encryptor.java b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Base64Encryptor.java index 519158d00..3bd4149a6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Base64Encryptor.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Base64Encryptor.java @@ -1,9 +1,9 @@ package com.ruoyi.common.encrypt.encryptor; -import cn.hutool.core.codec.Base64; import com.ruoyi.common.encrypt.EncryptContext; import com.ruoyi.common.enums.AlgorithmType; import com.ruoyi.common.enums.EncodeType; +import com.ruoyi.common.utils.EncryptUtils; /** * Base64算法实现 @@ -33,7 +33,7 @@ public AlgorithmType algorithm() { */ @Override public String encrypt(String value, EncodeType encodeType) { - return Base64.encode(value); + return EncryptUtils.encryptByBase64(value); } /** @@ -43,6 +43,6 @@ public String encrypt(String value, EncodeType encodeType) { */ @Override public String decrypt(String value) { - return Base64.decodeStr(value); + return EncryptUtils.decryptByBase64(value); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/RsaEncryptor.java b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/RsaEncryptor.java index 2563fc214..9e0776422 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/RsaEncryptor.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/RsaEncryptor.java @@ -1,12 +1,9 @@ package com.ruoyi.common.encrypt.encryptor; -import cn.hutool.core.codec.Base64; -import cn.hutool.crypto.SecureUtil; -import cn.hutool.crypto.asymmetric.KeyType; -import cn.hutool.crypto.asymmetric.RSA; import com.ruoyi.common.encrypt.EncryptContext; import com.ruoyi.common.enums.AlgorithmType; import com.ruoyi.common.enums.EncodeType; +import com.ruoyi.common.utils.EncryptUtils; import com.ruoyi.common.utils.StringUtils; @@ -18,7 +15,7 @@ */ public class RsaEncryptor extends AbstractEncryptor { - private final RSA rsa; + private final EncryptContext context; public RsaEncryptor(EncryptContext context) { super(context); @@ -27,7 +24,7 @@ public RsaEncryptor(EncryptContext context) { if (StringUtils.isAnyEmpty(privateKey, publicKey)) { throw new IllegalArgumentException("RSA公私钥均需要提供,公钥加密,私钥解密。"); } - this.rsa = SecureUtil.rsa(Base64.decode(privateKey), Base64.decode(publicKey)); + this.context = context; } /** @@ -47,9 +44,9 @@ public AlgorithmType algorithm() { @Override public String encrypt(String value, EncodeType encodeType) { if (encodeType == EncodeType.HEX) { - return rsa.encryptHex(value, KeyType.PublicKey); + return EncryptUtils.encryptByRsaHex(value, context.getPublicKey()); } else { - return rsa.encryptBase64(value, KeyType.PublicKey); + return EncryptUtils.encryptByRsa(value, context.getPublicKey()); } } @@ -60,6 +57,6 @@ public String encrypt(String value, EncodeType encodeType) { */ @Override public String decrypt(String value) { - return this.rsa.decryptStr(value, KeyType.PrivateKey); + return EncryptUtils.decryptByRsa(value, context.getPrivateKey()); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm2Encryptor.java b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm2Encryptor.java index a84f7f7ea..ec4714aa4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm2Encryptor.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm2Encryptor.java @@ -1,13 +1,10 @@ package com.ruoyi.common.encrypt.encryptor; -import cn.hutool.core.codec.Base64; -import cn.hutool.crypto.SmUtil; -import cn.hutool.crypto.asymmetric.KeyType; -import cn.hutool.crypto.asymmetric.SM2; import com.ruoyi.common.encrypt.EncryptContext; import com.ruoyi.common.enums.AlgorithmType; import com.ruoyi.common.enums.EncodeType; +import com.ruoyi.common.utils.EncryptUtils; import com.ruoyi.common.utils.StringUtils; /** @@ -18,7 +15,7 @@ */ public class Sm2Encryptor extends AbstractEncryptor { - private final SM2 sm2; + private final EncryptContext context; public Sm2Encryptor(EncryptContext context) { super(context); @@ -27,7 +24,7 @@ public Sm2Encryptor(EncryptContext context) { if (StringUtils.isAnyEmpty(privateKey, publicKey)) { throw new IllegalArgumentException("SM2公私钥均需要提供,公钥加密,私钥解密。"); } - this.sm2 = SmUtil.sm2(Base64.decode(privateKey), Base64.decode(publicKey)); + this.context = context; } /** @@ -47,9 +44,9 @@ public AlgorithmType algorithm() { @Override public String encrypt(String value, EncodeType encodeType) { if (encodeType == EncodeType.HEX) { - return sm2.encryptHex(value, KeyType.PublicKey); + return EncryptUtils.encryptBySm2Hex(value, context.getPublicKey()); } else { - return sm2.encryptBase64(value, KeyType.PublicKey); + return EncryptUtils.encryptBySm2(value, context.getPublicKey()); } } @@ -60,6 +57,6 @@ public String encrypt(String value, EncodeType encodeType) { */ @Override public String decrypt(String value) { - return this.sm2.decryptStr(value, KeyType.PrivateKey); + return EncryptUtils.decryptBySm2(value, context.getPrivateKey()); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm4Encryptor.java b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm4Encryptor.java index 7d2e50974..80a57df67 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm4Encryptor.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/encrypt/encryptor/Sm4Encryptor.java @@ -1,13 +1,9 @@ package com.ruoyi.common.encrypt.encryptor; -import cn.hutool.core.util.StrUtil; -import cn.hutool.crypto.SmUtil; -import cn.hutool.crypto.symmetric.SM4; import com.ruoyi.common.encrypt.EncryptContext; import com.ruoyi.common.enums.AlgorithmType; import com.ruoyi.common.enums.EncodeType; - -import java.nio.charset.StandardCharsets; +import com.ruoyi.common.utils.EncryptUtils; /** * sm4算法实现 @@ -17,19 +13,11 @@ */ public class Sm4Encryptor extends AbstractEncryptor { - private final SM4 sm4; + private final EncryptContext context; public Sm4Encryptor(EncryptContext context) { super(context); - String password = context.getPassword(); - if (StrUtil.isBlank(password)) { - throw new IllegalArgumentException("SM4没有获得秘钥信息"); - } - // sm4算法的秘钥要求是16位长度 - if (16 != password.length()) { - throw new IllegalArgumentException("SM4秘钥长度应该为16位,实际为" + password.length() + "位"); - } - this.sm4 = SmUtil.sm4(password.getBytes(StandardCharsets.UTF_8)); + this.context = context; } /** @@ -49,9 +37,9 @@ public AlgorithmType algorithm() { @Override public String encrypt(String value, EncodeType encodeType) { if (encodeType == EncodeType.HEX) { - return sm4.encryptHex(value); + return EncryptUtils.encryptBySm4Hex(value, context.getPassword()); } else { - return sm4.encryptBase64(value); + return EncryptUtils.encryptBySm4(value, context.getPassword()); } } @@ -62,6 +50,6 @@ public String encrypt(String value, EncodeType encodeType) { */ @Override public String decrypt(String value) { - return this.sm4.decryptStr(value); + return EncryptUtils.decryptBySm4(value, context.getPassword()); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/excel/ExcelDownHandler.java b/ruoyi-common/src/main/java/com/ruoyi/common/excel/ExcelDownHandler.java index 442e353dd..09f038886 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/excel/ExcelDownHandler.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/excel/ExcelDownHandler.java @@ -5,7 +5,9 @@ import cn.hutool.core.util.EnumUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.metadata.FieldCache; +import com.alibaba.excel.metadata.FieldWrapper; +import com.alibaba.excel.util.ClassUtils; import com.alibaba.excel.write.handler.SheetWriteHandler; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; @@ -83,16 +85,18 @@ public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheet Sheet sheet = writeSheetHolder.getSheet(); // 开始设置下拉框 HSSFWorkbook DataValidationHelper helper = sheet.getDataValidationHelper(); - Field[] fields = writeWorkbookHolder.getClazz().getDeclaredFields(); Workbook workbook = writeWorkbookHolder.getWorkbook(); - int length = fields.length; - for (int i = 0; i < length; i++) { + FieldCache fieldCache = ClassUtils.declaredFields(writeWorkbookHolder.getClazz(), writeWorkbookHolder); + for (Map.Entry entry : fieldCache.getSortedFieldMap().entrySet()) { + Integer index = entry.getKey(); + FieldWrapper wrapper = entry.getValue(); + Field field = wrapper.getField(); // 循环实体中的每个属性 // 可选的下拉值 List options = new ArrayList<>(); - if (fields[i].isAnnotationPresent(ExcelDictFormat.class)) { + if (field.isAnnotationPresent(ExcelDictFormat.class)) { // 如果指定了@ExcelDictFormat,则使用字典的逻辑 - ExcelDictFormat format = fields[i].getDeclaredAnnotation(ExcelDictFormat.class); + ExcelDictFormat format = field.getDeclaredAnnotation(ExcelDictFormat.class); String dictType = format.dictType(); String converterExp = format.readConverterExp(); if (StrUtil.isNotBlank(dictType)) { @@ -105,20 +109,14 @@ public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheet // 如果指定了确切的值,则直接解析确切的值 options = StrUtil.split(converterExp, format.separator(), true, true); } - } else if (fields[i].isAnnotationPresent(ExcelEnumFormat.class)) { + } else if (field.isAnnotationPresent(ExcelEnumFormat.class)) { // 否则如果指定了@ExcelEnumFormat,则使用枚举的逻辑 - ExcelEnumFormat format = fields[i].getDeclaredAnnotation(ExcelEnumFormat.class); + ExcelEnumFormat format = field.getDeclaredAnnotation(ExcelEnumFormat.class); List values = EnumUtil.getFieldValues(format.enumClass(), format.textField()); options = StreamUtils.toList(values, String::valueOf); } if (ObjectUtil.isNotEmpty(options)) { // 仅当下拉可选项不为空时执行 - // 获取列下标,默认为当前循环次数 - int index = i; - if (fields[i].isAnnotationPresent(ExcelProperty.class)) { - // 如果指定了列下标,以指定的为主 - index = fields[i].getDeclaredAnnotation(ExcelProperty.class).index(); - } if (options.size() > 20) { // 这里限制如果可选项大于20,则使用额外表形式 dropDownWithSheet(helper, workbook, sheet, index, options); @@ -128,6 +126,9 @@ public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheet } } } + if (CollUtil.isEmpty(dropDownOptions)) { + return; + } dropDownOptions.forEach(everyOptions -> { // 如果传递了下拉框选择器参数 if (!everyOptions.getNextOptions().isEmpty()) { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java index 691b6c0f4..ab213b71e 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/EncryptUtils.java @@ -67,6 +67,25 @@ public static String encryptByAes(String data, String password) { return SecureUtil.aes(password.getBytes(StandardCharsets.UTF_8)).encryptBase64(data, StandardCharsets.UTF_8); } + /** + * AES加密 + * + * @param data 待解密数据 + * @param password 秘钥字符串 + * @return 加密后字符串, 采用Hex编码 + */ + public static String encryptByAesHex(String data, String password) { + if (StrUtil.isBlank(password)) { + throw new IllegalArgumentException("AES需要传入秘钥信息"); + } + // aes算法的秘钥要求是16位、24位、32位 + int[] array = {16, 24, 32}; + if (!ArrayUtil.contains(array, password.length())) { + throw new IllegalArgumentException("AES秘钥长度要求为16位、24位、32位"); + } + return SecureUtil.aes(password.getBytes(StandardCharsets.UTF_8)).encryptHex(data, StandardCharsets.UTF_8); + } + /** * AES解密 * @@ -105,6 +124,25 @@ public static String encryptBySm4(String data, String password) { return SmUtil.sm4(password.getBytes(StandardCharsets.UTF_8)).encryptBase64(data, StandardCharsets.UTF_8); } + /** + * sm4加密 + * + * @param data 待加密数据 + * @param password 秘钥字符串 + * @return 加密后字符串, 采用Base64编码 + */ + public static String encryptBySm4Hex(String data, String password) { + if (StrUtil.isBlank(password)) { + throw new IllegalArgumentException("SM4需要传入秘钥信息"); + } + // sm4算法的秘钥要求是16位长度 + int sm4PasswordLength = 16; + if (sm4PasswordLength != password.length()) { + throw new IllegalArgumentException("SM4秘钥长度要求为16位"); + } + return SmUtil.sm4(password.getBytes(StandardCharsets.UTF_8)).encryptHex(data, StandardCharsets.UTF_8); + } + /** * sm4解密 * @@ -152,6 +190,21 @@ public static String encryptBySm2(String data, String publicKey) { return sm2.encryptBase64(data, StandardCharsets.UTF_8, KeyType.PublicKey); } + /** + * sm2公钥加密 + * + * @param data 待加密数据 + * @param publicKey 公钥 + * @return 加密后字符串, 采用Hex编码 + */ + public static String encryptBySm2Hex(String data, String publicKey) { + if (StrUtil.isBlank(publicKey)) { + throw new IllegalArgumentException("SM2需要传入公钥进行加密"); + } + SM2 sm2 = SmUtil.sm2(null, publicKey); + return sm2.encryptHex(data, StandardCharsets.UTF_8, KeyType.PublicKey); + } + /** * sm2私钥解密 * @@ -195,6 +248,21 @@ public static String encryptByRsa(String data, String publicKey) { return rsa.encryptBase64(data, StandardCharsets.UTF_8, KeyType.PublicKey); } + /** + * rsa公钥加密 + * + * @param data 待加密数据 + * @param publicKey 公钥 + * @return 加密后字符串, 采用Hex编码 + */ + public static String encryptByRsaHex(String data, String publicKey) { + if (StrUtil.isBlank(publicKey)) { + throw new IllegalArgumentException("RSA需要传入公钥进行加密"); + } + RSA rsa = SecureUtil.rsa(null, publicKey); + return rsa.encryptHex(data, StandardCharsets.UTF_8, KeyType.PublicKey); + } + /** * rsa私钥解密 * diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java index 0f57122eb..72c2f939b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StreamUtils.java @@ -30,7 +30,6 @@ public static List filter(Collection collection, Predicate function if (CollUtil.isEmpty(collection)) { return CollUtil.newArrayList(); } - // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 return collection.stream().filter(function).collect(Collectors.toList()); } @@ -71,7 +70,6 @@ public static List sorted(Collection collection, Comparator compari if (CollUtil.isEmpty(collection)) { return CollUtil.newArrayList(); } - // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 return collection.stream().filter(Objects::nonNull).sorted(comparing).collect(Collectors.toList()); } @@ -190,7 +188,6 @@ public static List toList(Collection collection, Function fun .stream() .map(function) .filter(Objects::nonNull) - // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 .collect(Collectors.toList()); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 8459e1478..78cf0e72d 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -196,10 +196,8 @@ public static void exportExcel(List list, String sheetName, Class claz // 合并处理器 builder.registerWriteHandler(new CellMergeStrategy(list, true)); } - if (CollUtil.isNotEmpty(options)) { - // 添加下拉框操作 - builder.registerWriteHandler(new ExcelDownHandler(options)); - } + // 添加下拉框操作 + builder.registerWriteHandler(new ExcelDownHandler(options)); builder.doWrite(list); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java index 7a4bce4b3..842e4565b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/redis/QueueUtils.java @@ -131,6 +131,32 @@ public static boolean addPriorityQueueObject(String queueName, T data) { return priorityBlockingQueue.offer(data); } + /** + * 优先队列获取一个队列数据 没有数据返回 null(不支持延迟队列) + * + * @param queueName 队列名 + */ + public static T getPriorityQueueObject(String queueName) { + RPriorityBlockingQueue queue = CLIENT.getPriorityBlockingQueue(queueName); + return queue.poll(); + } + + /** + * 优先队列删除队列数据(不支持延迟队列) + */ + public static boolean removePriorityQueueObject(String queueName, T data) { + RPriorityBlockingQueue queue = CLIENT.getPriorityBlockingQueue(queueName); + return queue.remove(data); + } + + /** + * 优先队列销毁队列 所有阻塞监听 报错(不支持延迟队列) + */ + public static boolean destroyPriorityQueue(String queueName) { + RPriorityBlockingQueue queue = CLIENT.getPriorityBlockingQueue(queueName); + return queue.delete(); + } + /** * 尝试设置 有界队列 容量 用于限制数量 * @@ -169,6 +195,32 @@ public static boolean addBoundedQueueObject(String queueName, T data) { return boundedBlockingQueue.offer(data); } + /** + * 有界队列获取一个队列数据 没有数据返回 null(不支持延迟队列) + * + * @param queueName 队列名 + */ + public static T getBoundedQueueObject(String queueName) { + RBoundedBlockingQueue queue = CLIENT.getBoundedBlockingQueue(queueName); + return queue.poll(); + } + + /** + * 有界队列删除队列数据(不支持延迟队列) + */ + public static boolean removeBoundedQueueObject(String queueName, T data) { + RBoundedBlockingQueue queue = CLIENT.getBoundedBlockingQueue(queueName); + return queue.remove(data); + } + + /** + * 有界队列销毁队列 所有阻塞监听 报错(不支持延迟队列) + */ + public static boolean destroyBoundedQueue(String queueName) { + RBoundedBlockingQueue queue = CLIENT.getBoundedBlockingQueue(queueName); + return queue.delete(); + } + /** * 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 等) */ diff --git a/ruoyi-demo/pom.xml b/ruoyi-demo/pom.xml index a1d235eaa..ff8d869aa 100644 --- a/ruoyi-demo/pom.xml +++ b/ruoyi-demo/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java index 7342cba98..7da724ac6 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisCacheController.java @@ -34,7 +34,7 @@ public class RedisCacheController { * 如果没有,就调用方法,然后把结果缓存起来 * 这个注解「一般用在查询方法上」 *

- * 重点说明: 缓存注解严谨与其他筛选数据功能一起使用 + * 重点说明: 缓存注解严禁与其他筛选数据功能一起使用 * 例如: 数据权限注解 会造成 缓存击穿 与 数据不一致问题 *

* cacheNames 命名规则 查看 {@link CacheNames} 注释 支持多参数 diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/BoundedQueueController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/BoundedQueueController.java index 968a4193f..584111415 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/BoundedQueueController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/BoundedQueueController.java @@ -35,7 +35,7 @@ public class BoundedQueueController { @GetMapping("/add") public R add(String queueName, int capacity) { // 用完了一定要销毁 否则会一直存在 - boolean b = QueueUtils.destroyQueue(queueName); + boolean b = QueueUtils.destroyBoundedQueue(queueName); log.info("通道: {} , 删除: {}", queueName, b); // 初始化设置一次即可 if (QueueUtils.trySetBoundedQueueCapacity(queueName, capacity)) { @@ -64,7 +64,7 @@ public R add(String queueName, int capacity) { @GetMapping("/remove") public R remove(String queueName) { String data = "data-" + 5; - if (QueueUtils.removeQueueObject(queueName, data)) { + if (QueueUtils.removeBoundedQueueObject(queueName, data)) { log.info("通道: {} , 删除数据: {}", queueName, data); } else { return R.fail("操作失败"); @@ -81,7 +81,7 @@ public R remove(String queueName) { public R get(String queueName) { String data; do { - data = QueueUtils.getQueueObject(queueName); + data = QueueUtils.getBoundedQueueObject(queueName); log.info("通道: {} , 获取数据: {}", queueName, data); } while (data != null); return R.ok("操作成功"); diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/PriorityQueueController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/PriorityQueueController.java index 4a60232c7..0bc37d971 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/PriorityQueueController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/queue/PriorityQueueController.java @@ -34,7 +34,7 @@ public class PriorityQueueController { @GetMapping("/add") public R add(String queueName) { // 用完了一定要销毁 否则会一直存在 - boolean b = QueueUtils.destroyQueue(queueName); + boolean b = QueueUtils.destroyPriorityQueue(queueName); log.info("通道: {} , 删除: {}", queueName, b); for (int i = 0; i < 10; i++) { @@ -63,7 +63,7 @@ public R remove(String queueName, String name, Integer orderNum) { PriorityDemo data = new PriorityDemo(); data.setName(name); data.setOrderNum(orderNum); - if (QueueUtils.removeQueueObject(queueName, data)) { + if (QueueUtils.removePriorityQueueObject(queueName, data)) { log.info("通道: {} , 删除数据: {}", queueName, data); } else { return R.fail("操作失败"); @@ -80,7 +80,7 @@ public R remove(String queueName, String name, Integer orderNum) { public R get(String queueName) { PriorityDemo data; do { - data = QueueUtils.getQueueObject(queueName); + data = QueueUtils.getPriorityQueueObject(queueName); log.info("通道: {} , 获取数据: {}", queueName, data); } while (data != null); return R.ok("操作成功"); diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestDemoMapper.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestDemoMapper.java index 11a3d50e2..6d3a47fe7 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestDemoMapper.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestDemoMapper.java @@ -33,7 +33,7 @@ public interface TestDemoMapper extends BaseMapperPlus> P selectPage(P page, @Param(Constants.WRAPPER) Wrapper queryWrapper); + List selectList(IPage page, @Param(Constants.WRAPPER) Wrapper queryWrapper); @Override @DataPermission({ diff --git a/ruoyi-extend/pom.xml b/ruoyi-extend/pom.xml index 3fc1c3722..6f35db8af 100644 --- a/ruoyi-extend/pom.xml +++ b/ruoyi-extend/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 ruoyi-extend diff --git a/ruoyi-extend/ruoyi-monitor-admin/pom.xml b/ruoyi-extend/ruoyi-monitor-admin/pom.xml index 7f614985b..b06929f55 100644 --- a/ruoyi-extend/ruoyi-monitor-admin/pom.xml +++ b/ruoyi-extend/ruoyi-monitor-admin/pom.xml @@ -5,7 +5,7 @@ ruoyi-extend com.ruoyi - 4.8.0 + 4.8.1 4.0.0 jar diff --git a/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml b/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml index 558c3b067..85b050b71 100644 --- a/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml +++ b/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml @@ -4,7 +4,7 @@ ruoyi-extend com.ruoyi - 4.8.0 + 4.8.1 ruoyi-xxl-job-admin jar diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml index 4d821f328..1bbb43ab6 100644 --- a/ruoyi-framework/pom.xml +++ b/ruoyi-framework/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java index b45eace4b..5c8df8ab6 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java @@ -51,7 +51,7 @@ public void addInterceptors(InterceptorRegistry registry) { // 有效率影响 用于临时测试 // if (log.isDebugEnabled()) { // log.debug("剩余有效时间: {}", StpUtil.getTokenTimeout()); - // log.debug("临时有效时间: {}", StpUtil.getTokenActivityTimeout()); + // log.debug("临时有效时间: {}", StpUtil.getTokenActiveTimeout()); // } }); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java index 90b313340..65624a87f 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisDecryptInterceptor.java @@ -1,6 +1,7 @@ package com.ruoyi.framework.encrypt; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; import com.ruoyi.common.annotation.EncryptField; import com.ruoyi.common.encrypt.EncryptContext; @@ -76,7 +77,7 @@ private void decryptHandler(Object sourceObject) { Set fields = encryptorManager.getFieldCache(sourceObject.getClass()); try { for (Field field : fields) { - field.set(sourceObject, this.decryptField(String.valueOf(field.get(sourceObject)), field)); + field.set(sourceObject, this.decryptField(Convert.toStr(field.get(sourceObject)), field)); } } catch (Exception e) { log.error("处理解密字段时出错", e); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java index f5ffb2b12..ec4243282 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/encrypt/MybatisEncryptInterceptor.java @@ -1,6 +1,7 @@ package com.ruoyi.framework.encrypt; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; import com.ruoyi.common.annotation.EncryptField; import com.ruoyi.common.encrypt.EncryptContext; @@ -86,7 +87,7 @@ private void encryptHandler(Object sourceObject) { Set fields = encryptorManager.getFieldCache(sourceObject.getClass()); try { for (Field field : fields) { - field.set(sourceObject, this.encryptField(String.valueOf(field.get(sourceObject)), field)); + field.set(sourceObject, this.encryptField(Convert.toStr(field.get(sourceObject)), field)); } } catch (Exception e) { log.error("处理加密字段时出错", e); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java index f1cbff22a..e44ce90c9 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -8,6 +8,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.exception.DemoModeException; import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.StreamUtils; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.MyBatisSystemException; @@ -105,18 +106,27 @@ public R handleCannotFindDataSourceException(MyBatisSystemException e, Htt */ @ExceptionHandler(ServiceException.class) public R handleServiceException(ServiceException e, HttpServletRequest request) { - log.error(e.getMessage(), e); + log.error(e.getMessage()); Integer code = e.getCode(); return ObjectUtil.isNotNull(code) ? R.fail(code, e.getMessage()) : R.fail(e.getMessage()); } + /** + * 业务异常 + */ + @ExceptionHandler(BaseException.class) + public R handleBaseException(BaseException e, HttpServletRequest request) { + log.error(e.getMessage()); + return R.fail(e.getMessage()); + } + /** * 请求路径中缺少必需的路径变量 */ @ExceptionHandler(MissingPathVariableException.class) public R handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e); + log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI); return R.fail(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName())); } @@ -126,7 +136,7 @@ public R handleMissingPathVariableException(MissingPathVariableException e @ExceptionHandler(MethodArgumentTypeMismatchException.class) public R handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e); + log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI); return R.fail(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue())); } @@ -155,7 +165,7 @@ public R handleException(Exception e, HttpServletRequest request) { */ @ExceptionHandler(BindException.class) public R handleBindException(BindException e) { - log.error(e.getMessage(), e); + log.error(e.getMessage()); String message = StreamUtils.join(e.getAllErrors(), DefaultMessageSourceResolvable::getDefaultMessage, ", "); return R.fail(message); } @@ -165,7 +175,7 @@ public R handleBindException(BindException e) { */ @ExceptionHandler(ConstraintViolationException.class) public R constraintViolationException(ConstraintViolationException e) { - log.error(e.getMessage(), e); + log.error(e.getMessage()); String message = StreamUtils.join(e.getConstraintViolations(), ConstraintViolation::getMessage, ", "); return R.fail(message); } @@ -175,7 +185,7 @@ public R constraintViolationException(ConstraintViolationException e) { */ @ExceptionHandler(MethodArgumentNotValidException.class) public R handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { - log.error(e.getMessage(), e); + log.error(e.getMessage()); String message = e.getBindingResult().getFieldError().getDefaultMessage(); return R.fail(message); } diff --git a/ruoyi-generator/pom.xml b/ruoyi-generator/pom.xml index 4b89616b4..a5cbbb728 100644 --- a/ruoyi-generator/pom.xml +++ b/ruoyi-generator/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-generator/src/main/resources/vm/java/vo.java.vm b/ruoyi-generator/src/main/resources/vm/java/vo.java.vm index fb8b0a98c..f6062ff9c 100644 --- a/ruoyi-generator/src/main/resources/vm/java/vo.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/vo.java.vm @@ -10,7 +10,7 @@ import com.ruoyi.common.convert.ExcelDictConvert; import lombok.Data; import java.util.Date; - +import java.io.Serializable; /** * ${functionName}视图对象 ${tableName} @@ -20,7 +20,7 @@ import java.util.Date; */ @Data @ExcelIgnoreUnannotated -public class ${ClassName}Vo { +public class ${ClassName}Vo implements Serializable { private static final long serialVersionUID = 1L; diff --git a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm index fd07e4d72..601ee583c 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -434,7 +434,7 @@ export default { this.reset(); this.getTreeselect(); if (row != null && row.${treeCode}) { - this.form.${treeParentCode} = row.${treeCode}; + this.form.${treeParentCode} = row.${treeParentCode}; } else { this.form.${treeParentCode} = 0; } diff --git a/ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm index 4f109531b..79a17b210 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/v3/index-tree.vue.vm @@ -398,7 +398,7 @@ function handleAdd(row) { reset(); getTreeselect(); if (row != null && row.${treeCode}) { - form.value.${treeParentCode} = row.${treeCode}; + form.value.${treeParentCode} = row.${treeParentCode}; } else { form.value.${treeParentCode} = 0; } diff --git a/ruoyi-job/pom.xml b/ruoyi-job/pom.xml index b97339484..45dd25f71 100644 --- a/ruoyi-job/pom.xml +++ b/ruoyi-job/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 jar diff --git a/ruoyi-oss/pom.xml b/ruoyi-oss/pom.xml index 715eef5c5..4f3c6ee80 100644 --- a/ruoyi-oss/pom.xml +++ b/ruoyi-oss/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-sms/pom.xml b/ruoyi-sms/pom.xml index 33dc69250..8d61a304e 100644 --- a/ruoyi-sms/pom.xml +++ b/ruoyi-sms/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 7db3a02a0..2300126e7 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -5,7 +5,7 @@ ruoyi-vue-plus com.ruoyi - 4.8.0 + 4.8.1 4.0.0 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java index e2b3c0190..d741cdf9e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -19,7 +19,8 @@ public interface SysRoleMapper extends BaseMapperPlus { @DataPermission({ - @DataColumn(key = "deptName", value = "d.dept_id") + @DataColumn(key = "deptName", value = "d.dept_id"), + @DataColumn(key = "userName", value = "us.user_id") }) Page selectPageRoleList(@Param("page") Page page, @Param(Constants.WRAPPER) Wrapper queryWrapper); @@ -30,7 +31,8 @@ public interface SysRoleMapper extends BaseMapperPlus selectRoleList(@Param(Constants.WRAPPER) Wrapper queryWrapper); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java index 1fa41b805..c2627445b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java @@ -143,9 +143,13 @@ public String xcxLogin(String xcxCode) { public void logout() { try { LoginUser loginUser = LoginHelper.getLoginUser(); - StpUtil.logout(); recordLogininfor(loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success")); } catch (NotLoginException ignored) { + } finally { + try { + StpUtil.logout(); + } catch (NotLoginException ignored) { + } } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 8af6cabdb..aba3d99e0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -72,6 +72,8 @@ public List selectDeptList(SysDept dept) { */ @Override public List> selectDeptTreeList(SysDept dept) { + // 只查询未禁用部门 + dept.setStatus(UserConstants.DEPT_NORMAL); List depts = this.selectDeptList(dept); return buildDeptTreeSelect(depts); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index 79edef7f9..f41a2d01d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -147,7 +147,7 @@ public int deletePostByIds(Long[] postIds) { for (Long postId : postIds) { SysPost post = selectPostById(postId); if (countUserPostById(postId) > 0) { - throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName())); + throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName())); } } return baseMapper.deleteBatchIds(Arrays.asList(postIds)); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 84e762175..4f05d5ee7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -268,6 +268,9 @@ public int updateRole(SysRole role) { */ @Override public int updateRoleStatus(SysRole role) { + if (UserConstants.ROLE_DISABLE.equals(role.getStatus()) && this.countUserRoleByRoleId(role.getRoleId()) > 0) { + throw new ServiceException("角色已分配,不能禁用!"); + } return baseMapper.updateById(role); } @@ -360,7 +363,7 @@ public int deleteRoleByIds(Long[] roleIds) { checkRoleAllowed(role); checkRoleDataScope(roleId); if (countUserRoleByRoleId(roleId) > 0) { - throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); + throw new ServiceException(String.format("%1$s已分配,不能删除!", role.getRoleName())); } } List ids = Arrays.asList(roleIds); diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index 90dff5051..c6464cb84 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -36,6 +36,7 @@ from sys_role r left join sys_user_role sur on sur.role_id = r.role_id left join sys_user u on u.user_id = sur.user_id + left join sys_user us on us.user_name = r.create_by left join sys_dept d on u.dept_id = d.dept_id diff --git a/ruoyi-ui-vue3/package.json b/ruoyi-ui-vue3/package.json index b570f1c64..bd03f605b 100644 --- a/ruoyi-ui-vue3/package.json +++ b/ruoyi-ui-vue3/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi-vue-plus", - "version": "4.8.0", + "version": "4.8.1", "description": "RuoYi-Vue-Plus后台管理系统", "author": "LionLi", "license": "MIT", @@ -38,6 +38,6 @@ "vite": "3.2.3", "vite-plugin-compression": "0.5.1", "vite-plugin-svg-icons": "2.0.1", - "vite-plugin-vue-setup-extend": "0.4.0" + "unplugin-vue-setup-extend-plus": "0.4.9" } } diff --git a/ruoyi-ui-vue3/src/components/DictTag/index.vue b/ruoyi-ui-vue3/src/components/DictTag/index.vue index 3b9511796..7d0888cf0 100644 --- a/ruoyi-ui-vue3/src/components/DictTag/index.vue +++ b/ruoyi-ui-vue3/src/components/DictTag/index.vue @@ -3,7 +3,7 @@