From 1a5881b1d0bdb37461d402ffa145bf7728ee768c Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Sep 2021 19:09:22 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E7=A3=81=E7=9B=98=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/monitor/server/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/monitor/server/index.vue b/ruoyi-ui/src/views/monitor/server/index.vue index 0965a935c..367001f4d 100644 --- a/ruoyi-ui/src/views/monitor/server/index.vue +++ b/ruoyi-ui/src/views/monitor/server/index.vue @@ -153,7 +153,7 @@ - +
{{ sysFile.dirName }}
{{ sysFile.sysTypeName }}
{{ sysFile.typeName }}
From f8cc7ce328c39ce998e19b6bd13f9abc5b69d656 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 23 Sep 2021 19:15:33 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E9=99=90=E6=B5=81=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E6=95=B0=E5=80=BC=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/framework/config/RedisConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 322d6e344..fe1822f70 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 @@ -68,12 +68,12 @@ public class RedisConfig extends CachingConfigurerSupport "local time = tonumber(ARGV[2])\n" + "local current = redis.call('get', key);\n" + "if current and tonumber(current) > count then\n" + - " return current;\n" + + " return tonumber(current);\n" + "end\n" + "current = redis.call('incr', key)\n" + "if tonumber(current) == 1 then\n" + " redis.call('expire', key, time)\n" + "end\n" + - "return current;"; + "return tonumber(current);"; } } From 7c8eae3735d4d07cdf28abc9c7d3bd0829fead74 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, 23 Sep 2021 19:25:01 +0800 Subject: [PATCH 03/23] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=20satoken?= =?UTF-8?q?=E5=88=86=E6=94=AF=20=E7=9B=B8=E5=85=B3=E4=BB=8B=E7=BB=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index fd4f62c97..a7957e5e0 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级(不兼 | 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 | |---|---|---|---| | 当前框架 | RuoYi-Vue-Plus | [RuoYi-Vue-Plus文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) | 重写RuoYi-Vue全方位升级(不兼容原框架) | +| satoken分支 | RuoYi-Vue-Plus-satoken | [satoken分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 使用satoken重构权限鉴权(仅供学习不推荐上生产) | +| 单体分支 | RuoYi-Vue-Plus-fast | [fast分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) | 单体应用结构 | | 原框架 | RuoYi-Vue | [RuoYi-Vue官网](http://ruoyi.vip/) | 定期同步需要的功能 | | 前端开发框架 | Vue、Element UI | [Element UI官网](https://element.eleme.cn/#/zh-CN) | | | 后端开发框架 | SpringBoot | [SpringBoot官网](https://spring.io/projects/spring-boot/#learn) | | @@ -69,6 +71,7 @@ RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级(不兼 * 同步升级 RuoYi-Vue * GitHub 地址 [RuoYi-Vue-Plus-github](https://github.com/JavaLionLi/RuoYi-Vue-Plus) * 单模块 fast 分支 [RuoYi-Vue-Plus-fast](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) +* satoken 分支 [RuoYi-Vue-Plus-satoken](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) * 用户扩展项目 [扩展项目列表](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4478302&doc_id=1469725) ## 加群与捐献 From b477e40d3c98d06c5bd680b1eb3dd2ba6b230d6d Mon Sep 17 00:00:00 2001 From: lihy2021 Date: Fri, 24 Sep 2021 00:41:43 +0000 Subject: [PATCH 04/23] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/web/service/SysLoginService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 07bb03cfd..2b5474327 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -87,7 +87,7 @@ public class SysLoginService } AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); LoginUser loginUser = (LoginUser) authentication.getPrincipal(); - recordLoginInfo(loginUser.getUser()); + recordLoginInfo(loginUser.getUserId()); // 生成token return tokenService.createToken(loginUser); } @@ -119,11 +119,15 @@ public class SysLoginService /** * 记录登录信息 + * + * @param userId 用户ID */ - public void recordLoginInfo(SysUser user) + public void recordLoginInfo(Long userId) { - user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); - user.setLoginDate(DateUtils.getNowDate()); - userService.updateUserProfile(user); + SysUser sysUser = new SysUser(); + sysUser.setUserId(userId); + sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); + sysUser.setLoginDate(DateUtils.getNowDate()); + userService.updateUserProfile(sysUser); } } From 648028282600eb5f559551073febb7d231fe3f29 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 24 Sep 2021 09:28:46 +0800 Subject: [PATCH 05/23] =?UTF-8?q?=E5=8D=87=E7=BA=A7fastjson=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=881.2.78?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc3e45cfe..2e1d5e075 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 2.3.2 2.1.4 1.3.1 - 1.2.76 + 1.2.78 5.8.0 5.8.0 2.11.0 From 77bce8b1e8a4d151119505a80f68128dbce500a3 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, 24 Sep 2021 09:59:28 +0800 Subject: [PATCH 06/23] =?UTF-8?q?update=20springboot=202.5.4=20=3D>=202.5.?= =?UTF-8?q?5=20bugfix=E7=89=88=E6=9C=AC=20update=20mybatis-plus=203.4.3.3?= =?UTF-8?q?=20=3D>=203.4.3.4=20bugfix=E7=89=88=E6=9C=AC=20update=20redisso?= =?UTF-8?q?n=203.16.2=20=3D>=203.16.3=20bugfix=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 73d680a10..f124949d4 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 3.1.0 - 2.5.4 + 2.5.5 UTF-8 UTF-8 1.8 @@ -26,14 +26,14 @@ 2.2.11 1.7 0.9.1 - 3.4.3.3 + 3.4.3.4 3.9.1 5.7.13 3.0.3 11.6 4.9.1 2.5.1 - 3.16.2 + 3.16.3 2.2.1 3.4.1 @@ -43,7 +43,7 @@ 7.8.0 3.13.1 - 5.6.51 + 5.6.55 8.3.0 From eaa3baab3ca340131809ff4942d4190fdc3c553e 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, 24 Sep 2021 10:06:23 +0800 Subject: [PATCH 07/23] =?UTF-8?q?update=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2=20=E6=8B=BC?= =?UTF-8?q?=E5=86=99=E9=94=99=E8=AF=AF=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/tool/gen/editTable.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ruoyi-ui/src/views/tool/gen/editTable.vue b/ruoyi-ui/src/views/tool/gen/editTable.vue index 4689ea9f6..a013cbbb0 100644 --- a/ruoyi-ui/src/views/tool/gen/editTable.vue +++ b/ruoyi-ui/src/views/tool/gen/editTable.vue @@ -4,8 +4,8 @@ - - + + { - this.cloumns = res.data.rows; + this.columns = res.data.rows; this.info = res.data.info; this.tables = res.data.tables; }); @@ -184,7 +184,7 @@ export default { const validateResult = res.every(item => !!item); if (validateResult) { const genTable = Object.assign({}, basicForm.model, genForm.model); - genTable.columns = this.cloumns; + genTable.columns = this.columns; genTable.params = { treeCode: genTable.treeCode, treeName: genTable.treeName, @@ -220,10 +220,10 @@ export default { const sortable = Sortable.create(el, { handle: ".allowDrag", onEnd: evt => { - const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0]; - this.cloumns.splice(evt.newIndex, 0, targetRow); - for (let index in this.cloumns) { - this.cloumns[index].sort = parseInt(index) + 1; + const targetRow = this.columns.splice(evt.oldIndex, 1)[0]; + this.columns.splice(evt.newIndex, 0, targetRow); + for (let index in this.columns) { + this.columns[index].sort = parseInt(index) + 1; } } }); From 6f870e11ffb2379d6483c29f1fbf7c9a61f432ef 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, 24 Sep 2021 11:17:25 +0800 Subject: [PATCH 08/23] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E7=A9=BA?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/common/utils/ip/AddressUtils.java | 3 +++ .../java/com/ruoyi/framework/config/AsyncConfig.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java index 03c608af8..bd7522c51 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java @@ -27,6 +27,9 @@ public class AddressUtils { public static String getRealAddressByIP(String ip) { String address = UNKNOWN; + if (StringUtils.isBlank(ip)){ + return address; + } // 内网不查询 ip = "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip); if (NetUtil.isInnerIP(ip)) { 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 e30f83c79..95f3c9b73 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 @@ -1,5 +1,6 @@ package com.ruoyi.framework.config; +import cn.hutool.core.util.ArrayUtil; import com.ruoyi.common.exception.ServiceException; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.beans.factory.annotation.Autowired; @@ -41,10 +42,13 @@ public class AsyncConfig extends AsyncConfigurerSupport { public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { return (throwable, method, objects) -> { throwable.printStackTrace(); - throw new ServiceException( - "Exception message - " + throwable.getMessage() - + ", Method name - " + method.getName() - + ", Parameter value - " + Arrays.toString(objects)); + StringBuilder sb = new StringBuilder(); + sb.append("Exception message - ").append(throwable.getMessage()) + .append(", Method name - ").append(method.getName()); + if (ArrayUtil.isNotEmpty(objects)) { + sb.append(", Parameter value - ").append(Arrays.toString(objects)); + } + throw new ServiceException(sb.toString()); }; } From 02ce9868a7c7677c6a53ce8baff5c86543702ead 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, 24 Sep 2021 05:41:55 +0000 Subject: [PATCH 09/23] =?UTF-8?q?fix=20=E8=87=AA=E5=8A=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E4=BB=A3=E7=A0=81=E6=BC=8F=E6=8E=89=20this.#[[$modal]?= =?UTF-8?q?]#.msgError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6893f28c1..a55550373 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -546,7 +546,7 @@ export default { /** ${subTable.functionName}删除按钮操作 */ handleDelete${subClassName}() { if (this.checked${subClassName}.length == 0) { - this.msgError("请先选择要删除的${subTable.functionName}数据"); + this.#[[$modal]]#.msgError("请先选择要删除的${subTable.functionName}数据"); } else { const ${subclassName}List = this.${subclassName}List; const checked${subClassName} = this.checked${subClassName}; From 9801e9c29a5c69044ce3f37661326ece6f4e6e09 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, 24 Sep 2021 15:13:11 +0800 Subject: [PATCH 10/23] =?UTF-8?q?remove=20=E7=A7=BB=E9=99=A4=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/core/redis/RedisCache.java | 260 ------------------ 1 file changed, 260 deletions(-) delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java deleted file mode 100644 index 23a25e045..000000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java +++ /dev/null @@ -1,260 +0,0 @@ -package com.ruoyi.common.core.redis; - -import com.google.common.collect.Lists; -import org.redisson.api.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; - -/** - * spring redis 工具类 - * - * @author shenxinquan - * @see com.ruoyi.common.utils.RedisUtils - * @deprecated 3.2.0 删除此类 - **/ -@SuppressWarnings(value = {"unchecked", "rawtypes"}) -@Component -@Deprecated -public class RedisCache { - - @Autowired - private RedissonClient redissonClient; - - /** - * 发布通道消息 - * - * @param channelKey 通道key - * @param msg 发送数据 - * @param consumer 自定义处理 - */ - public void publish(String channelKey, T msg, Consumer consumer) { - RTopic topic = redissonClient.getTopic(channelKey); - topic.publish(msg); - consumer.accept(msg); - } - - public void publish(String channelKey, T msg) { - RTopic topic = redissonClient.getTopic(channelKey); - topic.publish(msg); - } - - /** - * 订阅通道接收消息 - * - * @param channelKey 通道key - * @param clazz 消息类型 - * @param consumer 自定义处理 - */ - public void subscribe(String channelKey, Class clazz, Consumer consumer) { - RTopic topic = redissonClient.getTopic(channelKey); - topic.addListener(clazz, (channel, msg) -> consumer.accept(msg)); - } - - /** - * 缓存基本的对象,Integer、String、实体类等 - * - * @param key 缓存的键值 - * @param value 缓存的值 - */ - public void setCacheObject(final String key, final T value) { - redissonClient.getBucket(key).set(value); - } - - /** - * 缓存基本的对象,Integer、String、实体类等 - * - * @param key 缓存的键值 - * @param value 缓存的值 - * @param timeout 时间 - * @param timeUnit 时间颗粒度 - */ - public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { - RBucket result = redissonClient.getBucket(key); - result.set(value); - result.expire(timeout, timeUnit); - } - - /** - * 设置有效时间 - * - * @param key Redis键 - * @param timeout 超时时间 - * @return true=设置成功;false=设置失败 - */ - public boolean expire(final String key, final long timeout) { - return expire(key, timeout, TimeUnit.SECONDS); - } - - /** - * 设置有效时间 - * - * @param key Redis键 - * @param timeout 超时时间 - * @param unit 时间单位 - * @return true=设置成功;false=设置失败 - */ - public boolean expire(final String key, final long timeout, final TimeUnit unit) { - RBucket rBucket = redissonClient.getBucket(key); - return rBucket.expire(timeout, unit); - } - - /** - * 获得缓存的基本对象。 - * - * @param key 缓存键值 - * @return 缓存键值对应的数据 - */ - public T getCacheObject(final String key) { - RBucket rBucket = redissonClient.getBucket(key); - return rBucket.get(); - } - - /** - * 删除单个对象 - * - * @param key - */ - public boolean deleteObject(final String key) { - return redissonClient.getBucket(key).delete(); - } - - /* */ - - /** - * 删除集合对象 - * - * @param collection 多个对象 - * @return - */ - public void deleteObject(final Collection collection) { - RBatch batch = redissonClient.createBatch(); - collection.forEach(t->{ - batch.getBucket(t.toString()).deleteAsync(); - }); - batch.execute(); - } - - /** - * 缓存List数据 - * - * @param key 缓存的键值 - * @param dataList 待缓存的List数据 - * @return 缓存的对象 - */ - public boolean setCacheList(final String key, final List dataList) { - RList rList = redissonClient.getList(key); - return rList.addAll(dataList); - } - - /** - * 获得缓存的list对象 - * - * @param key 缓存的键值 - * @return 缓存键值对应的数据 - */ - public List getCacheList(final String key) { - RList rList = redissonClient.getList(key); - return rList.readAll(); - } - - /** - * 缓存Set - * - * @param key 缓存键值 - * @param dataSet 缓存的数据 - * @return 缓存数据的对象 - */ - public boolean setCacheSet(final String key, final Set dataSet) { - RSet rSet = redissonClient.getSet(key); - return rSet.addAll(dataSet); - } - - /** - * 获得缓存的set - * - * @param key - * @return - */ - public Set getCacheSet(final String key) { - RSet rSet = redissonClient.getSet(key); - return rSet.readAll(); - } - - /** - * 缓存Map - * - * @param key - * @param dataMap - */ - public void setCacheMap(final String key, final Map dataMap) { - if (dataMap != null) { - RMap rMap = redissonClient.getMap(key); - rMap.putAll(dataMap); - } - } - - /** - * 获得缓存的Map - * - * @param key - * @return - */ - public Map getCacheMap(final String key) { - RMap rMap = redissonClient.getMap(key); - return rMap.getAll(rMap.keySet()); - } - - /** - * 往Hash中存入数据 - * - * @param key Redis键 - * @param hKey Hash键 - * @param value 值 - */ - public void setCacheMapValue(final String key, final String hKey, final T value) { - RMap rMap = redissonClient.getMap(key); - rMap.put(hKey, value); - } - - /** - * 获取Hash中的数据 - * - * @param key Redis键 - * @param hKey Hash键 - * @return Hash中的对象 - */ - public T getCacheMapValue(final String key, final String hKey) { - RMap rMap = redissonClient.getMap(key); - return rMap.get(hKey); - } - - /** - * 获取多个Hash中的数据 - * - * @param key Redis键 - * @param hKeys Hash键集合 - * @return Hash对象集合 - */ - public Map getMultiCacheMapValue(final String key, final Set hKeys) { - RMap rMap = redissonClient.getMap(key); - return rMap.getAll(hKeys); - } - - /** - * 获得缓存的基本对象列表 - * - * @param pattern 字符串前缀 - * @return 对象列表 - */ - public Collection keys(final String pattern) { - Iterable iterable = redissonClient.getKeys().getKeysByPattern(pattern); - return Lists.newArrayList(iterable); - } -} From 7479ff4b06680cb7cca3a9cd987c4d6efb2d0032 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 25 Sep 2021 17:12:37 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dxss=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=90=8E=E6=A0=BC=E5=BC=8F=E5=87=BA=E7=8E=B0=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java index 3de26bb4b..415acbab2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java @@ -387,7 +387,7 @@ public final class HTMLFilter { paramValue = processParamProtocol(paramValue); } - params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); + params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\""); } } From 30c89b33fefbec967e0913332b2f0018cb2b31ec Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 26 Sep 2021 09:03:01 +0800 Subject: [PATCH 12/23] =?UTF-8?q?Excel=E6=B3=A8=E8=A7=A3=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E6=A0=87=E9=A2=98=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/poi/ExcelUtil.java | 148 +++++++++++++++--- 1 file changed, 126 insertions(+), 22 deletions(-) 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 388479056..b9f9ac289 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 @@ -47,6 +47,7 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.streaming.SXSSFWorkbook; @@ -125,6 +126,16 @@ public class ExcelUtil */ private List fields; + /** + * 当前行号 + */ + private int rownum; + + /** + * 标题 + */ + private String title; + /** * 最大高度 */ @@ -150,7 +161,7 @@ public class ExcelUtil this.clazz = clazz; } - public void init(List list, String sheetName, Type type) + public void init(List list, String sheetName, String title, Type type) { if (list == null) { @@ -159,8 +170,27 @@ public class ExcelUtil this.list = list; this.sheetName = sheetName; this.type = type; + this.title = title; createExcelField(); createWorkbook(); + createTitle(); + } + + /** + * 创建excel第一行标题 + */ + public void createTitle() + { + if (StringUtils.isNotEmpty(title)) + { + Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0); + titleRow.setHeightInPoints(30); + Cell titleCell = titleRow.createCell(0); + titleCell.setCellStyle(styles.get("title")); + titleCell.setCellValue(title); + sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(), + this.fields.size() - 1)); + } } /** @@ -171,17 +201,30 @@ public class ExcelUtil */ public List importExcel(InputStream is) throws Exception { - return importExcel(StringUtils.EMPTY, is); + return importExcel(is, 0); + } + + /** + * 对excel表单默认第一个索引名转换成list + * + * @param is 输入流 + * @param titleNum 标题占用行数 + * @return 转换后集合 + */ + public List importExcel(InputStream is, int titleNum) throws Exception + { + return importExcel(StringUtils.EMPTY, is, titleNum); } /** * 对excel表单指定表格索引名转换成list * * @param sheetName 表格索引名 + * @param titleNum 标题占用行数 * @param is 输入流 * @return 转换后集合 */ - public List importExcel(String sheetName, InputStream is) throws Exception + public List importExcel(String sheetName, InputStream is, int titleNum) throws Exception { this.type = Type.IMPORT; this.wb = WorkbookFactory.create(is); @@ -210,7 +253,7 @@ public class ExcelUtil // 定义一个map用于存放excel列的序号和field. Map cellMap = new HashMap(); // 获取表头 - Row heard = sheet.getRow(0); + Row heard = sheet.getRow(titleNum); for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) { Cell cell = heard.getCell(i); @@ -243,7 +286,7 @@ public class ExcelUtil } } } - for (int i = 1; i <= rows; i++) + for (int i = titleNum + 1; i <= rows; i++) { // 从第2行开始取数据,默认第一行是表头. Row row = sheet.getRow(i); @@ -369,7 +412,20 @@ public class ExcelUtil */ public AjaxResult exportExcel(List list, String sheetName) { - this.init(list, sheetName, Type.EXPORT); + return exportExcel(list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public AjaxResult exportExcel(List list, String sheetName, String title) + { + this.init(list, sheetName, title, Type.EXPORT); return exportExcel(); } @@ -382,11 +438,26 @@ public class ExcelUtil * @return 结果 * @throws IOException */ - public void exportExcel(HttpServletResponse response, List list, String sheetName) throws IOException + public void exportExcel(HttpServletResponse response, List list, String sheetName)throws IOException + { + exportExcel(response, list, sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param response 返回数据 + * @param list 导出数据集合 + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + * @throws IOException + */ + public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) throws IOException { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - this.init(list, sheetName, Type.EXPORT); + this.init(list, sheetName, title, Type.EXPORT); exportExcel(response.getOutputStream()); } @@ -398,7 +469,19 @@ public class ExcelUtil */ public AjaxResult importTemplateExcel(String sheetName) { - this.init(null, sheetName, Type.IMPORT); + return importTemplateExcel(sheetName, StringUtils.EMPTY); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public AjaxResult importTemplateExcel(String sheetName, String title) + { + this.init(null, sheetName, title, Type.IMPORT); return exportExcel(); } @@ -409,10 +492,22 @@ public class ExcelUtil * @return 结果 */ public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException + { + importTemplateExcel(response, sheetName); + } + + /** + * 对list数据源将其里面的数据导入到excel表单 + * + * @param sheetName 工作表的名称 + * @param title 标题 + * @return 结果 + */ + public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) throws IOException { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - this.init(null, sheetName, Type.IMPORT); + this.init(null, sheetName, title, Type.IMPORT); exportExcel(response.getOutputStream()); } @@ -473,13 +568,13 @@ public class ExcelUtil public void writeSheet() { // 取出一共有多少个sheet. - double sheetNo = Math.ceil(list.size() / sheetSize); - for (int index = 0; index <= sheetNo; index++) + int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize)); + for (int index = 0; index < sheetNo; index++) { createSheet(sheetNo, index); // 产生一行 - Row row = sheet.createRow(0); + Row row = sheet.createRow(rownum); int column = 0; // 写入各个字段的列头名称 for (Object[] os : fields) @@ -507,7 +602,7 @@ public class ExcelUtil int endNo = Math.min(startNo + sheetSize, list.size()); for (int i = startNo; i < endNo; i++) { - row = sheet.createRow(i + 1 - startNo); + row = sheet.createRow(i + 1 + rownum - startNo); // 得到导出对象. T vo = (T) list.get(i); int column = 0; @@ -535,6 +630,16 @@ public class ExcelUtil CellStyle style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); + Font titleFont = wb.createFont(); + titleFont.setFontName("Arial"); + titleFont.setFontHeightInPoints((short) 16); + titleFont.setBold(true); + style.setFont(titleFont); + styles.put("title", style); + + style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBorderLeft(BorderStyle.THIN); @@ -1117,6 +1222,9 @@ public class ExcelUtil public void createWorkbook() { this.wb = new SXSSFWorkbook(500); + this.sheet = wb.createSheet(); + wb.setSheetName(0, sheetName); + this.styles = createStyles(wb); } /** @@ -1125,17 +1233,13 @@ public class ExcelUtil * @param sheetNo sheet数量 * @param index 序号 */ - public void createSheet(double sheetNo, int index) + public void createSheet(int sheetNo, int index) { - this.sheet = wb.createSheet(); - this.styles = createStyles(wb); // 设置工作表的名称. - if (sheetNo == 0) - { - wb.setSheetName(index, sheetName); - } - else + if (sheetNo > 1 && index > 0) { + this.sheet = wb.createSheet(); + this.createTitle(); wb.setSheetName(index, sheetName + index); } } From 8a81f37d2275131638e915561f1d8671f9fecf30 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: Sun, 26 Sep 2021 10:08:24 +0800 Subject: [PATCH 13/23] =?UTF-8?q?update=20=E5=90=8C=E6=AD=A5ruoyi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/system/service/SysLoginService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 06aa9ac11..45bbf0abe 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 @@ -81,7 +81,7 @@ public class SysLoginService } else { - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); + asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage(), request); throw new ServiceException(e.getMessage()); } } @@ -123,7 +123,7 @@ public class SysLoginService { SysUser sysUser = new SysUser(); sysUser.setUserId(userId); - sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest())); + sysUser.setLoginIp(ServletUtils.getClientIP()); sysUser.setLoginDate(DateUtils.getNowDate()); userService.updateUserProfile(sysUser); } From 0f2caf1cb6711c38055edbc0b41484a1853ebead 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: Sun, 26 Sep 2021 14:08:28 +0800 Subject: [PATCH 14/23] =?UTF-8?q?update=20security=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8A=BD=E5=8F=96=E5=88=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=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/application.yml | 17 +++++++++++++++++ .../ruoyi/framework/config/SecurityConfig.java | 15 +++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index fa95235a7..9f649edb0 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -106,6 +106,23 @@ token: # 令牌有效期(默认30分钟) expireTime: 30 +# security配置 +security: + anonymous: + - /login + - /register + - /captchaImage + # swagger 文档配置 + - /doc.html + - /swagger-resources/** + - /webjars/** + - /*/api-docs + # druid 监控配置 + - /druid/** + # actuator 监控配置 + - /actuator + - /actuator/** + # 重复提交 repeat-submit: # 全局间隔时间(毫秒) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index bd6ee8f36..855be657c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -1,5 +1,6 @@ package com.ruoyi.framework.config; +import com.ruoyi.framework.config.properties.SecurityProperties; import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; @@ -56,6 +57,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter @Autowired private CorsFilter corsFilter; + @Autowired + private SecurityProperties securityProperties; + /** * 解决 无法直接注入 AuthenticationManager * @@ -96,8 +100,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() // 过滤请求 .authorizeRequests() - // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login", "/register", "/captchaImage").anonymous() .antMatchers( HttpMethod.GET, "/", @@ -106,14 +108,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter "/**/*.css", "/**/*.js" ).permitAll() - .antMatchers("/doc.html").anonymous() - .antMatchers("/swagger-resources/**").anonymous() - .antMatchers("/webjars/**").anonymous() - .antMatchers("/*/api-docs").anonymous() - .antMatchers("/druid/**").anonymous() - // Spring Boot Actuator 的安全配置 - .antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous() + .antMatchers(securityProperties.getAnonymous()).anonymous() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() From 92804151a3459162438be2e66e589fd33a3c8087 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: Sun, 26 Sep 2021 14:08:48 +0800 Subject: [PATCH 15/23] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E5=8C=BF?= =?UTF-8?q?=E5=90=8D=E8=B7=AF=E5=BE=84jwt=E6=94=BE=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/properties/SecurityProperties.java | 22 +++++++++++++++++++ .../filter/JwtAuthenticationTokenFilter.java | 13 +++++++++++ 2 files changed, 35 insertions(+) create mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java new file mode 100644 index 000000000..33414cedb --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java @@ -0,0 +1,22 @@ +package com.ruoyi.framework.config.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * Security 配置属性 + * + * @author Lion Li + */ +@Data +@Component +@ConfigurationProperties(prefix = "security") +public class SecurityProperties { + + /** + * 匿名放行路径 + */ + private String[] anonymous; + +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index 5439a979b..2c5e3029e 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -4,11 +4,14 @@ import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.service.TokenService; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.config.properties.SecurityProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; import org.springframework.stereotype.Component; +import org.springframework.util.AntPathMatcher; +import org.springframework.util.PathMatcher; import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.FilterChain; @@ -28,10 +31,20 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter @Autowired private TokenService tokenService; + @Autowired + private SecurityProperties securityProperties; + @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { + // 匿名路径放行 + for (String anonymou : securityProperties.getAnonymous()) { + PathMatcher pm = new AntPathMatcher(); + if (pm.matchStart(anonymou, request.getRequestURI())) { + chain.doFilter(request, response); + } + } LoginUser loginUser = tokenService.getLoginUser(request); if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) { From f7982ede73f77946768d891449017c060c7c82a1 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: Sun, 26 Sep 2021 14:35:25 +0800 Subject: [PATCH 16/23] =?UTF-8?q?fix=20jwt=E8=BF=87=E6=BB=A4=E7=BC=96?= =?UTF-8?q?=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/JwtAuthenticationTokenFilter.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index 2c5e3029e..b46a8cedc 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -38,20 +38,24 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { - // 匿名路径放行 + // 匿名路径放行 默认拦截 + boolean flag = true; for (String anonymou : securityProperties.getAnonymous()) { PathMatcher pm = new AntPathMatcher(); if (pm.matchStart(anonymou, request.getRequestURI())) { - chain.doFilter(request, response); + flag = false; + break; } + } - LoginUser loginUser = tokenService.getLoginUser(request); - if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) - { - tokenService.verifyToken(loginUser); - UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); - authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); - SecurityContextHolder.getContext().setAuthentication(authenticationToken); + if (flag) { + LoginUser loginUser = tokenService.getLoginUser(request); + if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) { + tokenService.verifyToken(loginUser); + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); + authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); + SecurityContextHolder.getContext().setAuthentication(authenticationToken); + } } chain.doFilter(request, response); } From 36f8eb71f3e44fec3d25c091106d153a1dbba4ad 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: Sun, 26 Sep 2021 14:39:51 +0800 Subject: [PATCH 17/23] =?UTF-8?q?fix=20jwt=E8=BF=87=E6=BB=A4=E7=BC=96?= =?UTF-8?q?=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/filter/JwtAuthenticationTokenFilter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index b46a8cedc..c5161c534 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -39,11 +39,11 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter throws ServletException, IOException { // 匿名路径放行 默认拦截 - boolean flag = true; + boolean flag = false; for (String anonymou : securityProperties.getAnonymous()) { PathMatcher pm = new AntPathMatcher(); if (pm.matchStart(anonymou, request.getRequestURI())) { - flag = false; + flag = true; break; } From bff9d0560d9c833c885f88f8ff0ab27aec8ef069 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: Sun, 26 Sep 2021 15:17:27 +0800 Subject: [PATCH 18/23] =?UTF-8?q?fix=20jwt=E8=BF=87=E6=BB=A4=E7=BC=96?= =?UTF-8?q?=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/filter/JwtAuthenticationTokenFilter.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index c5161c534..2b53e8372 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -39,14 +39,13 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter throws ServletException, IOException { // 匿名路径放行 默认拦截 - boolean flag = false; + boolean flag = true; for (String anonymou : securityProperties.getAnonymous()) { PathMatcher pm = new AntPathMatcher(); - if (pm.matchStart(anonymou, request.getRequestURI())) { - flag = true; + if (pm.match(anonymou, request.getRequestURI())) { + flag = false; break; } - } if (flag) { LoginUser loginUser = tokenService.getLoginUser(request); From 4a8781f4d974abd567e481822827aba93fac3ccc 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: Sun, 26 Sep 2021 15:18:05 +0800 Subject: [PATCH 19/23] =?UTF-8?q?fix=20jwt=E8=BF=87=E6=BB=A4=E7=BC=96?= =?UTF-8?q?=E5=86=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/security/filter/JwtAuthenticationTokenFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index 2b53e8372..aea860ccb 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -40,8 +40,8 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { // 匿名路径放行 默认拦截 boolean flag = true; + PathMatcher pm = new AntPathMatcher(); for (String anonymou : securityProperties.getAnonymous()) { - PathMatcher pm = new AntPathMatcher(); if (pm.match(anonymou, request.getRequestURI())) { flag = false; break; From aed8969498eb8fc39f8b461104f05009fe8533e1 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: Sun, 26 Sep 2021 15:37:40 +0800 Subject: [PATCH 20/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=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/framework/config/ServerConfig.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java deleted file mode 100644 index b5b7de316..000000000 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.ruoyi.framework.config; - -import javax.servlet.http.HttpServletRequest; -import org.springframework.stereotype.Component; -import com.ruoyi.common.utils.ServletUtils; - -/** - * 服务相关配置 - * - * @author ruoyi - */ -@Component -public class ServerConfig -{ - /** - * 获取完整的请求路径,包括:域名,端口,上下文访问路径 - * - * @return 服务地址 - */ - public String getUrl() - { - HttpServletRequest request = ServletUtils.getRequest(); - return getDomain(request); - } - - public static String getDomain(HttpServletRequest request) - { - StringBuffer url = request.getRequestURL(); - String contextPath = request.getServletContext().getContextPath(); - return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString(); - } -} From 369438a46d2d24da9afa1f296ecffa30cd1561a9 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: Sun, 26 Sep 2021 16:42:42 +0800 Subject: [PATCH 21/23] =?UTF-8?q?update=20=E5=9B=9E=E6=BB=9A=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/JwtAuthenticationTokenFilter.java | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index aea860ccb..967ef6464 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -4,14 +4,11 @@ import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.service.TokenService; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.config.properties.SecurityProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; import org.springframework.stereotype.Component; -import org.springframework.util.AntPathMatcher; -import org.springframework.util.PathMatcher; import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.FilterChain; @@ -31,30 +28,16 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter @Autowired private TokenService tokenService; - @Autowired - private SecurityProperties securityProperties; - @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { - // 匿名路径放行 默认拦截 - boolean flag = true; - PathMatcher pm = new AntPathMatcher(); - for (String anonymou : securityProperties.getAnonymous()) { - if (pm.match(anonymou, request.getRequestURI())) { - flag = false; - break; - } - } - if (flag) { - LoginUser loginUser = tokenService.getLoginUser(request); - if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) { - tokenService.verifyToken(loginUser); - UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); - authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); - SecurityContextHolder.getContext().setAuthentication(authenticationToken); - } + LoginUser loginUser = tokenService.getLoginUser(request); + if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) { + tokenService.verifyToken(loginUser); + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); + authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); + SecurityContextHolder.getContext().setAuthentication(authenticationToken); } chain.doFilter(request, response); } From bcac70b2abaf61ee3429cfcd8ed0b0d5b3c656b2 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: Sun, 26 Sep 2021 17:02:08 +0800 Subject: [PATCH 22/23] =?UTF-8?q?update=20=E6=89=A9=E5=B1=95=20security=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application.yml | 5 +++++ .../com/ruoyi/framework/config/SecurityConfig.java | 3 ++- .../config/properties/SecurityProperties.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 9f649edb0..6a7b7d007 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -108,6 +108,9 @@ token: # security配置 security: + # 登出路径 + logout-url: /logout + # 匿名路径 anonymous: - /login - /register @@ -122,6 +125,8 @@ security: # actuator 监控配置 - /actuator - /actuator/** + # 用户放行 + permit-all: # 重复提交 repeat-submit: diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 855be657c..229704f1b 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -109,11 +109,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter "/**/*.js" ).permitAll() .antMatchers(securityProperties.getAnonymous()).anonymous() + .antMatchers(securityProperties.getPermitAll()).permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() .headers().frameOptions().disable(); - httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler); + httpSecurity.logout().logoutUrl(securityProperties.getLogoutUrl()).logoutSuccessHandler(logoutSuccessHandler); // 添加JWT filter httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); // 添加CORS filter diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java index 33414cedb..c83ffccbe 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/SecurityProperties.java @@ -14,9 +14,19 @@ import org.springframework.stereotype.Component; @ConfigurationProperties(prefix = "security") public class SecurityProperties { + /** + * 退出登录url + */ + private String logoutUrl; + /** * 匿名放行路径 */ private String[] anonymous; + /** + * 用户任意访问放行路径 + */ + private String[] permitAll; + } From 3434610349c93037e9fc565600b151e0aed1672e 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: Sun, 26 Sep 2021 17:02:28 +0800 Subject: [PATCH 23/23] =?UTF-8?q?update=20=E6=8E=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20=E6=94=AF=E6=8C=81=E5=88=86=E7=BB=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 5 + .../ruoyi/framework/config/SwaggerConfig.java | 162 ++++++++++-------- .../config/properties/SwaggerProperties.java | 33 +++- 3 files changed, 121 insertions(+), 79 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 6a7b7d007..48464f1a6 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -243,6 +243,11 @@ swagger: name: Lion Li email: crazylionli@163.com url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus + groups: + - name: 演示案例 + basePackage: com.ruoyi.demo + - name: 系统模块 + basePackage: com.ruoyi.admin # 防止XSS攻击 xss: 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 2c65ac69d..4da3b9949 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 @@ -1,11 +1,12 @@ package com.ruoyi.framework.config; import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import com.ruoyi.common.properties.TokenProperties; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; 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; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; @@ -15,6 +16,7 @@ import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; +import javax.annotation.PostConstruct; import java.util.ArrayList; import java.util.List; @@ -27,82 +29,92 @@ import java.util.List; @EnableKnife4j public class SwaggerConfig { - @Autowired - private SwaggerProperties swaggerProperties; + @Autowired + private SwaggerProperties swaggerProperties; - /** - * 创建API - */ - @Bean - public Docket createRestApi() { - return new Docket(DocumentationType.OAS_30) - .enable(swaggerProperties.getEnabled()) - // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) - .apiInfo(apiInfo()) - // 设置哪些接口暴露给Swagger展示 - .select() - // 扫描所有有注解的api,用这种方式更灵活 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - // 扫描指定包中的swagger注解 - // .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger")) - // 扫描所有 .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build() - /* 设置安全模式,swagger可以设置访问token */ - .securitySchemes(securitySchemes()) - .securityContexts(securityContexts()) - .pathMapping(swaggerProperties.getPathMapping()); - } + @Autowired + private TokenProperties tokenProperties; - /** - * 安全模式,这里指定token通过Authorization头请求头传递 - */ - private List securitySchemes() { - List apiKeyList = new ArrayList(); - apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); - return apiKeyList; - } + /** + * 创建API + */ + @PostConstruct + public void createRestApi() { + for (SwaggerProperties.Groups group : swaggerProperties.getGroups()) { + String basePackage = group.getBasePackage(); + Docket docket = new Docket(DocumentationType.OAS_30) + .enable(swaggerProperties.getEnabled()) + // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) + .apiInfo(apiInfo()) + // 设置哪些接口暴露给Swagger展示 + .select() + // 扫描所有有注解的api,用这种方式更灵活 + //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + // 扫描指定包中的swagger注解 + .apis(RequestHandlerSelectors.basePackage(basePackage)) + // 扫描所有 .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + .groupName(group.getName()) + // 设置安全模式,swagger可以设置访问token + .securitySchemes(securitySchemes()) + .securityContexts(securityContexts()) + .pathMapping(swaggerProperties.getPathMapping()); + String beanName = StringUtils.substringAfterLast(basePackage, ".") + "Docket"; + SpringUtils.registerBean(beanName, docket); + } + } - /** - * 安全上下文 - */ - private List securityContexts() { - List securityContexts = new ArrayList<>(); - securityContexts.add( - SecurityContext.builder() - .securityReferences(defaultAuth()) - .operationSelector(o -> o.requestMappingPattern().matches("/.*")) - .build()); - return securityContexts; - } + /** + * 安全模式,这里指定token通过Authorization头请求头传递 + */ + private List securitySchemes() { + List apiKeyList = new ArrayList(); + String header = tokenProperties.getHeader(); + apiKeyList.add(new ApiKey(header, header, In.HEADER.toValue())); + return apiKeyList; + } - /** - * 默认的安全上引用 - */ - private List defaultAuth() { - AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); - AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; - authorizationScopes[0] = authorizationScope; - List securityReferences = new ArrayList<>(); - securityReferences.add(new SecurityReference("Authorization", authorizationScopes)); - return securityReferences; - } + /** + * 安全上下文 + */ + private List securityContexts() { + List securityContexts = new ArrayList<>(); + securityContexts.add( + SecurityContext.builder() + .securityReferences(defaultAuth()) + .operationSelector(o -> o.requestMappingPattern().matches("/.*")) + .build()); + return securityContexts; + } - /** - * 添加摘要信息 - */ - private ApiInfo apiInfo() { - // 用ApiInfoBuilder进行定制 - SwaggerProperties.Contact contact = swaggerProperties.getContact(); - return new ApiInfoBuilder() - // 设置标题 - .title(swaggerProperties.getTitle()) - // 描述 - .description(swaggerProperties.getDescription()) - // 作者信息 - .contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail())) - // 版本 - .version(swaggerProperties.getVersion()) - .build(); - } + /** + * 默认的安全上引用 + */ + private List defaultAuth() { + AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); + AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; + authorizationScopes[0] = authorizationScope; + List securityReferences = new ArrayList<>(); + securityReferences.add(new SecurityReference(tokenProperties.getHeader(), authorizationScopes)); + return securityReferences; + } + + /** + * 添加摘要信息 + */ + private ApiInfo apiInfo() { + // 用ApiInfoBuilder进行定制 + SwaggerProperties.Contact contact = swaggerProperties.getContact(); + return new ApiInfoBuilder() + // 设置标题 + .title(swaggerProperties.getTitle()) + // 描述 + .description(swaggerProperties.getDescription()) + // 作者信息 + .contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail())) + // 版本 + .version(swaggerProperties.getVersion()) + .build(); + } } 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 ece75efef..9c4cd238c 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 @@ -5,6 +5,8 @@ import lombok.NoArgsConstructor; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import java.util.List; + /** * swagger 配置属性 * @@ -41,23 +43,46 @@ public class SwaggerProperties { */ private Contact contact; + /** + * 组配置 + */ + private List groups; + @Data @NoArgsConstructor - public static class Contact{ + public static class Contact { /** * 联系人 - **/ + */ private String name; + /** * 联系人url - **/ + */ private String url; + /** * 联系人email - **/ + */ private String email; } + @Data + @NoArgsConstructor + public static class Groups { + + /** + * 组名 + */ + private String name; + + /** + * 基础包路径 + */ + private String basePackage; + + } + }