From 19924cd184908cbca2f7e8670ed5a5dfb88aac01 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 3 Jun 2021 13:24:29 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=B3=E9=97=ADconfi?= =?UTF-8?q?rm=E6=8F=90=E7=A4=BA=E6=A1=86=E6=8E=A7=E5=88=B6=E5=8F=B0?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm | 2 +- ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 4 ++-- ruoyi-ui/src/layout/components/Navbar.vue | 2 +- ruoyi-ui/src/utils/request.js | 2 +- ruoyi-ui/src/views/monitor/job/index.vue | 6 +++--- ruoyi-ui/src/views/monitor/job/log.vue | 6 +++--- ruoyi-ui/src/views/monitor/logininfor/index.vue | 6 +++--- ruoyi-ui/src/views/monitor/online/index.vue | 2 +- ruoyi-ui/src/views/monitor/operlog/index.vue | 6 +++--- ruoyi-ui/src/views/system/config/index.vue | 4 ++-- ruoyi-ui/src/views/system/dept/index.vue | 2 +- ruoyi-ui/src/views/system/dict/data.vue | 4 ++-- ruoyi-ui/src/views/system/dict/index.vue | 4 ++-- ruoyi-ui/src/views/system/menu/index.vue | 4 ++-- ruoyi-ui/src/views/system/notice/index.vue | 2 +- ruoyi-ui/src/views/system/post/index.vue | 4 ++-- ruoyi-ui/src/views/system/role/index.vue | 4 ++-- ruoyi-ui/src/views/system/user/index.vue | 4 ++-- ruoyi-ui/src/views/tool/gen/index.vue | 4 ++-- 19 files changed, 36 insertions(+), 36 deletions(-) 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 6d67c2e0d..ab8706818 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 @@ -532,7 +532,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 501f2f634..9fd6adf5f 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -590,7 +590,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, #if($table.sub) /** ${subTable.functionName}序号 */ @@ -639,7 +639,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index 18c89a0ea..67a53ab67 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -104,7 +104,7 @@ export default { this.$store.dispatch('LogOut').then(() => { location.href = '/index'; }) - }) + }).catch(() => {}); } } } diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index ae89f24de..a510d2daf 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -63,7 +63,7 @@ service.interceptors.response.use(res => { store.dispatch('LogOut').then(() => { location.href = '/index'; }) - }) + }).catch(() => {}); } else if (code === 500) { Message({ message: msg, diff --git a/ruoyi-ui/src/views/monitor/job/index.vue b/ruoyi-ui/src/views/monitor/job/index.vue index 30115e336..c8fcd6dcc 100644 --- a/ruoyi-ui/src/views/monitor/job/index.vue +++ b/ruoyi-ui/src/views/monitor/job/index.vue @@ -410,7 +410,7 @@ export default { return runJob(row.jobId, row.jobGroup); }).then(() => { this.msgSuccess("执行成功"); - }) + }).catch(() => {}); }, /** 任务详细信息 */ handleView(row) { @@ -471,7 +471,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -486,7 +486,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/job/log.vue b/ruoyi-ui/src/views/monitor/job/log.vue index 121dde828..fa5976fea 100644 --- a/ruoyi-ui/src/views/monitor/job/log.vue +++ b/ruoyi-ui/src/views/monitor/job/log.vue @@ -269,7 +269,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { @@ -282,7 +282,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("清空成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -297,7 +297,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/logininfor/index.vue b/ruoyi-ui/src/views/monitor/logininfor/index.vue index 4ac9a78d9..c6b38c747 100644 --- a/ruoyi-ui/src/views/monitor/logininfor/index.vue +++ b/ruoyi-ui/src/views/monitor/logininfor/index.vue @@ -202,7 +202,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { @@ -215,7 +215,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("清空成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -230,7 +230,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/online/index.vue b/ruoyi-ui/src/views/monitor/online/index.vue index 4233de5c6..baec6e0b4 100644 --- a/ruoyi-ui/src/views/monitor/online/index.vue +++ b/ruoyi-ui/src/views/monitor/online/index.vue @@ -120,7 +120,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("强退成功"); - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/monitor/operlog/index.vue b/ruoyi-ui/src/views/monitor/operlog/index.vue index d1505c663..7909c8514 100644 --- a/ruoyi-ui/src/views/monitor/operlog/index.vue +++ b/ruoyi-ui/src/views/monitor/operlog/index.vue @@ -290,7 +290,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 清空按钮操作 */ handleClean() { @@ -303,7 +303,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("清空成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -318,7 +318,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue index d6275f532..d942f8ff1 100644 --- a/ruoyi-ui/src/views/system/config/index.vue +++ b/ruoyi-ui/src/views/system/config/index.vue @@ -338,7 +338,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -353,7 +353,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); }, /** 刷新缓存按钮操作 */ handleRefreshCache() { diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue index 98d57fb3e..2d58f6424 100644 --- a/ruoyi-ui/src/views/system/dept/index.vue +++ b/ruoyi-ui/src/views/system/dept/index.vue @@ -310,7 +310,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/dict/data.vue b/ruoyi-ui/src/views/system/dict/data.vue index 720ed7e7a..4b5dd29e2 100644 --- a/ruoyi-ui/src/views/system/dict/data.vue +++ b/ruoyi-ui/src/views/system/dict/data.vue @@ -337,7 +337,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -352,7 +352,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/dict/index.vue b/ruoyi-ui/src/views/system/dict/index.vue index 545912a2e..a52df7bf6 100644 --- a/ruoyi-ui/src/views/system/dict/index.vue +++ b/ruoyi-ui/src/views/system/dict/index.vue @@ -342,7 +342,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -357,7 +357,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); }, /** 刷新缓存按钮操作 */ handleRefreshCache() { diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index cee61b737..507ae509a 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -163,7 +163,7 @@ - + @@ -393,7 +393,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/notice/index.vue b/ruoyi-ui/src/views/system/notice/index.vue index 7da479804..6dbbfcb0a 100644 --- a/ruoyi-ui/src/views/system/notice/index.vue +++ b/ruoyi-ui/src/views/system/notice/index.vue @@ -336,7 +336,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/post/index.vue b/ruoyi-ui/src/views/system/post/index.vue index ce48b03b2..0b10126bb 100644 --- a/ruoyi-ui/src/views/system/post/index.vue +++ b/ruoyi-ui/src/views/system/post/index.vue @@ -309,7 +309,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -324,7 +324,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue index 4892615c3..8f0d43330 100644 --- a/ruoyi-ui/src/views/system/role/index.vue +++ b/ruoyi-ui/src/views/system/role/index.vue @@ -593,7 +593,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -608,7 +608,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); } } }; diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 2e55120cd..471a66cc4 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -631,7 +631,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); }, /** 导出按钮操作 */ handleExport() { @@ -646,7 +646,7 @@ export default { }).then(response => { this.download(response.msg); this.exportLoading = false; - }) + }).catch(() => {}); }, /** 导入按钮操作 */ handleImport() { diff --git a/ruoyi-ui/src/views/tool/gen/index.vue b/ruoyi-ui/src/views/tool/gen/index.vue index 113f35405..348543e2d 100644 --- a/ruoyi-ui/src/views/tool/gen/index.vue +++ b/ruoyi-ui/src/views/tool/gen/index.vue @@ -283,7 +283,7 @@ export default { return synchDb(tableName); }).then(() => { this.msgSuccess("同步成功"); - }) + }).catch(() => {}); }, /** 打开导入表弹窗 */ openImportTable() { @@ -333,7 +333,7 @@ export default { }).then(() => { this.getList(); this.msgSuccess("删除成功"); - }) + }).catch(() => {}); } } }; From b7446f8d0ffd282d7f22d775e896d066219856a4 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 3 Jun 2021 13:26:09 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=8F=E9=85=8D=E7=BD=AE=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/components/Editor/index.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ruoyi-ui/src/components/Editor/index.vue b/ruoyi-ui/src/components/Editor/index.vue index 640049ca0..ad4da7eee 100644 --- a/ruoyi-ui/src/components/Editor/index.vue +++ b/ruoyi-ui/src/components/Editor/index.vue @@ -75,7 +75,7 @@ export default { [{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色 [{ align: [] }], // 对齐方式 ["clean"], // 清除文本格式 - ["link", "image"] // 链接、图片 + ["link", "image", "video"] // 链接、图片、视频 ], }, placeholder: "请输入内容", @@ -158,6 +158,7 @@ export default { }); }, handleUploadSuccess(res, file) { + console.info(file); // 获取富文本组件实例 let quill = this.Quill; // 如果上传成功 From f087b37cb32b84ae841fc409ea00ed2f729d9c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 4 Jun 2021 16:46:28 +0800 Subject: [PATCH 03/23] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E9=94=81?= =?UTF-8?q?=E5=88=87=E9=9D=A2=E4=BB=A3=E7=A0=81=20key=E5=88=B0=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/constant/Constants.java | 7 ++++++- .../ruoyi/framework/aspectj/RedisLockAspect.java | 13 +++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index 534291991..137969a8b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -2,7 +2,7 @@ package com.ruoyi.common.constant; /** * 通用常量信息 - * + * * @author ruoyi */ public class Constants @@ -126,4 +126,9 @@ public class Constants * 资源映射路径 前缀 */ public static final String RESOURCE_PREFIX = "/profile"; + + /** + * 资源映射路径 前缀 + */ + public static final String REDIS_LOCK_KEY = "redis_lock:"; } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java index 0ff695f8b..0af3844ff 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java @@ -2,6 +2,7 @@ package com.ruoyi.framework.aspectj; import com.ruoyi.common.annotation.RedisLock; +import com.ruoyi.common.constant.Constants; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -34,8 +35,6 @@ public class RedisLockAspect { @Autowired private RedissonClient redissonClient; - private static final String LOCK_TITLE = "RedisLock_"; - @Pointcut("@annotation(com.ruoyi.common.annotation.RedisLock)") public void annotationPointcut() { } @@ -67,6 +66,8 @@ public class RedisLockAspect { throw new RuntimeException("redis分布式锁注解参数异常", e); } + // 声明锁名称 + key = Constants.REDIS_LOCK_KEY + key; Object res; try { if (acquire(key, expireTime, TimeUnit.SECONDS)) { @@ -136,8 +137,6 @@ public class RedisLockAspect { * 加锁(RLock)带超时时间的 */ private boolean acquire(String key, long expire, TimeUnit expireUnit) { - //声明key对象 - key = LOCK_TITLE + key; try { //获取锁对象 RLock mylock = redissonClient.getLock(key); @@ -155,13 +154,11 @@ public class RedisLockAspect { * 锁的释放 */ private void release(String lockName) { - //必须是和加锁时的同一个key - String key = LOCK_TITLE + lockName; //获取所对象 - RLock mylock = redissonClient.getLock(key); + RLock mylock = redissonClient.getLock(lockName); //释放锁(解锁) mylock.unlock(); - log.info("unlock => key : " + key + " , ThreadName : " + Thread.currentThread().getName()); + log.info("unlock => key : " + lockName + " , ThreadName : " + Thread.currentThread().getName()); } } From 00d024ff86ad5bb754961a988032e0a68020c167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 4 Jun 2021 18:11:46 +0800 Subject: [PATCH 04/23] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E4=B8=8A=E4=BC=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/utils/file/FileUploadUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index cb4a225fb..22d53c7fa 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -1,5 +1,6 @@ package com.ruoyi.common.utils.file; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.Validator; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; @@ -113,7 +114,8 @@ public class FileUploadUtils String fileName = extractFilename(file); File desc = getAbsoluteFile(baseDir, fileName); - file.transferTo(desc); + desc = FileUtil.touch(desc); + FileUtil.writeFromStream(file.getInputStream(), desc); String pathFileName = getPathFileName(baseDir, fileName); return pathFileName; } From fd33fe869dfad2364503f13bc90a239fccba5dc3 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 8 Jun 2021 16:27:24 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=95=B0=E6=8D=AE=E8=8C=83=E5=9B=B4=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E7=BC=BA=E5=B0=91=E4=BB=85=E6=9C=AC=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/core/domain/entity/SysRole.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java index b122538b6..f28a063a6 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java @@ -33,8 +33,8 @@ public class SysRole extends BaseEntity @Excel(name = "角色排序") private String roleSort; - /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限) */ - @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限") + /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ + @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") private String dataScope; /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ From c16ee7fc2c6cbda1cc8e87f21f1c29b2cb5948cd Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 8 Jun 2021 16:34:36 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E5=8D=87=E7=BA=A7swagger=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=ACv3.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 41 +++++++------------ ruoyi-admin/pom.xml | 20 ++------- .../ruoyi/web/core/config/SwaggerConfig.java | 12 +++--- ruoyi-ui/src/components/Editor/index.vue | 1 - ruoyi-ui/src/views/tool/swagger/index.vue | 2 +- 5 files changed, 25 insertions(+), 51 deletions(-) diff --git a/pom.xml b/pom.xml index 640387a12..ebf3f28f6 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 3.1.1 1.2.6 1.21 - 2.9.2 + 3.0.0 2.3.2 2.1.4 1.3.0 @@ -48,7 +48,7 @@ import - + com.alibaba druid-spring-boot-starter @@ -95,38 +95,25 @@ ${jna.version} - + io.springfox - springfox-swagger2 - ${swagger.version} - - - io.swagger - swagger-annotations - - - io.swagger - swagger-models - - + springfox-boot-starter + 3.0.0 + + io.swagger + swagger-models + - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - + commons-io commons-io ${commons.io.version} - + commons-fileupload commons-fileupload @@ -140,7 +127,7 @@ ${poi.version} - + org.apache.velocity velocity @@ -167,14 +154,14 @@ ${fastjson.version} - + io.jsonwebtoken jjwt ${jwt.version} - + com.github.penggle kaptcha diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index d58ad5bdf..25016b056 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -24,29 +24,17 @@ true - + io.springfox - springfox-swagger2 - - - - - io.swagger - swagger-annotations - 1.5.21 + springfox-boot-starter + io.swagger swagger-models - 1.5.21 - - - - - io.springfox - springfox-swagger-ui + 1.6.2 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 86acc3f0b..02227fd27 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.ruoyi.common.config.RuoYiConfig; import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; @@ -16,10 +17,10 @@ import springfox.documentation.service.ApiKey; import springfox.documentation.service.AuthorizationScope; import springfox.documentation.service.Contact; import springfox.documentation.service.SecurityReference; +import springfox.documentation.service.SecurityScheme; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; /** * Swagger2的接口配置 @@ -27,7 +28,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; * @author ruoyi */ @Configuration -@EnableSwagger2 public class SwaggerConfig { /** 系统基础配置 */ @@ -71,10 +71,10 @@ public class SwaggerConfig /** * 安全模式,这里指定token通过Authorization头请求头传递 */ - private List securitySchemes() + private List securitySchemes() { - List apiKeyList = new ArrayList(); - apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); + List apiKeyList = new ArrayList(); + apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); return apiKeyList; } @@ -87,7 +87,7 @@ public class SwaggerConfig securityContexts.add( SecurityContext.builder() .securityReferences(defaultAuth()) - .forPaths(PathSelectors.regex("^(?!auth).*$")) + .operationSelector(o -> o.requestMappingPattern().matches("/.*")) .build()); return securityContexts; } diff --git a/ruoyi-ui/src/components/Editor/index.vue b/ruoyi-ui/src/components/Editor/index.vue index ad4da7eee..d63a48d12 100644 --- a/ruoyi-ui/src/components/Editor/index.vue +++ b/ruoyi-ui/src/components/Editor/index.vue @@ -158,7 +158,6 @@ export default { }); }, handleUploadSuccess(res, file) { - console.info(file); // 获取富文本组件实例 let quill = this.Quill; // 如果上传成功 diff --git a/ruoyi-ui/src/views/tool/swagger/index.vue b/ruoyi-ui/src/views/tool/swagger/index.vue index 624b59a2d..8db31808e 100644 --- a/ruoyi-ui/src/views/tool/swagger/index.vue +++ b/ruoyi-ui/src/views/tool/swagger/index.vue @@ -8,7 +8,7 @@ export default { name: "Swagger", data() { return { - src: process.env.VUE_APP_BASE_API + "/swagger-ui.html", + src: process.env.VUE_APP_BASE_API + "/swagger-ui/index.html", height: document.documentElement.clientHeight - 94.5 + "px;", loading: true }; From 2ace3257f95eee1f8734754f488412b6a266d928 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 9 Jun 2021 20:07:36 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E5=8D=87=E7=BA=A7swagger=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=ACv3.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 12 +++++++----- .../com/ruoyi/web/core/config/SwaggerConfig.java | 2 +- .../com/ruoyi/framework/config/ResourcesConfig.java | 3 +-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index ebf3f28f6..ff0ebab75 100644 --- a/pom.xml +++ b/pom.xml @@ -99,11 +99,13 @@ io.springfox springfox-boot-starter - 3.0.0 - - io.swagger - swagger-models - + ${swagger.version} + + + io.swagger + swagger-models + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 02227fd27..0b9424507 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -48,7 +48,7 @@ public class SwaggerConfig @Bean public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2) + return new Docket(DocumentationType.OAS_30) // 是否启用Swagger .enable(enabled) // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java index 1082ea51c..9cd523e76 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java @@ -31,8 +31,7 @@ public class ResourcesConfig implements WebMvcConfigurer registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"); /** swagger配置 */ - registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); } /** From f45b50a796e1db1238b1147f11c2f96c0d405e48 Mon Sep 17 00:00:00 2001 From: sxq <812980466@qq.com> Date: Tue, 8 Jun 2021 14:55:55 +0800 Subject: [PATCH 08/23] =?UTF-8?q?update=20redis=E9=94=81=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/redis/RedisLockManager.java | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java new file mode 100644 index 000000000..fb665a995 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java @@ -0,0 +1,132 @@ +package com.ruoyi.common.core.redis; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.lang.Validator; +import cn.hutool.core.util.StrUtil; +import org.redisson.api.RCountDownLatch; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +/** + * redis 锁管理类 + * + * @author shenxinquan + */ +@Component +public class RedisLockManager { + + @Autowired + private RedissonClient redissonClient; + + private final ThreadLocal threadLocal = new ThreadLocal<>(); + + /** + * 获取锁(不用设置超时时间,一直等待) + */ + public boolean getLock(String key) { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + RLock lock = redissonClient.getLock(key); + threadLocal.set(lock); + return lock.tryLock(); + } + + /** + * 设置过期时间 + * + * @param key + * @param time 过期时间 + * @param expireUnit 时间单位 + */ + public boolean getLock(String key, long time, TimeUnit expireUnit) throws InterruptedException { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + Assert.isTrue(time > 0, "过期时间必须大于0"); + Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); + RLock lock = redissonClient.getLock(key); + threadLocal.set(lock); + return lock.tryLock(time, expireUnit); + } + + /** + * 设置过期时间 + * + * @param key + * @param waitTime 获取锁等待时间 + * @param leaseTime 保留锁的时间 + * @param expireUnit 时间单位 + * @throws InterruptedException + */ + public boolean getLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) throws InterruptedException { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + Assert.isTrue(waitTime > 0, "获取锁等待时间必须大于0"); + Assert.isTrue(leaseTime > 0, "保留锁的时间必须大于0"); + Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); + RLock lock = redissonClient.getLock(key); + threadLocal.set(lock); + return lock.tryLock(waitTime, leaseTime, expireUnit); + } + + /** + * 获取计数器锁 + * + * @param key + * @param count countDownLatch 的数量 + */ + public RCountDownLatch countDownLatch(String key, long count) { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + Assert.isTrue(count >= 0, "count数量必须大于等于0"); + RCountDownLatch rCountDownLatch = redissonClient.getCountDownLatch(key); + rCountDownLatch.trySetCount(count); + return rCountDownLatch; + } + + /** + * 获取公平锁 + * + * @param key + * @param waitTime 获取锁等待时间 + * @param leaseTime 持有锁的时间 + * @param expireUnit 时间单位 + * @return + * @throws InterruptedException + */ + public boolean getFairLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) throws InterruptedException { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + Assert.isTrue(waitTime > 0, "获取锁等待时间必须大于0"); + Assert.isTrue(leaseTime > 0, "保留锁的时间必须大于0"); + Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); + RLock lock = redissonClient.getFairLock(key); + threadLocal.set(lock); + return lock.tryLock(waitTime, leaseTime, expireUnit); + } + + /** + * 获取公平锁 + * + * @param key + * @param leaseTime 持有锁的时间 + * @param expireUnit 时间单位 + * @return + * @throws InterruptedException + */ + public boolean getFairLock(String key, long leaseTime, TimeUnit expireUnit) throws InterruptedException { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + Assert.isTrue(leaseTime > 0, "保留锁的时间必须大于0"); + Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); + RLock lock = redissonClient.getFairLock(key); + threadLocal.set(lock); + return lock.tryLock(leaseTime, expireUnit); + } + + /** + * 释放锁(统一释放) + */ + public void unLock() { + RLock lock = threadLocal.get(); + lock.unlock(); + threadLocal.remove(); + } +} From a6ba7d909329b8f2262b7014c1ffc7b0dde2a56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Wed, 9 Jun 2021 23:31:47 +0800 Subject: [PATCH 09/23] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96pr=20redis?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/RedisLockController.java | 34 ++++++++++++++++- .../framework/aspectj/RedisLockAspect.java | 38 +++---------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java index 7792784a1..40019fc27 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java @@ -2,26 +2,35 @@ package com.ruoyi.demo.controller; import com.ruoyi.common.annotation.RedisLock; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisLockManager; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.TimeUnit; + /** * 测试分布式锁的样例 * * @author shenxinquan */ +@Slf4j @RestController @RequestMapping("/demo/redisLock") public class RedisLockController { + @Autowired + private RedisLockManager redisLockManager; + /** * #p0 标识取第一个参数为redis锁的key */ - @GetMapping("/getLock") + @GetMapping("/testLock1") @RedisLock(expireTime = 10, key = "#p0") - public AjaxResult getLock(String key, String value) { + public AjaxResult testLock1(String key, String value) { try { // 同时请求排队 // Thread.sleep(5000); @@ -32,4 +41,25 @@ public class RedisLockController { } return AjaxResult.success("操作成功",value); } + + /** + * 测试锁工具类 + */ + @GetMapping("/testLock2") + public AjaxResult testLock(String key, Long time) { + try { + boolean flag = redisLockManager.getLock(key, time, TimeUnit.SECONDS); + if (flag) { + log.info("获取锁成功: " + key); + Thread.sleep(3000); + redisLockManager.unLock(); + log.info("释放锁成功: " + key); + } else { + log.error("获取锁失败: " + key); + } + } catch (InterruptedException e) { + log.error(e.getMessage()); + } + return AjaxResult.success(); + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java index 0af3844ff..9d3bc8d99 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java @@ -3,6 +3,7 @@ package com.ruoyi.framework.aspectj; import com.ruoyi.common.annotation.RedisLock; import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.redis.RedisLockManager; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -10,7 +11,6 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.redisson.api.RLock; -import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit; public class RedisLockAspect { @Autowired - private RedissonClient redissonClient; + private RedisLockManager redisLockManager; @Pointcut("@annotation(com.ruoyi.common.annotation.RedisLock)") public void annotationPointcut() { @@ -70,14 +70,16 @@ public class RedisLockAspect { key = Constants.REDIS_LOCK_KEY + key; Object res; try { - if (acquire(key, expireTime, TimeUnit.SECONDS)) { + if (redisLockManager.getLock(key, expireTime, TimeUnit.SECONDS)) { + log.info("lock => key : " + key + " , ThreadName : " + Thread.currentThread().getName()); try { res = joinPoint.proceed(); return res; } catch (Exception e) { throw new RuntimeException(e); } finally { - release(key); + redisLockManager.unLock(); + log.info("unlock => key : " + key + " , ThreadName : " + Thread.currentThread().getName()); } } else { throw new RuntimeException("redis分布式锁注解参数异常"); @@ -133,32 +135,4 @@ public class RedisLockAspect { return listPar; } - /** - * 加锁(RLock)带超时时间的 - */ - private boolean acquire(String key, long expire, TimeUnit expireUnit) { - try { - //获取锁对象 - RLock mylock = redissonClient.getLock(key); - //加锁,并且设置锁过期时间,防止死锁的产生 - mylock.tryLock(expire, expire, expireUnit); - } catch (InterruptedException e) { - return false; - } - log.info("lock => key : " + key + " , ThreadName : " + Thread.currentThread().getName()); - //加锁成功 - return true; - } - - /** - * 锁的释放 - */ - private void release(String lockName) { - //获取所对象 - RLock mylock = redissonClient.getLock(lockName); - //释放锁(解锁) - mylock.unlock(); - log.info("unlock => key : " + lockName + " , ThreadName : " + Thread.currentThread().getName()); - } - } From ceeac476ecbfb6397afa68d46a5fed2690c0b7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 00:04:19 +0800 Subject: [PATCH 10/23] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=98=B2=E9=87=8D=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/vm/java/controller.java.vm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index b40b497ad..900f51017 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -9,6 +9,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; +import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -28,7 +29,7 @@ import io.swagger.annotations.ApiOperation; /** * ${functionName}Controller - * + * * @author ${author} * @date ${datetime} */ @@ -87,6 +88,7 @@ public class ${ClassName}Controller extends BaseController { @ApiOperation("新增${functionName}") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") @Log(title = "${functionName}", businessType = BusinessType.INSERT) + @RepeatSubmit @PostMapping() public AjaxResult add(@Validated @RequestBody ${ClassName}AddBo bo) { return toAjax(i${ClassName}Service.insertByAddBo(bo) ? 1 : 0); @@ -98,6 +100,7 @@ public class ${ClassName}Controller extends BaseController { @ApiOperation("修改${functionName}") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") @Log(title = "${functionName}", businessType = BusinessType.UPDATE) + @RepeatSubmit @PutMapping() public AjaxResult edit(@Validated @RequestBody ${ClassName}EditBo bo) { return toAjax(i${ClassName}Service.updateByEditBo(bo) ? 1 : 0); From 524683eabdef0ec4a58e653c94063bf5d51d8e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 09:57:34 +0800 Subject: [PATCH 11/23] =?UTF-8?q?update=20swagger=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E4=B8=BA=203.0.0=20=E4=BD=BF=E7=94=A8=20OAS=5F30=20=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 13 ------------- ruoyi-common/pom.xml | 5 ----- .../com/ruoyi/framework/config/SwaggerConfig.java | 9 ++++----- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 6c2b99e6f..94ab8d5ce 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,6 @@ 3.1.1 1.2.6 3.0.2 - 1.5.22 1.2.76 4.1.2 1.7 @@ -58,18 +57,6 @@ com.github.xiaoymin knife4j-spring-boot-starter ${knife4j.version} - - - swagger-annotations - io.swagger - - - - - - io.swagger - swagger-annotations - ${swagger-annotations.version} diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 2c75fcd1b..c6275c250 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -136,11 +136,6 @@ knife4j-spring-boot-starter - - io.swagger - swagger-annotations - - org.springframework.boot spring-boot-starter-actuator diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java index 1a92ca088..7b5d95105 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java @@ -3,6 +3,7 @@ package com.ruoyi.framework.config; import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import com.ruoyi.framework.config.properties.SwaggerProperties; import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,7 +14,6 @@ import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.ArrayList; import java.util.List; @@ -24,7 +24,6 @@ import java.util.List; * @author Lion Li */ @Configuration -@EnableSwagger2 @EnableKnife4j public class SwaggerConfig { @@ -36,7 +35,7 @@ public class SwaggerConfig { */ @Bean public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2) + return new Docket(DocumentationType.OAS_30) .enable(swaggerProperties.getEnabled()) // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) .apiInfo(apiInfo()) @@ -60,7 +59,7 @@ public class SwaggerConfig { */ private List securitySchemes() { List apiKeyList = new ArrayList(); - apiKeyList.add(new ApiKey("Authorization", "Authorization", "header")); + apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); return apiKeyList; } @@ -72,7 +71,7 @@ public class SwaggerConfig { securityContexts.add( SecurityContext.builder() .securityReferences(defaultAuth()) - .forPaths(PathSelectors.regex("^(?!auth).*$")) + .operationSelector(o -> o.requestMappingPattern().matches("/.*")) .build()); return securityContexts; } From 1bf9dd1217ad2d62cb6e23ea40e2a56395a9f2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 13:32:50 +0800 Subject: [PATCH 12/23] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96redis=E9=94=81?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/redis/RedisLockManager.java | 109 +++++++++++++----- .../demo/controller/RedisLockController.java | 2 +- .../framework/aspectj/RedisLockAspect.java | 3 +- 3 files changed, 79 insertions(+), 35 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java index fb665a995..e00f80096 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java @@ -22,15 +22,50 @@ public class RedisLockManager { @Autowired private RedissonClient redissonClient; - private final ThreadLocal threadLocal = new ThreadLocal<>(); + /** + * 通用锁 + */ + private final static Integer BASE_LOCK = 1; + + /** + * 公平锁 + */ + private final static Integer FAIR_LOCK = 2; + + /** + * 计数锁 + */ + private final static Integer COUNT_LOCK = 3; + + /** + * 存放当前线程获取锁的类型 + */ + private final ThreadLocal threadLocal = new ThreadLocal<>(); + + /** + * 获取锁 + */ + private T getLock(String key, Integer lockType) { + Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + threadLocal.set(lockType); + Object lock; + if (BASE_LOCK.equals(lockType)) { + lock = redissonClient.getLock(key); + } else if (FAIR_LOCK.equals(lockType)) { + lock = redissonClient.getFairLock(key); + } else if (COUNT_LOCK.equals(lockType)) { + lock = redissonClient.getCountDownLatch(key); + } else { + throw new RuntimeException("锁不存在!"); + } + return (T)lock; + } /** * 获取锁(不用设置超时时间,一直等待) */ public boolean getLock(String key) { - Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); - RLock lock = redissonClient.getLock(key); - threadLocal.set(lock); + RLock lock = getLock(key, BASE_LOCK); return lock.tryLock(); } @@ -41,13 +76,16 @@ public class RedisLockManager { * @param time 过期时间 * @param expireUnit 时间单位 */ - public boolean getLock(String key, long time, TimeUnit expireUnit) throws InterruptedException { - Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + public boolean getLock(String key, long time, TimeUnit expireUnit) { Assert.isTrue(time > 0, "过期时间必须大于0"); Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); - RLock lock = redissonClient.getLock(key); - threadLocal.set(lock); - return lock.tryLock(time, expireUnit); + RLock lock = getLock(key, BASE_LOCK); + try { + return lock.tryLock(time, expireUnit); + } catch (InterruptedException e) { + e.printStackTrace(); + return false; + } } /** @@ -57,28 +95,30 @@ public class RedisLockManager { * @param waitTime 获取锁等待时间 * @param leaseTime 保留锁的时间 * @param expireUnit 时间单位 - * @throws InterruptedException */ - public boolean getLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) throws InterruptedException { - Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + public boolean getLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) { Assert.isTrue(waitTime > 0, "获取锁等待时间必须大于0"); Assert.isTrue(leaseTime > 0, "保留锁的时间必须大于0"); Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); - RLock lock = redissonClient.getLock(key); - threadLocal.set(lock); - return lock.tryLock(waitTime, leaseTime, expireUnit); + RLock lock = getLock(key, BASE_LOCK); + try { + return lock.tryLock(waitTime, leaseTime, expireUnit); + } catch (InterruptedException e) { + e.printStackTrace(); + return false; + } } + /** * 获取计数器锁 * * @param key * @param count countDownLatch 的数量 */ - public RCountDownLatch countDownLatch(String key, long count) { - Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + public RCountDownLatch getCountDownLatch(String key, long count) { Assert.isTrue(count >= 0, "count数量必须大于等于0"); - RCountDownLatch rCountDownLatch = redissonClient.getCountDownLatch(key); + RCountDownLatch rCountDownLatch = getLock(key, COUNT_LOCK); rCountDownLatch.trySetCount(count); return rCountDownLatch; } @@ -93,14 +133,17 @@ public class RedisLockManager { * @return * @throws InterruptedException */ - public boolean getFairLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) throws InterruptedException { - Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + public boolean getFairLock(String key, long waitTime, long leaseTime, TimeUnit expireUnit) { Assert.isTrue(waitTime > 0, "获取锁等待时间必须大于0"); Assert.isTrue(leaseTime > 0, "保留锁的时间必须大于0"); Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); - RLock lock = redissonClient.getFairLock(key); - threadLocal.set(lock); - return lock.tryLock(waitTime, leaseTime, expireUnit); + RLock lock = getLock(key, FAIR_LOCK); + try { + return lock.tryLock(waitTime, leaseTime, expireUnit); + } catch (InterruptedException e) { + e.printStackTrace(); + return false; + } } /** @@ -109,23 +152,25 @@ public class RedisLockManager { * @param key * @param leaseTime 持有锁的时间 * @param expireUnit 时间单位 - * @return - * @throws InterruptedException */ - public boolean getFairLock(String key, long leaseTime, TimeUnit expireUnit) throws InterruptedException { - Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); + public boolean getFairLock(String key, long leaseTime, TimeUnit expireUnit) { Assert.isTrue(leaseTime > 0, "保留锁的时间必须大于0"); Assert.isTrue(Validator.isNotEmpty(expireUnit), "时间单位不能为空"); - RLock lock = redissonClient.getFairLock(key); - threadLocal.set(lock); - return lock.tryLock(leaseTime, expireUnit); + RLock lock = getLock(key, FAIR_LOCK); + try { + return lock.tryLock(leaseTime, expireUnit); + } catch (InterruptedException e) { + e.printStackTrace(); + return false; + } } /** * 释放锁(统一释放) */ - public void unLock() { - RLock lock = threadLocal.get(); + public void unLock(String key) { + Integer lockType = threadLocal.get(); + RLock lock = getLock(key, lockType); lock.unlock(); threadLocal.remove(); } diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java index 40019fc27..e80e3d6b7 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java @@ -52,7 +52,7 @@ public class RedisLockController { if (flag) { log.info("获取锁成功: " + key); Thread.sleep(3000); - redisLockManager.unLock(); + redisLockManager.unLock(key); log.info("释放锁成功: " + key); } else { log.error("获取锁失败: " + key); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java index 9d3bc8d99..efe628f3c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RedisLockAspect.java @@ -10,7 +10,6 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; -import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -78,7 +77,7 @@ public class RedisLockAspect { } catch (Exception e) { throw new RuntimeException(e); } finally { - redisLockManager.unLock(); + redisLockManager.unLock(key); log.info("unlock => key : " + key + " , ThreadName : " + Thread.currentThread().getName()); } } else { From f6ccfe6ed3fa97d62c7fe9b10279ab0d59e80319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 14:04:41 +0800 Subject: [PATCH 13/23] =?UTF-8?q?update=20=E7=8B=AC=E7=AB=8B=20CountDownLa?= =?UTF-8?q?tch=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/core/redis/RedisLockManager.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java index e00f80096..0688bb1c5 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisLockManager.java @@ -32,11 +32,6 @@ public class RedisLockManager { */ private final static Integer FAIR_LOCK = 2; - /** - * 计数锁 - */ - private final static Integer COUNT_LOCK = 3; - /** * 存放当前线程获取锁的类型 */ @@ -45,20 +40,18 @@ public class RedisLockManager { /** * 获取锁 */ - private T getLock(String key, Integer lockType) { + private RLock getLock(String key, Integer lockType) { Assert.isTrue(StrUtil.isNotBlank(key), "key不能为空"); threadLocal.set(lockType); - Object lock; + RLock lock; if (BASE_LOCK.equals(lockType)) { lock = redissonClient.getLock(key); } else if (FAIR_LOCK.equals(lockType)) { lock = redissonClient.getFairLock(key); - } else if (COUNT_LOCK.equals(lockType)) { - lock = redissonClient.getCountDownLatch(key); } else { throw new RuntimeException("锁不存在!"); } - return (T)lock; + return lock; } /** @@ -118,7 +111,7 @@ public class RedisLockManager { */ public RCountDownLatch getCountDownLatch(String key, long count) { Assert.isTrue(count >= 0, "count数量必须大于等于0"); - RCountDownLatch rCountDownLatch = getLock(key, COUNT_LOCK); + RCountDownLatch rCountDownLatch = redissonClient.getCountDownLatch(key); rCountDownLatch.trySetCount(count); return rCountDownLatch; } From 9d05d2bac5214246fd23f949f77da0ba3c882528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 15:42:46 +0800 Subject: [PATCH 14/23] =?UTF-8?q?remove=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml | 0 ruoyi-ui/vue.config.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml diff --git a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 5eb7edd71..11cd50262 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -34,7 +34,7 @@ module.exports = { proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - target: `http://localhost:8080`, + target: `http://localhost:8081`, changeOrigin: true, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: '' From b561f7d90631fd95ff3f508f7eb7d557b88e2ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 15:43:20 +0800 Subject: [PATCH 15/23] =?UTF-8?q?remove=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml diff --git a/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml deleted file mode 100644 index e69de29bb..000000000 From c5c8afe1476855f64956cfe9b1e3cd052b218471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 15:44:14 +0800 Subject: [PATCH 16/23] =?UTF-8?q?update=20=E8=BF=98=E5=8E=9F=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/vue.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 11cd50262..5eb7edd71 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -34,7 +34,7 @@ module.exports = { proxy: { // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VUE_APP_BASE_API]: { - target: `http://localhost:8081`, + target: `http://localhost:8080`, changeOrigin: true, pathRewrite: { ['^' + process.env.VUE_APP_BASE_API]: '' From 48d9fc10ea8111424a0315c3420384c19fa04bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 16:21:44 +0800 Subject: [PATCH 17/23] =?UTF-8?q?update=20=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=AF=B9=E8=B1=A1=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/core/page/PagePlus.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java index 812a683d6..79d889cf0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PagePlus.java @@ -10,6 +10,13 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +/** + * 分页 Page 增强对象 + * + * @param 数据库实体 + * @param vo实体 + * @author Lion Li + */ @Data @Accessors(chain = true) public class PagePlus implements IPage { From 427430fc4839e773648477a99d3cdf6d08715507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 17:11:44 +0800 Subject: [PATCH 18/23] =?UTF-8?q?update=20=E8=A1=A5=E5=85=A8=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 35 ++----------------- .../ruoyi/framework/config/AsyncConfig.java | 5 +++ .../ruoyi/framework/config/SwaggerConfig.java | 2 +- .../config/properties/SwaggerProperties.java | 2 +- .../properties/ThreadPoolProperties.java | 2 +- .../config/properties/TokenProperties.java | 5 +++ .../config/properties/XssProperties.java | 2 +- 7 files changed, 17 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b877e68c4..320625763 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ * 文档框架 knife4j 美化接口文档 * 代码生成器 一键生成前后端代码 +## 参考文档 +[参考文档 Wiki](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) + ## 修改RuoYi功能 ### 依赖改动 @@ -59,38 +62,6 @@ -## 重点注意事项 - -若依文档对事务注解的描述 [关于事务](https://doc.ruoyi.vip/ruoyi/document/htsc.html#%E4%BA%8B%E5%8A%A1%E7%AE%A1%E7%90%86) 以下对多数据源事务做补充: -* 同一个事务下是无法切换数据源的 -* 禁止 父方法使用 @Transactional 创建事务 子方法使用 @DataSource 切换数据源 -* 正确用法: 子方法单独创建事务 或 父方法使用 @Transactional(propagation = Propagation.REQUIRES_NEW) 为所有子方法创建新事务 - -关于如何使用Tomcat -* 查看ruoyi-framework模块的pom.xml文件,根据注释更改依赖 -* 查看ruoyi-admin模块中的application.yml文件,根据注释更改配置 - -关于如何创建新模块 -* 参考ruoyi-demo模块 -* 需要改动: 父pom 与 admin模块pom - -关于树表生成 -* 直接在mysql表中 添加 parentId orderNum 等字段(根据需要参考 TreeEntity类) -* 代码生成选择树表生成即可 - -关于数据权限 -* 创建表 需预留 dept_id 字段 如需用户权限 还需预留 user_id 字段 -* 支持 Mybatis-Plus 方式注入 参考 demo 模块用法(需导入 test.sql 文件) -* 支持 XML 方式注入 参考 system 模块用法 - -关于vue与boot整合部署 -* [前端静态资源如何整合到后端访问](https://doc.ruoyi.vip/ruoyi-vue/other/faq.html#前端静态资源如何整合到后端访问) - -关于修改包名 -* 将文件夹全部修改为 com.xxx -* 使用IDEA全局替换 com.ruoyi 替换为 com.xxx -* 严禁手动修改 - ## 内置功能 1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java index 568260209..5c11ae67a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AsyncConfig.java @@ -11,6 +11,11 @@ import java.util.Arrays; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +/** + * 异步配置 + * + * @author Lion Li + */ @EnableAsync @Configuration public class AsyncConfig extends AsyncConfigurerSupport { diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java index 7b5d95105..2c65ac69d 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; /** - * Swagger2的接口配置 + * Swagger 文档配置 * * @author Lion Li */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java index f99c3da15..ece75efef 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SwaggerProperties.java @@ -6,7 +6,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** - * 验证码 配置属性 + * swagger 配置属性 * * @author Lion Li */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/ThreadPoolProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/ThreadPoolProperties.java index 68cb09337..08b6842aa 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/ThreadPoolProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/ThreadPoolProperties.java @@ -5,7 +5,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** - * 验证码 配置属性 + * 线程池 配置属性 * * @author Lion Li */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/TokenProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/TokenProperties.java index d582e5407..f695c1c62 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/TokenProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/TokenProperties.java @@ -4,6 +4,11 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +/** + * token 配置属性 + * + * @author Lion Li + */ @Data @Component @ConfigurationProperties(prefix = "token") diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/XssProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/XssProperties.java index 35ae2e4ff..d8a68a86a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/XssProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/XssProperties.java @@ -5,7 +5,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** - * 验证码 配置属性 + * xss过滤 配置属性 * * @author Lion Li */ From 35f607f9a541cb78d5ed695f956e22051c3ce0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 18:23:59 +0800 Subject: [PATCH 19/23] =?UTF-8?q?remove=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 3ea04c71e..476a9333d 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -288,8 +288,6 @@ spring: url: http://localhost:${server.port}${spring.boot.admin.context-path} instance: prefer-ip: true # 注册实例时,优先使用 IP - # username: ruoyi - # password: 123456 # Spring Boot Admin Server 服务端的相关配置 context-path: /admin # 配置 Spring From 57df2690da79e420b8e0510895cba8d5d903d8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 20:23:15 +0800 Subject: [PATCH 20/23] =?UTF-8?q?update=20spring-cache=20=E6=95=B4?= =?UTF-8?q?=E5=90=88=20redisson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/RedisLockController.java | 10 ++++++++++ .../com/ruoyi/framework/config/RedisConfig.java | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java index e80e3d6b7..c3c71efc4 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/RedisLockController.java @@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.redis.RedisLockManager; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -62,4 +63,13 @@ public class RedisLockController { } return AjaxResult.success(); } + + /** + * 测试spring-cache注解 + */ + @Cacheable(value = "test", key = "#key") + @GetMapping("/testCache") + public AjaxResult testCache(String key) { + return AjaxResult.success("操作成功", key); + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java index e86f5bc03..95c7572fd 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java @@ -6,15 +6,20 @@ import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.codec.JsonJacksonCodec; import org.redisson.config.Config; +import org.redisson.spring.cache.CacheConfig; +import org.redisson.spring.cache.RedissonSpringCacheManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.data.redis.RedisProperties; +import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; /** * redis配置 @@ -67,4 +72,15 @@ public class RedisConfig extends CachingConfigurerSupport { .setDnsMonitoringInterval(singleServerConfig.getDnsMonitoringInterval()); return Redisson.create(config); } + + /** + * 整合spring-cache + */ + @Bean + public CacheManager cacheManager(RedissonClient redissonClient) { + Map config = new HashMap<>(); + config.put("redissonCacheMap", new CacheConfig(30*60*1000, 10*60*1000)); + return new RedissonSpringCacheManager(redissonClient, config, JsonJacksonCodec.INSTANCE); + } + } From 24da85fea353960420d370cd6a50ee7be4d7ef32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 21:18:58 +0800 Subject: [PATCH 21/23] =?UTF-8?q?update=20MybatisPlus=E6=95=B4=E5=90=88Red?= =?UTF-8?q?is=E4=BA=8C=E7=BA=A7=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatisplus/MybatisPlusRedisCache.java | 102 ++++++++++++++++++ .../com/ruoyi/demo/mapper/TestDemoMapper.java | 5 +- .../com/ruoyi/demo/mapper/TestTreeMapper.java | 5 +- .../src/main/resources/vm/java/mapper.java.vm | 3 + 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/MybatisPlusRedisCache.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/MybatisPlusRedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/MybatisPlusRedisCache.java new file mode 100644 index 000000000..6ff6a982b --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/mybatisplus/MybatisPlusRedisCache.java @@ -0,0 +1,102 @@ +package com.ruoyi.common.core.mybatisplus; + +import cn.hutool.extra.spring.SpringUtil; +import com.ruoyi.common.core.redis.RedisCache; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.cache.Cache; +import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.util.CollectionUtils; + +import java.util.Collection; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * mybatis-redis 二级缓存 + * + * @author Lion Li + */ +@Slf4j +public class MybatisPlusRedisCache implements Cache { + + private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(true); + + private RedisCache redisCache; + + private String id; + + public MybatisPlusRedisCache(final String id) { + if (id == null) { + throw new IllegalArgumentException("Cache instances require an ID"); + } + this.id = id; + } + + @Override + public String getId() { + return this.id; + } + + @Override + public void putObject(Object key, Object value) { + if (redisCache == null) { + redisCache = SpringUtil.getBean(RedisCache.class); + } + if (value != null) { + redisCache.setCacheObject(key.toString(), value); + } + } + + @Override + public Object getObject(Object key) { + if (redisCache == null) { + //由于启动期间注入失败,只能运行期间注入,这段代码可以删除 + redisCache = SpringUtil.getBean(RedisCache.class); + } + try { + if (key != null) { + return redisCache.getCacheObject(key.toString()); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("缓存出错"); + } + return null; + } + + @Override + public Object removeObject(Object key) { + if (redisCache == null) { + redisCache = SpringUtil.getBean(RedisCache.class); + } + if (key != null) { + redisCache.deleteObject(key.toString()); + } + return null; + } + + @Override + public void clear() { + log.debug("清空缓存"); + if (redisCache == null) { + redisCache = SpringUtil.getBean(RedisCache.class); + } + Collection keys = redisCache.keys("*:" + this.id + "*"); + if (!CollectionUtils.isEmpty(keys)) { + redisCache.deleteObject(keys); + } + } + + @Override + public int getSize() { + RedisTemplate redisTemplate = SpringUtil.getBean("redisTemplate"); + Long size = redisTemplate.execute(RedisServerCommands::dbSize); + return size.intValue(); + } + + @Override + public ReadWriteLock getReadWriteLock() { + return this.readWriteLock; + } +} 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 2416f0efc..5cfb9f69c 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 @@ -1,7 +1,9 @@ package com.ruoyi.demo.mapper; -import com.ruoyi.demo.domain.TestDemo; +import com.ruoyi.common.core.mybatisplus.MybatisPlusRedisCache; import com.ruoyi.common.core.page.BaseMapperPlus; +import com.ruoyi.demo.domain.TestDemo; +import org.apache.ibatis.annotations.CacheNamespace; /** * 测试单表Mapper接口 @@ -9,6 +11,7 @@ import com.ruoyi.common.core.page.BaseMapperPlus; * @author Lion Li * @date 2021-05-30 */ +@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class) public interface TestDemoMapper extends BaseMapperPlus { } diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestTreeMapper.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestTreeMapper.java index 6dd75c50d..0635ebc06 100644 --- a/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestTreeMapper.java +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestTreeMapper.java @@ -1,7 +1,9 @@ package com.ruoyi.demo.mapper; -import com.ruoyi.demo.domain.TestTree; +import com.ruoyi.common.core.mybatisplus.MybatisPlusRedisCache; import com.ruoyi.common.core.page.BaseMapperPlus; +import com.ruoyi.demo.domain.TestTree; +import org.apache.ibatis.annotations.CacheNamespace; /** * 测试树表Mapper接口 @@ -9,6 +11,7 @@ import com.ruoyi.common.core.page.BaseMapperPlus; * @author Lion Li * @date 2021-05-30 */ +@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class) public interface TestTreeMapper extends BaseMapperPlus { } diff --git a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm index 600841891..36a98642c 100644 --- a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm @@ -2,6 +2,8 @@ package ${packageName}.mapper; import ${packageName}.domain.${ClassName}; import com.ruoyi.common.core.page.BaseMapperPlus; +import com.ruoyi.common.core.mybatisplus.MybatisPlusRedisCache; +import org.apache.ibatis.annotations.CacheNamespace; /** * ${functionName}Mapper接口 @@ -9,6 +11,7 @@ import com.ruoyi.common.core.page.BaseMapperPlus; * @author ${author} * @date ${datetime} */ +@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class) public interface ${ClassName}Mapper extends BaseMapperPlus<${ClassName}> { } From 346e80839fa450ff75869e9bfa39d9a1df4bebec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Thu, 10 Jun 2021 22:32:40 +0800 Subject: [PATCH 22/23] =?UTF-8?q?update=20spring-cache=20=E4=B8=8E=20MP?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E7=BC=93=E5=AD=98=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 320625763..312f3e1fd 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ * 项目修改为 maven多环境配置 * 项目配置修改为 application.yml 统一管理 * 数据权限修改为 适配支持单表、多表 +* 使用 redisson 实现 spring-cache 整合 +* 增加 mybatis-plus 二级缓存 redis 存储 ### 其他 From bf3a88ff1a12de55e643ba79eb0daaef57680d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 11 Jun 2021 09:23:34 +0800 Subject: [PATCH 23/23] =?UTF-8?q?=E5=8F=91=E7=89=88=20v2.3.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 16 ++++++++-------- ruoyi-ui/package.json | 2 +- ruoyi-ui/src/views/index.vue | 11 +++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 94ab8d5ce..4a73f1eac 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ RuoYi-Vue-Plus后台管理系统 - 2.3.1 + 2.3.2 2.3.11.RELEASE UTF-8 UTF-8 @@ -126,6 +126,13 @@ ${spring-boot-admin.version} + + + org.redisson + redisson-spring-boot-starter + ${redisson.version} + + com.ruoyi @@ -168,13 +175,6 @@ ${ruoyi-vue-plus.version} - - - org.redisson - redisson-spring-boot-starter - ${redisson.version} - - diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 52551a4cc..d90fdbac6 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi-vue-plus", - "version": "2.3.1", + "version": "2.3.2", "description": "RuoYi-Vue-Plus后台管理系统", "author": "LionLi", "license": "MIT", diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index d904f3098..5f487c914 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -80,6 +80,17 @@ 更新日志 + +
    +
  1. add redis锁工具类编写
  2. +
  3. update spring-cache 整合 redisson
  4. +
  5. update MybatisPlus整合Redis二级缓存
  6. +
  7. update swagger 升级为 3.0.0 使用 OAS_30 协议
  8. +
  9. update 优化 代码生成器 增加表单防重注解
  10. +
  11. update 优化 锁切面代码 key到常量类
  12. +
  13. fix 修复相对路径上传异常问题
  14. +
+
  1. add 增加 redisson 分布式锁 注解与demo案例