From 380b4e5f3aba8ad2b48d611db76e7552e61c9c7f 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: Tue, 25 May 2021 14:28:38 +0800 Subject: [PATCH 01/48] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application-dev.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 3a2a03d64..06456dd8d 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -1,7 +1,3 @@ ---- -server: - port: 8081 ---- # 数据源配置 spring: datasource: @@ -10,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://39.101.143.184:3306/ruoyi-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true - username: ruoyi-vue - password: ryvue + url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true + username: root + password: root # 从库数据源 slave: # 从数据源开关/默认关闭 @@ -62,13 +58,13 @@ spring: # redis 配置 redis: # 地址 - host: 39.101.143.184 + host: localhost # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # 密码 - password: ryvue + password: # 连接超时时间 timeout: 10s lettuce: From a42c1e4711449cd2697effc658f514463d18bb51 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: Tue, 25 May 2021 14:32:41 +0800 Subject: [PATCH 02/48] =?UTF-8?q?remove=20=E5=88=A0=E9=99=A4=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E9=94=99=E8=AF=AF=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/ExceptionUtil.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java deleted file mode 100644 index e69de29bb..000000000 From d2f0ea6fa08802cf865b8188b3999578366107d2 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, 26 May 2021 09:23:56 +0800 Subject: [PATCH 03/48] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8Dsql=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/system/service/impl/SysConfigServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index fbf6ec814..7c76c5713 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -55,10 +55,10 @@ public class SysConfigServiceImpl extends ServiceImpl= date_format(#{0},'%y%m%d')", + "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", params.get("beginTime")) .apply(Validator.isNotEmpty(params.get("endTime")), - "date_format(create_time,'%y%m%d') <= date_format(#{0},'%y%m%d')", + "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", params.get("endTime")); return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); } @@ -110,10 +110,10 @@ public class SysConfigServiceImpl extends ServiceImpl= date_format(#{0},'%y%m%d')", + "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", params.get("beginTime")) .apply(Validator.isNotEmpty(params.get("endTime")), - "date_format(create_time,'%y%m%d') >= date_format(#{0},'%y%m%d')", + "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", params.get("endTime")); return baseMapper.selectList(lqw); } From 8a6bc41938d6c2466b2ceb4eb5297cc1330ec6df 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, 26 May 2021 16:44:59 +0800 Subject: [PATCH 04/48] =?UTF-8?q?update=20=E6=96=87=E6=A1=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=BC=94=E7=A4=BA=E5=9B=BE=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ pom.xml | 8 ++++++++ 2 files changed, 49 insertions(+) diff --git a/README.md b/README.md index 796d57fba..778346524 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,47 @@ 17. 在线构建器:拖动表单元素生成相应的HTML代码。 18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。 +## 演示图例 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

+
+ ## 在线体验 - admin/admin123 diff --git a/pom.xml b/pom.xml index a197fd391..43c0aead1 100644 --- a/pom.xml +++ b/pom.xml @@ -248,6 +248,14 @@ + + local + + + local + debug + + dev From 6fa3bfe05184e9bcaadf00becee1d30f4abb9b1d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 27 May 2021 17:38:27 +0800 Subject: [PATCH 05/48] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=A4=E5=A4=84?= =?UTF-8?q?=E5=AD=98=E5=9C=A8SQL=E6=B3=A8=E5=85=A5=E6=BC=8F=E6=B4=9E?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/framework/aspectj/DataScopeAspect.java | 14 ++++++++++++++ .../main/resources/mapper/system/SysDeptMapper.xml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index a796f841c..e9884302c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -66,6 +66,7 @@ public class DataScopeAspect @Before("dataScopePointCut()") public void doBefore(JoinPoint point) throws Throwable { + clearDataScope(point); handleDataScope(point); } @@ -166,4 +167,17 @@ public class DataScopeAspect } return null; } + + /** + * 拼接权限sql前先清空params.dataScope参数防止注入 + */ + private void clearDataScope(final JoinPoint joinPoint) + { + Object params = joinPoint.getArgs()[0]; + if (StringUtils.isNotNull(params) && params instanceof BaseEntity) + { + BaseEntity baseEntity = (BaseEntity) params; + baseEntity.getParams().put(DATA_SCOPE, ""); + } + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index cdc26f4e2..3845730cb 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -147,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_by = #{updateBy}, update_time = sysdate() - where dept_id in (${ancestors}) + where find_in_set(#{deptId}, ancestors) From af9cfb40a4c37579f21624c9f72ea4d9759095ff Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 27 May 2021 17:38:44 +0800 Subject: [PATCH 06/48] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=82=E6=95=B0&?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=BC=93=E5=AD=98=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysConfigController.java | 11 ++-- .../system/SysDictDataController.java | 3 +- .../system/SysDictTypeController.java | 11 ++-- .../com/ruoyi/common/utils/DictUtils.java | 10 +++ .../system/service/ISysConfigService.java | 16 ++++- .../system/service/ISysDictDataService.java | 2 +- .../system/service/ISysDictTypeService.java | 16 ++++- .../service/impl/SysConfigServiceImpl.java | 44 ++++++++----- .../service/impl/SysDictDataServiceImpl.java | 29 +++++---- .../service/impl/SysDictTypeServiceImpl.java | 65 +++++++++++-------- ruoyi-ui/src/api/system/config.js | 6 +- ruoyi-ui/src/api/system/dict/type.js | 6 +- ruoyi-ui/src/views/system/config/index.vue | 14 ++-- ruoyi-ui/src/views/system/dict/index.vue | 14 ++-- 14 files changed, 155 insertions(+), 92 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java index 41b82098e..8678fd691 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -118,18 +118,19 @@ public class SysConfigController extends BaseController @DeleteMapping("/{configIds}") public AjaxResult remove(@PathVariable Long[] configIds) { - return toAjax(configService.deleteConfigByIds(configIds)); + configService.deleteConfigByIds(configIds); + return success(); } /** - * 清空缓存 + * 刷新参数缓存 */ @PreAuthorize("@ss.hasPermi('system:config:remove')") @Log(title = "参数管理", businessType = BusinessType.CLEAN) - @DeleteMapping("/clearCache") - public AjaxResult clearCache() + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() { - configService.clearCache(); + configService.resetConfigCache(); return AjaxResult.success(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index 8d0e87091..c044d2538 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -115,6 +115,7 @@ public class SysDictDataController extends BaseController @DeleteMapping("/{dictCodes}") public AjaxResult remove(@PathVariable Long[] dictCodes) { - return toAjax(dictDataService.deleteDictDataByIds(dictCodes)); + dictDataService.deleteDictDataByIds(dictCodes); + return success(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java index efde2d49f..3185f410b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -104,18 +104,19 @@ public class SysDictTypeController extends BaseController @DeleteMapping("/{dictIds}") public AjaxResult remove(@PathVariable Long[] dictIds) { - return toAjax(dictTypeService.deleteDictTypeByIds(dictIds)); + dictTypeService.deleteDictTypeByIds(dictIds); + return success(); } /** - * 清空缓存 + * 刷新字典缓存 */ @PreAuthorize("@ss.hasPermi('system:dict:remove')") @Log(title = "字典类型", businessType = BusinessType.CLEAN) - @DeleteMapping("/clearCache") - public AjaxResult clearCache() + @DeleteMapping("/refreshCache") + public AjaxResult refreshCache() { - dictTypeService.clearCache(); + dictTypeService.resetDictCache(); return AjaxResult.success(); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java index 0d3a23d51..16e7fca11 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -151,6 +151,16 @@ public class DictUtils return StringUtils.stripEnd(propertyString.toString(), separator); } + /** + * 删除指定字典缓存 + * + * @param key 字典键 + */ + public static void removeDictCache(String key) + { + SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key)); + } + /** * 清空字典缓存 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java index a937e8308..6b6842f34 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -56,12 +56,22 @@ public interface ISysConfigService * @param configIds 需要删除的参数ID * @return 结果 */ - public int deleteConfigByIds(Long[] configIds); + public void deleteConfigByIds(Long[] configIds); /** - * 清空缓存数据 + * 加载参数缓存数据 */ - public void clearCache(); + public void loadingConfigCache(); + + /** + * 清空参数缓存数据 + */ + public void clearConfigCache(); + + /** + * 重置参数缓存数据 + */ + public void resetConfigCache(); /** * 校验参数键名是否唯一 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java index 5fe8956be..63664cd6a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java @@ -41,7 +41,7 @@ public interface ISysDictDataService * @param dictCodes 需要删除的字典数据ID * @return 结果 */ - public int deleteDictDataByIds(Long[] dictCodes); + public void deleteDictDataByIds(Long[] dictCodes); /** * 新增保存字典数据信息 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java index 3603d896d..bbc065868 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java @@ -56,12 +56,22 @@ public interface ISysDictTypeService * @param dictIds 需要删除的字典ID * @return 结果 */ - public int deleteDictTypeByIds(Long[] dictIds); + public void deleteDictTypeByIds(Long[] dictIds); /** - * 清空缓存数据 + * 加载字典缓存数据 */ - public void clearCache(); + public void loadingDictCache(); + + /** + * 清空字典缓存数据 + */ + public void clearDictCache(); + + /** + * 重置字典缓存数据 + */ + public void resetDictCache(); /** * 新增保存字典类型信息 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index f1e2f29f6..41ef26198 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -37,11 +37,7 @@ public class SysConfigServiceImpl implements ISysConfigService @PostConstruct public void init() { - List configsList = configMapper.selectConfigList(new SysConfig()); - for (SysConfig config : configsList) - { - redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } + loadingConfigCache(); } /** @@ -137,7 +133,7 @@ public class SysConfigServiceImpl implements ISysConfigService * @return 结果 */ @Override - public int deleteConfigByIds(Long[] configIds) + public void deleteConfigByIds(Long[] configIds) { for (Long configId : configIds) { @@ -146,26 +142,44 @@ public class SysConfigServiceImpl implements ISysConfigService { throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); } + configMapper.deleteConfigById(configId); + redisCache.deleteObject(getCacheKey(config.getConfigKey())); } - int count = configMapper.deleteConfigByIds(configIds); - if (count > 0) - { - Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); - redisCache.deleteObject(keys); - } - return count; } /** - * 清空缓存数据 + * 加载参数缓存数据 */ @Override - public void clearCache() + public void loadingConfigCache() + { + List configsList = configMapper.selectConfigList(new SysConfig()); + for (SysConfig config : configsList) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + } + + /** + * 清空参数缓存数据 + */ + @Override + public void clearConfigCache() { Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); redisCache.deleteObject(keys); } + /** + * 重置参数缓存数据 + */ + @Override + public void resetConfigCache() + { + clearConfigCache(); + loadingConfigCache(); + } + /** * 校验参数键名是否唯一 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java index 39d950531..5500f7350 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -63,29 +63,31 @@ public class SysDictDataServiceImpl implements ISysDictDataService * @return 结果 */ @Override - public int deleteDictDataByIds(Long[] dictCodes) + public void deleteDictDataByIds(Long[] dictCodes) { - int row = dictDataMapper.deleteDictDataByIds(dictCodes); - if (row > 0) + for (Long dictCode : dictCodes) { - DictUtils.clearDictCache(); + SysDictData data = selectDictDataById(dictCode); + dictDataMapper.deleteDictDataById(dictCode); + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); } - return row; } /** * 新增保存字典数据信息 * - * @param dictData 字典数据信息 + * @param data 字典数据信息 * @return 结果 */ @Override - public int insertDictData(SysDictData dictData) + public int insertDictData(SysDictData data) { - int row = dictDataMapper.insertDictData(dictData); + int row = dictDataMapper.insertDictData(data); if (row > 0) { - DictUtils.clearDictCache(); + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); } return row; } @@ -93,16 +95,17 @@ public class SysDictDataServiceImpl implements ISysDictDataService /** * 修改保存字典数据信息 * - * @param dictData 字典数据信息 + * @param data 字典数据信息 * @return 结果 */ @Override - public int updateDictData(SysDictData dictData) + public int updateDictData(SysDictData data) { - int row = dictDataMapper.updateDictData(dictData); + int row = dictDataMapper.updateDictData(data); if (row > 0) { - DictUtils.clearDictCache(); + List dictDatas = dictDataMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); } return row; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java index 2db4341b4..d2daae438 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -35,12 +35,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService @PostConstruct public void init() { - List dictTypeList = dictTypeMapper.selectDictTypeAll(); - for (SysDictType dictType : dictTypeList) - { - List dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); - DictUtils.setDictCache(dictType.getDictType(), dictDatas); - } + loadingDictCache(); } /** @@ -120,7 +115,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService * @return 结果 */ @Override - public int deleteDictTypeByIds(Long[] dictIds) + public void deleteDictTypeByIds(Long[] dictIds) { for (Long dictId : dictIds) { @@ -129,37 +124,54 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService { throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName())); } + dictTypeMapper.deleteDictTypeById(dictId); + DictUtils.removeDictCache(dictType.getDictType()); } - int count = dictTypeMapper.deleteDictTypeByIds(dictIds); - if (count > 0) - { - DictUtils.clearDictCache(); - } - return count; } /** - * 清空缓存数据 + * 加载字典缓存数据 */ - @Override - public void clearCache() + public void loadingDictCache() + { + List dictTypeList = dictTypeMapper.selectDictTypeAll(); + for (SysDictType dictType : dictTypeList) + { + List dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); + DictUtils.setDictCache(dictType.getDictType(), dictDatas); + } + } + + /** + * 清空字典缓存数据 + */ + public void clearDictCache() { DictUtils.clearDictCache(); } + /** + * 重置字典缓存数据 + */ + public void resetDictCache() + { + clearDictCache(); + loadingDictCache(); + } + /** * 新增保存字典类型信息 * - * @param dictType 字典类型信息 + * @param dict 字典类型信息 * @return 结果 */ @Override - public int insertDictType(SysDictType dictType) + public int insertDictType(SysDictType dict) { - int row = dictTypeMapper.insertDictType(dictType); + int row = dictTypeMapper.insertDictType(dict); if (row > 0) { - DictUtils.clearDictCache(); + DictUtils.setDictCache(dict.getDictType(), null); } return row; } @@ -167,19 +179,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService /** * 修改保存字典类型信息 * - * @param dictType 字典类型信息 + * @param dict 字典类型信息 * @return 结果 */ @Override @Transactional - public int updateDictType(SysDictType dictType) + public int updateDictType(SysDictType dict) { - SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); - dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); - int row = dictTypeMapper.updateDictType(dictType); + SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId()); + dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType()); + int row = dictTypeMapper.updateDictType(dict); if (row > 0) { - DictUtils.clearDictCache(); + List dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); + DictUtils.setDictCache(dict.getDictType(), dictDatas); } return row; } diff --git a/ruoyi-ui/src/api/system/config.js b/ruoyi-ui/src/api/system/config.js index 2221540e5..f1f872757 100644 --- a/ruoyi-ui/src/api/system/config.js +++ b/ruoyi-ui/src/api/system/config.js @@ -51,10 +51,10 @@ export function delConfig(configId) { }) } -// 清理参数缓存 -export function clearCache() { +// 刷新参数缓存 +export function refreshCache() { return request({ - url: '/system/config/clearCache', + url: '/system/config/refreshCache', method: 'delete' }) } diff --git a/ruoyi-ui/src/api/system/dict/type.js b/ruoyi-ui/src/api/system/dict/type.js index d392f5042..2c66bd5fb 100644 --- a/ruoyi-ui/src/api/system/dict/type.js +++ b/ruoyi-ui/src/api/system/dict/type.js @@ -43,10 +43,10 @@ export function delType(dictId) { }) } -// 清理参数缓存 -export function clearCache() { +// 刷新字典缓存 +export function refreshCache() { return request({ - url: '/system/dict/type/clearCache', + url: '/system/dict/type/refreshCache', method: 'delete' }) } diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue index aff5089e6..d6275f532 100644 --- a/ruoyi-ui/src/views/system/config/index.vue +++ b/ruoyi-ui/src/views/system/config/index.vue @@ -99,9 +99,9 @@ plain icon="el-icon-refresh" size="mini" - @click="handleClearCache" + @click="handleRefreshCache" v-hasPermi="['system:config:remove']" - >清理缓存 + >刷新缓存 @@ -181,7 +181,7 @@ From a02aeb468e1930eb0da6ddfef70ee635a3929180 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, 30 May 2021 02:25:14 +0800 Subject: [PATCH 22/48] =?UTF-8?q?add=20=E5=A2=9E=E5=8A=A0demo=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=20=E6=A0=91=E8=A1=A8=E6=BC=94=E7=A4=BA=E6=A1=88?= =?UTF-8?q?=E4=BE=8B(=E5=8C=85=E5=90=AB=E6=95=B0=E6=8D=AE=E6=9D=83?= =?UTF-8?q?=E9=99=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/demo/bo/TestTreeAddBo.java | 39 +++ .../com/ruoyi/demo/bo/TestTreeEditBo.java | 47 +++ .../com/ruoyi/demo/bo/TestTreeQueryBo.java | 42 +++ .../demo/controller/TestTreeController.java | 107 +++++++ .../java/com/ruoyi/demo/domain/TestTree.java | 67 +++++ .../com/ruoyi/demo/mapper/TestTreeMapper.java | 14 + .../ruoyi/demo/service/ITestTreeService.java | 52 ++++ .../service/impl/TestTreeServiceImpl.java | 84 ++++++ .../java/com/ruoyi/demo/vo/TestTreeVo.java | 55 ++++ .../resources/mapper/demo/TestTreeMapper.xml | 22 ++ ruoyi-ui/src/api/demo/tree.js | 53 ++++ ruoyi-ui/src/views/demo/tree/index.vue | 282 ++++++++++++++++++ 12 files changed, 864 insertions(+) create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeAddBo.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeEditBo.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeQueryBo.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestTreeController.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/domain/TestTree.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestTreeMapper.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/service/ITestTreeService.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TestTreeServiceImpl.java create mode 100644 ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java create mode 100644 ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml create mode 100644 ruoyi-ui/src/api/demo/tree.js create mode 100644 ruoyi-ui/src/views/demo/tree/index.vue diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeAddBo.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeAddBo.java new file mode 100644 index 000000000..a9a4b5e3f --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeAddBo.java @@ -0,0 +1,39 @@ +package com.ruoyi.demo.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import java.util.Date; +import javax.validation.constraints.*; + + + +/** + * 测试树表添加对象 test_tree + * + * @author Lion Li + * @date 2021-05-30 + */ +@Data +@ApiModel("测试树表添加对象") +public class TestTreeAddBo { + + /** 父id */ + @ApiModelProperty("父id") + private Long parentId; + + /** 部门id */ + @ApiModelProperty("部门id") + private Long deptId; + + /** 用户id */ + @ApiModelProperty("用户id") + private Long userId; + + /** 树节点名 */ + @ApiModelProperty("树节点名") + @NotBlank(message = "树节点名不能为空") + private String treeName; + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeEditBo.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeEditBo.java new file mode 100644 index 000000000..e3d359d00 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeEditBo.java @@ -0,0 +1,47 @@ +package com.ruoyi.demo.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import java.util.Date; +import javax.validation.constraints.*; + + +/** + * 测试树表编辑对象 test_tree + * + * @author Lion Li + * @date 2021-05-30 + */ +@Data +@ApiModel("测试树表编辑对象") +public class TestTreeEditBo { + + + /** 主键 */ + @ApiModelProperty("主键") + private Long id; + + + /** 父id */ + @ApiModelProperty("父id") + private Long parentId; + + + /** 部门id */ + @ApiModelProperty("部门id") + private Long deptId; + + + /** 用户id */ + @ApiModelProperty("用户id") + private Long userId; + + + /** 树节点名 */ + @ApiModelProperty("树节点名") + @NotBlank(message = "树节点名不能为空") + private String treeName; + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeQueryBo.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeQueryBo.java new file mode 100644 index 000000000..3ed482b35 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/bo/TestTreeQueryBo.java @@ -0,0 +1,42 @@ +package com.ruoyi.demo.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 测试树表分页查询对象 test_tree + * + * @author Lion Li + * @date 2021-05-30 + */ + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("测试树表分页查询对象") +public class TestTreeQueryBo extends BaseEntity { + + /** 分页大小 */ + @ApiModelProperty("分页大小") + private Integer pageSize; + /** 当前页数 */ + @ApiModelProperty("当前页数") + private Integer pageNum; + /** 排序列 */ + @ApiModelProperty("排序列") + private String orderByColumn; + /** 排序的方向desc或者asc */ + @ApiModelProperty(value = "排序的方向", example = "asc,desc") + private String isAsc; + + + /** 树节点名 */ + @ApiModelProperty("树节点名") + private String treeName; + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestTreeController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestTreeController.java new file mode 100644 index 000000000..54f1027ed --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/TestTreeController.java @@ -0,0 +1,107 @@ +package com.ruoyi.demo.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.demo.bo.TestTreeAddBo; +import com.ruoyi.demo.bo.TestTreeEditBo; +import com.ruoyi.demo.bo.TestTreeQueryBo; +import com.ruoyi.demo.service.ITestTreeService; +import com.ruoyi.demo.vo.TestTreeVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.Arrays; +import java.util.List; + +/** + * 测试树表Controller + * + * @author Lion Li + * @date 2021-05-30 + */ +@Api(value = "测试树表控制器", tags = {"测试树表管理"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController +@RequestMapping("/demo/tree") +public class TestTreeController extends BaseController { + + private final ITestTreeService iTestTreeService; + + /** + * 查询测试树表列表 + */ + @ApiOperation("查询测试树表列表") + @PreAuthorize("@ss.hasPermi('demo:tree:list')") + @GetMapping("/list") + public AjaxResult> list(@Validated TestTreeQueryBo bo) { + return AjaxResult.success(iTestTreeService.queryList(bo)); + } + + /** + * 导出测试树表列表 + */ + @ApiOperation("导出测试树表列表") + @PreAuthorize("@ss.hasPermi('demo:tree:export')") + @Log(title = "测试树表", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(@Validated TestTreeQueryBo bo) { + List list = iTestTreeService.queryList(bo); + ExcelUtil util = new ExcelUtil(TestTreeVo.class); + return util.exportExcel(list, "测试树表"); + } + + /** + * 获取测试树表详细信息 + */ + @ApiOperation("获取测试树表详细信息") + @PreAuthorize("@ss.hasPermi('demo:tree:query')") + @GetMapping("/{id}") + public AjaxResult getInfo(@NotNull(message = "主键不能为空") + @PathVariable("id") Long id) { + return AjaxResult.success(iTestTreeService.queryById(id)); + } + + /** + * 新增测试树表 + */ + @ApiOperation("新增测试树表") + @PreAuthorize("@ss.hasPermi('demo:tree:add')") + @Log(title = "测试树表", businessType = BusinessType.INSERT) + @PostMapping() + public AjaxResult add(@Validated @RequestBody TestTreeAddBo bo) { + return toAjax(iTestTreeService.insertByAddBo(bo) ? 1 : 0); + } + + /** + * 修改测试树表 + */ + @ApiOperation("修改测试树表") + @PreAuthorize("@ss.hasPermi('demo:tree:edit')") + @Log(title = "测试树表", businessType = BusinessType.UPDATE) + @PutMapping() + public AjaxResult edit(@Validated @RequestBody TestTreeEditBo bo) { + return toAjax(iTestTreeService.updateByEditBo(bo) ? 1 : 0); + } + + /** + * 删除测试树表 + */ + @ApiOperation("删除测试树表") + @PreAuthorize("@ss.hasPermi('demo:tree:remove')") + @Log(title = "测试树表" , businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(iTestTreeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); + } +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/domain/TestTree.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/domain/TestTree.java new file mode 100644 index 000000000..43d1efe5d --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/domain/TestTree.java @@ -0,0 +1,67 @@ +package com.ruoyi.demo.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import java.io.Serializable; +import java.util.Date; +import java.math.BigDecimal; +import com.ruoyi.common.annotation.Excel; + +/** + * 测试树表对象 test_tree + * + * @author Lion Li + * @date 2021-05-30 + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +@TableName("test_tree") +public class TestTree implements Serializable { + + private static final long serialVersionUID=1L; + + + /** 主键 */ + @TableId(value = "id") + private Long id; + + /** 父id */ + private Long parentId; + + /** 部门id */ + private Long deptId; + + /** 用户id */ + private Long userId; + + /** 树节点名 */ + private String treeName; + + /** 版本 */ + @Version + private Long version; + + /** 创建时间 */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** 创建人 */ + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** 更新时间 */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + /** 更新人 */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updateBy; + + /** 删除标志 */ + @TableLogic + private Long delFlag; + +} 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 new file mode 100644 index 000000000..6dd75c50d --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/mapper/TestTreeMapper.java @@ -0,0 +1,14 @@ +package com.ruoyi.demo.mapper; + +import com.ruoyi.demo.domain.TestTree; +import com.ruoyi.common.core.page.BaseMapperPlus; + +/** + * 测试树表Mapper接口 + * + * @author Lion Li + * @date 2021-05-30 + */ +public interface TestTreeMapper extends BaseMapperPlus { + +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/service/ITestTreeService.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/service/ITestTreeService.java new file mode 100644 index 000000000..605b3dfda --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/service/ITestTreeService.java @@ -0,0 +1,52 @@ +package com.ruoyi.demo.service; + +import com.ruoyi.common.core.page.IServicePlus; +import com.ruoyi.demo.bo.TestTreeAddBo; +import com.ruoyi.demo.bo.TestTreeEditBo; +import com.ruoyi.demo.bo.TestTreeQueryBo; +import com.ruoyi.demo.domain.TestTree; +import com.ruoyi.demo.vo.TestTreeVo; + +import java.util.Collection; +import java.util.List; + +/** + * 测试树表Service接口 + * + * @author Lion Li + * @date 2021-05-30 + */ +public interface ITestTreeService extends IServicePlus { + /** + * 查询单个 + * @return + */ + TestTreeVo queryById(Long id); + + /** + * 查询列表 + */ + List queryList(TestTreeQueryBo bo); + + /** + * 根据新增业务对象插入测试树表 + * @param bo 测试树表新增业务对象 + * @return + */ + Boolean insertByAddBo(TestTreeAddBo bo); + + /** + * 根据编辑业务对象修改测试树表 + * @param bo 测试树表编辑业务对象 + * @return + */ + Boolean updateByEditBo(TestTreeEditBo bo); + + /** + * 校验并删除数据 + * @param ids 主键集合 + * @param isValid 是否校验,true-删除前校验,false-不校验 + * @return + */ + Boolean deleteWithValidByIds(Collection ids, Boolean isValid); +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TestTreeServiceImpl.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TestTreeServiceImpl.java new file mode 100644 index 000000000..ae93ef377 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/TestTreeServiceImpl.java @@ -0,0 +1,84 @@ +package com.ruoyi.demo.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.demo.bo.TestTreeAddBo; +import com.ruoyi.demo.bo.TestTreeEditBo; +import com.ruoyi.demo.bo.TestTreeQueryBo; +import com.ruoyi.demo.domain.TestTree; +import com.ruoyi.demo.mapper.TestTreeMapper; +import com.ruoyi.demo.service.ITestTreeService; +import com.ruoyi.demo.vo.TestTreeVo; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +/** + * 测试树表Service业务层处理 + * + * @author Lion Li + * @date 2021-05-30 + */ +@Service +public class TestTreeServiceImpl extends ServiceImpl implements ITestTreeService { + + @Override + public TestTreeVo queryById(Long id) { + return getVoById(id, TestTreeVo.class); + } + + @DataScope(isUser = true) + @Override + public List queryList(TestTreeQueryBo bo) { + return listVo(buildQueryWrapper(bo), TestTreeVo.class); + } + + private LambdaQueryWrapper buildQueryWrapper(TestTreeQueryBo bo) { + Map params = bo.getParams(); + Object dataScope = params.get("dataScope"); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.like(StrUtil.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); + lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, + TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); + lqw.apply(dataScope != null && StrUtil.isNotBlank(dataScope.toString()), + dataScope != null ? dataScope.toString() : null); + return lqw; + } + + @Override + public Boolean insertByAddBo(TestTreeAddBo bo) { + TestTree add = BeanUtil.toBean(bo, TestTree.class); + validEntityBeforeSave(add); + return save(add); + } + + @Override + public Boolean updateByEditBo(TestTreeEditBo bo) { + TestTree update = BeanUtil.toBean(bo, TestTree.class); + validEntityBeforeSave(update); + return updateById(update); + } + + /** + * 保存前的数据校验 + * + * @param entity 实体类数据 + */ + private void validEntityBeforeSave(TestTree entity) { + //TODO 做一些数据校验,如唯一约束 + } + + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if (isValid) { + //TODO 做一些业务上的校验,判断是否需要校验 + } + return removeByIds(ids); + } +} diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java new file mode 100644 index 000000000..44413b120 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/vo/TestTreeVo.java @@ -0,0 +1,55 @@ +package com.ruoyi.demo.vo; + +import com.ruoyi.common.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; + + + +/** + * 测试树表视图对象 test_tree + * + * @author Lion Li + * @date 2021-05-30 + */ +@Data +@ApiModel("测试树表视图对象") +public class TestTreeVo { + + private static final long serialVersionUID = 1L; + + /** 主键 */ + @ApiModelProperty("主键") + private Long id; + + /** 父id */ + @Excel(name = "父id") + @ApiModelProperty("父id") + private Long parentId; + + /** 部门id */ + @Excel(name = "部门id") + @ApiModelProperty("部门id") + private Long deptId; + + /** 用户id */ + @Excel(name = "用户id") + @ApiModelProperty("用户id") + private Long userId; + + /** 树节点名 */ + @Excel(name = "树节点名") + @ApiModelProperty("树节点名") + private String treeName; + + /** 创建时间 */ + @Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("创建时间") + private Date createTime; + + +} diff --git a/ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml b/ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml new file mode 100644 index 000000000..0943d5b14 --- /dev/null +++ b/ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-ui/src/api/demo/tree.js b/ruoyi-ui/src/api/demo/tree.js new file mode 100644 index 000000000..d597e7261 --- /dev/null +++ b/ruoyi-ui/src/api/demo/tree.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询测试树表列表 +export function listTree(query) { + return request({ + url: '/demo/tree/list', + method: 'get', + params: query + }) +} + +// 查询测试树表详细 +export function getTree(id) { + return request({ + url: '/demo/tree/' + id, + method: 'get' + }) +} + +// 新增测试树表 +export function addTree(data) { + return request({ + url: '/demo/tree', + method: 'post', + data: data + }) +} + +// 修改测试树表 +export function updateTree(data) { + return request({ + url: '/demo/tree', + method: 'put', + data: data + }) +} + +// 删除测试树表 +export function delTree(id) { + return request({ + url: '/demo/tree/' + id, + method: 'delete' + }) +} + +// 导出测试树表 +export function exportTree(query) { + return request({ + url: '/demo/tree/export', + method: 'get', + params: query + }) +} \ No newline at end of file diff --git a/ruoyi-ui/src/views/demo/tree/index.vue b/ruoyi-ui/src/views/demo/tree/index.vue new file mode 100644 index 000000000..ddf767777 --- /dev/null +++ b/ruoyi-ui/src/views/demo/tree/index.vue @@ -0,0 +1,282 @@ + + + From 7b7f098deeef28e33780a9c032b0062824daa1b3 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, 30 May 2021 02:25:56 +0800 Subject: [PATCH 23/48] =?UTF-8?q?update=20=E6=96=87=E6=A1=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4aab64385..2305fe14b 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,9 @@ * 代码生成选择树表生成即可 关于数据权限 -* 参考(用户,角色,部门)列表接口用法 -* 目前仅支持 XML 方式使用(后续修改为支持MP) +* 创建表 需预留 dept_id 字段 如需用户权限 还需预留 user_id 字段 +* 支持 Mybatis-Plus 方式注入 参考 demo 模块用法(需导入 test.sql 文件) +* 支持 XML 方式注入 参考 system 模块用法 关于vue与boot整合部署 * [前端静态资源如何整合到后端访问](https://doc.ruoyi.vip/ruoyi-vue/other/faq.html#前端静态资源如何整合到后端访问) From 01fef0b9e19acb07fec138f09b07b7b3fdee5862 Mon Sep 17 00:00:00 2001 From: xx2yy <50043243@qq.com> Date: Mon, 31 May 2021 10:31:50 +0800 Subject: [PATCH 24/48] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=81=E4=BF=AE=E6=94=B9=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E2=80=9C=E5=8A=9F=E8=83=BD=E6=9D=83=E9=99=90=E2=80=9Dmaxlength?= =?UTF-8?q?=E4=B8=BA100=EF=BC=88=E4=BF=9D=E6=8C=81=E4=B8=8E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6=E4=B8=80?= =?UTF-8?q?=E8=87=B4=EF=BC=89=EF=BC=8C=E9=81=BF=E5=85=8D=E5=9B=A0=E8=B6=85?= =?UTF-8?q?=E8=BF=8750=E5=90=8E=E4=B8=8D=E8=83=BD=E5=BD=95=E5=85=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/system/menu/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index 734e8e8c0..cee61b737 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -163,7 +163,7 @@ - + From c105a63c8bae82958e76d3a36a6e24893bdbed6f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 31 May 2021 12:16:27 +0800 Subject: [PATCH 25/48] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bat=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/controller/BaseController.java | 13 ++ ry.bat | 67 +++++++ ry.sh | 176 +++++++++--------- 3 files changed, 170 insertions(+), 86 deletions(-) create mode 100644 ry.bat diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index 136bbacb4..80ac645fa 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -59,6 +59,19 @@ public class BaseController } } + /** + * 设置请求排序数据 + */ + protected void startOrderBy() + { + PageDomain pageDomain = TableSupport.buildPageRequest(); + if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) + { + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + PageHelper.orderBy(orderBy); + } + } + /** * 响应请求分页数据 */ diff --git a/ry.bat b/ry.bat new file mode 100644 index 000000000..5de3e1503 --- /dev/null +++ b/ry.bat @@ -0,0 +1,67 @@ +@echo off + +rem jarƽĿ¼ +set AppName=ruoyi-admin.jar + +rem JVM +set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" + + +ECHO. + ECHO. [1] %AppName% + ECHO. [2] ر%AppName% + ECHO. [3] %AppName% + ECHO. [4] ״̬ %AppName% + ECHO. [5] +ECHO. + +ECHO.ѡĿ: +set /p ID= + IF "%id%"=="1" GOTO start + IF "%id%"=="2" GOTO stop + IF "%id%"=="3" GOTO restart + IF "%id%"=="4" GOTO status + IF "%id%"=="5" EXIT +PAUSE +:start + for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( + set pid=%%a + set image_name=%%b + ) + if defined pid ( + echo %%is running + PAUSE + ) + +start javaw -jar %JAVA_OPTS% ruoyi-admin.jar + +echo starting +echo Start %AppName% success... +goto:eof + +rem stopͨjpspid +:stop + for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( + set pid=%%a + set image_name=%%b + ) + if not defined pid (echo process %AppName% does not exists) else ( + echo prepare to kill %image_name% + echo start kill %pid% ... + rem ݽIDkill + taskkill /f /pid %pid% + ) +goto:eof +:restart + call :stop + call :start +goto:eof +:status + for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( + set pid=%%a + set image_name=%%b + ) + if not defined pid (echo process %AppName% is dead ) else ( + echo %image_name% is running + ) +goto:eof \ No newline at end of file diff --git a/ry.sh b/ry.sh index 6558b9785..bec5de488 100644 --- a/ry.sh +++ b/ry.sh @@ -1,86 +1,90 @@ -#!/bin/bash - -AppName=ruoyi-admin.jar - -#JVM参数 -JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" -APP_HOME=`pwd` -LOG_PATH=$APP_HOME/logs/$AppName.log - -if [ "$1" = "" ]; -then - echo -e "\033[0;31m 未输入操作名 \033[0m \033[0;34m {start|stop|restart|status} \033[0m" - exit 1 -fi - -if [ "$AppName" = "" ]; -then - echo -e "\033[0;31m 未输入应用名 \033[0m" - exit 1 -fi - -function start() -{ - PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` - - if [ x"$PID" != x"" ]; then - echo "$AppName is running..." - else - nohup java -jar $JVM_OPTS target/$AppName > /dev/null 2>&1 & - echo "Start $AppName success..." - fi -} - -function stop() -{ - echo "Stop $AppName" - - PID="" - query(){ - PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` - } - - query - if [ x"$PID" != x"" ]; then - kill -TERM $PID - echo "$AppName (pid:$PID) exiting..." - while [ x"$PID" != x"" ] - do - sleep 1 - query - done - echo "$AppName exited." - else - echo "$AppName already stopped." - fi -} - -function restart() -{ - stop - sleep 2 - start -} - -function status() -{ - PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l` - if [ $PID != 0 ];then - echo "$AppName is running..." - else - echo "$AppName is not running..." - fi -} - -case $1 in - start) - start;; - stop) - stop;; - restart) - restart;; - status) - status;; - *) - -esac +#!/bin/sh +# author ruoyi +# ./ry.sh start 启动 +# ./ry.sh stop 停止 +# ./ry.sh restart 重启 +# ./ry.sh start 状态 +AppName=ruoyi-admin.jar + +# JVM参数 +JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" +APP_HOME=`pwd` +LOG_PATH=$APP_HOME/logs/$AppName.log + +if [ "$1" = "" ]; +then + echo -e "\033[0;31m 未输入操作名 \033[0m \033[0;34m {start|stop|restart|status} \033[0m" + exit 1 +fi + +if [ "$AppName" = "" ]; +then + echo -e "\033[0;31m 未输入应用名 \033[0m" + exit 1 +fi + +function start() +{ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` + + if [ x"$PID" != x"" ]; then + echo "$AppName is running..." + else + nohup java -jar $JVM_OPTS target/$AppName > /dev/null 2>&1 & + echo "Start $AppName success..." + fi +} + +function stop() +{ + echo "Stop $AppName" + + PID="" + query(){ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` + } + + query + if [ x"$PID" != x"" ]; then + kill -TERM $PID + echo "$AppName (pid:$PID) exiting..." + while [ x"$PID" != x"" ] + do + sleep 1 + query + done + echo "$AppName exited." + else + echo "$AppName already stopped." + fi +} + +function restart() +{ + stop + sleep 2 + start +} + +function status() +{ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l` + if [ $PID != 0 ];then + echo "$AppName is running..." + else + echo "$AppName is not running..." + fi +} + +case $1 in + start) + start;; + stop) + stop;; + restart) + restart;; + status) + status;; + *) + +esac From 079dc12fe13d4b24d9b652f22f335e4f6b7b0465 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: Mon, 31 May 2021 16:55:26 +0800 Subject: [PATCH 26/48] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20system=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=20=E5=88=A0=E9=99=A4=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/system/service/impl/SysConfigServiceImpl.java | 3 ++- .../ruoyi/system/service/impl/SysDictDataServiceImpl.java | 3 ++- .../ruoyi/system/service/impl/SysDictTypeServiceImpl.java | 6 ++---- .../com/ruoyi/system/service/impl/SysUserServiceImpl.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 7b5d061ca..d0b37c5e3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; @@ -157,9 +158,9 @@ public class SysConfigServiceImpl extends ServiceImpl dictDatas = baseMapper.selectDictDataByType(data.getDictType()); DictUtils.setDictCache(data.getDictType(), dictDatas); } + baseMapper.deleteBatchIds(Arrays.asList(dictCodes)); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java index 79a4036ed..c4f9d955d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -32,9 +33,6 @@ import java.util.Map; @Service public class SysDictTypeServiceImpl extends ServiceImpl implements ISysDictTypeService { - @Autowired - private SysDictTypeMapper dictTypeMapper; - @Autowired private SysDictDataMapper dictDataMapper; @@ -149,9 +147,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl 0) { throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName())); } - dictTypeMapper.deleteById(dictId); DictUtils.removeDictCache(dictType.getDictType()); } + baseMapper.deleteBatchIds(Arrays.asList(dictIds)); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index f729a8180..3133703f3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -100,7 +100,7 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override public String selectUserRoleGroup(String userName) { List list = roleMapper.selectRolesByUserName(userName); - StringBuffer idsStr = new StringBuffer(); + StringBuilder idsStr = new StringBuilder(); for (SysRole role : list) { idsStr.append(role.getRoleName()).append(","); } @@ -119,7 +119,7 @@ public class SysUserServiceImpl extends ServiceImpl impl @Override public String selectUserPostGroup(String userName) { List list = postMapper.selectPostsByUserName(userName); - StringBuffer idsStr = new StringBuffer(); + StringBuilder idsStr = new StringBuilder(); for (SysPost post : list) { idsStr.append(post.getPostName()).append(","); } From 8ba346faa6318bc78b5427a7feede5474c9e03d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=9D=B0?= <693337446@qq.com> Date: Mon, 31 May 2021 17:23:13 +0800 Subject: [PATCH 27/48] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E4=B8=AD=E6=89=B9=E9=87=8F=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8E=9F=E7=94=9Fmybatis=E6=89=A7=E8=A1=8Cfo?= =?UTF-8?q?reach=EF=BC=8C=E6=94=B9=E5=96=84=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/system/mapper/SysDeptMapper.java | 8 ++++++++ .../com/ruoyi/system/mapper/SysRoleDeptMapper.java | 10 ++++++++++ .../com/ruoyi/system/mapper/SysRoleMenuMapper.java | 10 ++++++++++ .../com/ruoyi/system/mapper/SysUserPostMapper.java | 10 ++++++++++ .../com/ruoyi/system/mapper/SysUserRoleMapper.java | 10 ++++++++++ .../system/service/impl/SysDeptServiceImpl.java | 2 +- .../system/service/impl/SysRoleServiceImpl.java | 8 ++------ .../system/service/impl/SysUserServiceImpl.java | 8 ++------ .../main/resources/mapper/system/SysDeptMapper.xml | 13 +++++++++++++ .../resources/mapper/system/SysRoleDeptMapper.xml | 9 ++++++++- .../resources/mapper/system/SysRoleMenuMapper.xml | 9 ++++++++- .../resources/mapper/system/SysUserPostMapper.xml | 9 ++++++++- .../resources/mapper/system/SysUserRoleMapper.xml | 9 ++++++++- 13 files changed, 98 insertions(+), 17 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 12824e753..54fe2611f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -30,4 +30,12 @@ public interface SysDeptMapper extends BaseMapperPlus { */ public List selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java index 6121490c2..331ecb911 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysRoleDept; +import java.util.List; + /** * 角色与部门关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysRoleDept; */ public interface SysRoleDeptMapper extends BaseMapperPlus { + /** + * 批量新增角色部门信息 + * + * @param roleDeptList 角色部门列表 + * @return 结果 + */ + public int batchRoleDept(List roleDeptList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java index fa8c5a34d..4f08ceaee 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysRoleMenu; +import java.util.List; + /** * 角色与菜单关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysRoleMenu; */ public interface SysRoleMenuMapper extends BaseMapperPlus { + /** + * 批量新增角色菜单信息 + * + * @param roleMenuList 角色菜单列表 + * @return 结果 + */ + public int batchRoleMenu(List roleMenuList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java index c17dfd5fa..7839bbe17 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysUserPost; +import java.util.List; + /** * 用户与岗位关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysUserPost; */ public interface SysUserPostMapper extends BaseMapperPlus { + /** + * 批量新增用户岗位信息 + * + * @param userPostList 用户角色列表 + * @return 结果 + */ + public int batchUserPost(List userPostList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index ddebd389b..365bbf47d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysUserRole; +import java.util.List; + /** * 用户与角色关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysUserRole; */ public interface SysUserRoleMapper extends BaseMapperPlus { + /** + * 批量新增用户角色信息 + * + * @param userRoleList 用户角色列表 + * @return 结果 + */ + public int batchUserRole(List userRoleList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 65f860134..7cdda238a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -244,7 +244,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); } if (children.size() > 0) { - updateBatchById(children); + baseMapper.updateDeptChildren(children); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 9d4b10a96..c46c45f99 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -240,9 +240,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl list.add(rm); } if (list.size() > 0) { - for (SysRoleMenu sysRoleMenu : list) { - rows += roleMenuMapper.insert(sysRoleMenu); - } + rows = roleMenuMapper.batchRoleMenu(list); } return rows; } @@ -263,9 +261,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl list.add(rd); } if (list.size() > 0) { - for (SysRoleDept sysRoleDept : list) { - rows += roleDeptMapper.insert(sysRoleDept); - } + rows = roleDeptMapper.batchRoleDept(list); } return rows; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index f729a8180..d3fd7250c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -311,9 +311,7 @@ public class SysUserServiceImpl extends ServiceImpl impl list.add(ur); } if (list.size() > 0) { - for (SysUserRole sysUserRole : list) { - userRoleMapper.insert(sysUserRole); - } + userRoleMapper.batchUserRole(list); } } } @@ -335,9 +333,7 @@ public class SysUserServiceImpl extends ServiceImpl impl list.add(up); } if (list.size() > 0) { - for (SysUserPost sysUserPost : list) { - userPostMapper.insert(sysUserPost); - } + userPostMapper.batchUserPost(list); } } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 21f68541d..2f565444b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -57,4 +57,17 @@ order by d.parent_id, d.order_num + + update sys_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml index 0fda68253..cace1f56e 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_role_dept(role_id, dept_id) values + + (#{item.roleId},#{item.deptId}) + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml index 2529a720b..356b61237 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_role_menu(role_id, menu_id) values + + (#{item.roleId},#{item.menuId}) + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml index bd13ed433..8d70825c1 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_user_post(user_id, post_id) values + + (#{item.userId},#{item.postId}) + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml index 3d41141b8..1db2f0fe3 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_user_role(user_id, role_id) values + + (#{item.userId},#{item.roleId}) + + + + From 90063ad03c406c0cf88f5e6a1860bb43926bfddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=9D=B0?= <693337446@qq.com> Date: Mon, 31 May 2021 17:23:13 +0800 Subject: [PATCH 28/48] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E4=B8=AD=E6=89=B9=E9=87=8F=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8E=9F=E7=94=9Fmybatis=E6=89=A7=E8=A1=8Cfo?= =?UTF-8?q?reach=EF=BC=8C=E6=94=B9=E5=96=84=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/system/mapper/SysDeptMapper.java | 8 ++++++++ .../com/ruoyi/system/mapper/SysRoleDeptMapper.java | 10 ++++++++++ .../com/ruoyi/system/mapper/SysRoleMenuMapper.java | 10 ++++++++++ .../com/ruoyi/system/mapper/SysUserPostMapper.java | 10 ++++++++++ .../com/ruoyi/system/mapper/SysUserRoleMapper.java | 10 ++++++++++ .../system/service/impl/SysDeptServiceImpl.java | 2 +- .../system/service/impl/SysRoleServiceImpl.java | 8 ++------ .../system/service/impl/SysUserServiceImpl.java | 8 ++------ .../main/resources/mapper/system/SysDeptMapper.xml | 13 +++++++++++++ .../resources/mapper/system/SysRoleDeptMapper.xml | 9 ++++++++- .../resources/mapper/system/SysRoleMenuMapper.xml | 9 ++++++++- .../resources/mapper/system/SysUserPostMapper.xml | 9 ++++++++- .../resources/mapper/system/SysUserRoleMapper.xml | 9 ++++++++- 13 files changed, 98 insertions(+), 17 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 12824e753..54fe2611f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -30,4 +30,12 @@ public interface SysDeptMapper extends BaseMapperPlus { */ public List selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java index 6121490c2..331ecb911 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysRoleDept; +import java.util.List; + /** * 角色与部门关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysRoleDept; */ public interface SysRoleDeptMapper extends BaseMapperPlus { + /** + * 批量新增角色部门信息 + * + * @param roleDeptList 角色部门列表 + * @return 结果 + */ + public int batchRoleDept(List roleDeptList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java index fa8c5a34d..4f08ceaee 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysRoleMenu; +import java.util.List; + /** * 角色与菜单关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysRoleMenu; */ public interface SysRoleMenuMapper extends BaseMapperPlus { + /** + * 批量新增角色菜单信息 + * + * @param roleMenuList 角色菜单列表 + * @return 结果 + */ + public int batchRoleMenu(List roleMenuList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java index c17dfd5fa..7839bbe17 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysUserPost; +import java.util.List; + /** * 用户与岗位关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysUserPost; */ public interface SysUserPostMapper extends BaseMapperPlus { + /** + * 批量新增用户岗位信息 + * + * @param userPostList 用户角色列表 + * @return 结果 + */ + public int batchUserPost(List userPostList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index ddebd389b..365bbf47d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -3,6 +3,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.common.core.page.BaseMapperPlus; import com.ruoyi.system.domain.SysUserRole; +import java.util.List; + /** * 用户与角色关联表 数据层 * @@ -10,4 +12,12 @@ import com.ruoyi.system.domain.SysUserRole; */ public interface SysUserRoleMapper extends BaseMapperPlus { + /** + * 批量新增用户角色信息 + * + * @param userRoleList 用户角色列表 + * @return 结果 + */ + public int batchUserRole(List userRoleList); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 65f860134..7cdda238a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -244,7 +244,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); } if (children.size() > 0) { - updateBatchById(children); + baseMapper.updateDeptChildren(children); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 9d4b10a96..c46c45f99 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -240,9 +240,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl list.add(rm); } if (list.size() > 0) { - for (SysRoleMenu sysRoleMenu : list) { - rows += roleMenuMapper.insert(sysRoleMenu); - } + rows = roleMenuMapper.batchRoleMenu(list); } return rows; } @@ -263,9 +261,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl list.add(rd); } if (list.size() > 0) { - for (SysRoleDept sysRoleDept : list) { - rows += roleDeptMapper.insert(sysRoleDept); - } + rows = roleDeptMapper.batchRoleDept(list); } return rows; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 3133703f3..dd12f10b2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -311,9 +311,7 @@ public class SysUserServiceImpl extends ServiceImpl impl list.add(ur); } if (list.size() > 0) { - for (SysUserRole sysUserRole : list) { - userRoleMapper.insert(sysUserRole); - } + userRoleMapper.batchUserRole(list); } } } @@ -335,9 +333,7 @@ public class SysUserServiceImpl extends ServiceImpl impl list.add(up); } if (list.size() > 0) { - for (SysUserPost sysUserPost : list) { - userPostMapper.insert(sysUserPost); - } + userPostMapper.batchUserPost(list); } } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 21f68541d..2f565444b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -57,4 +57,17 @@ order by d.parent_id, d.order_num + + update sys_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml index 0fda68253..cace1f56e 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_role_dept(role_id, dept_id) values + + (#{item.roleId},#{item.deptId}) + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml index 2529a720b..356b61237 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_role_menu(role_id, menu_id) values + + (#{item.roleId},#{item.menuId}) + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml index bd13ed433..8d70825c1 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_user_post(user_id, post_id) values + + (#{item.userId},#{item.postId}) + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml index 3d41141b8..1db2f0fe3 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml @@ -9,4 +9,11 @@ - \ No newline at end of file + + insert into sys_user_role(user_id, role_id) values + + (#{item.userId},#{item.roleId}) + + + + From 99c4692a0de9fd96d93dcf5fce4a13e7bb686523 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: Mon, 31 May 2021 23:21:14 +0800 Subject: [PATCH 29/48] =?UTF-8?q?update=20=E5=8D=87=E7=BA=A7=20luttuce=20?= =?UTF-8?q?=E4=B8=BA=20redisson=20=E6=80=A7=E8=83=BD=E6=9B=B4=E5=BC=BA=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=9B=B4=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 + .../src/main/resources/application-dev.yml | 45 +- .../src/main/resources/application-prod.yml | 45 +- ruoyi-common/pom.xml | 6 + .../ruoyi/common/core/redis/RedisCache.java | 397 +++++++++--------- .../ruoyi/framework/config/RedisConfig.java | 75 ++-- .../config/properties/RedissonProperties.java | 101 +++++ 7 files changed, 427 insertions(+), 250 deletions(-) create mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java diff --git a/pom.xml b/pom.xml index 6d52bf68b..6cbda80bb 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,7 @@ 2.2.6.RELEASE 11.0 2.3.1 + 3.15.2 @@ -180,6 +181,13 @@ ${ruoyi-vue-plus.version} + + + org.redisson + redisson-spring-boot-starter + ${redisson.version} + + diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 06456dd8d..71e5b6f4f 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -67,13 +67,38 @@ spring: password: # 连接超时时间 timeout: 10s - lettuce: - pool: - # 连接池中的最小空闲连接 - min-idle: 0 - # 连接池中的最大空闲连接 - max-idle: 8 - # 连接池的最大数据库连接数 - max-active: 8 - # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms + # 是否开启ssl + ssl: false + +--- # redisson 客户端配置 +redisson: + # 线程池数量 + threads: 16 + # Netty线程池数量 + nettyThreads: 32 + # 传输模式 + transportMode: "NIO" + # 单节点配置 + singleServerConfig: + # 客户端名称 + clientName: ${ruoyi-vue-plus.name} + # 最小空闲连接数 + connectionMinimumIdleSize: 32 + # 连接池大小 + connectionPoolSize: 64 + # 连接空闲超时,单位:毫秒 + idleConnectionTimeout: 10000 + # 命令等待超时,单位:毫秒 + timeout: 3000 + # 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。 + retryAttempts: 3 + # 命令重试发送时间间隔,单位:毫秒 + retryInterval: 1500 + # 发布和订阅连接的最小空闲连接数 + subscriptionConnectionMinimumIdleSize: 1 + # 发布和订阅连接池大小 + subscriptionConnectionPoolSize: 50 + # 单个连接最大订阅数量 + subscriptionsPerConnection: 5 + # DNS监测时间间隔,单位:毫秒 + dnsMonitoringInterval: 5000 diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index fbd01b336..eba8a8981 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -67,13 +67,38 @@ spring: password: # 连接超时时间 timeout: 10s - lettuce: - pool: - # 连接池中的最小空闲连接 - min-idle: 0 - # 连接池中的最大空闲连接 - max-idle: 8 - # 连接池的最大数据库连接数 - max-active: 8 - # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms \ No newline at end of file + # 是否开启ssl + ssl: false + +--- # redisson 客户端配置 +redisson: + # 线程池数量 + threads: 16 + # Netty线程池数量 + nettyThreads: 32 + # 传输模式 + transportMode: "NIO" + # 单节点配置 + singleServerConfig: + # 客户端名称 + clientName: ${ruoyi-vue-plus.name} + # 最小空闲连接数 + connectionMinimumIdleSize: 32 + # 连接池大小 + connectionPoolSize: 64 + # 连接空闲超时,单位:毫秒 + idleConnectionTimeout: 10000 + # 命令等待超时,单位:毫秒 + timeout: 3000 + # 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。 + retryAttempts: 3 + # 命令重试发送时间间隔,单位:毫秒 + retryInterval: 1500 + # 发布和订阅连接的最小空闲连接数 + subscriptionConnectionMinimumIdleSize: 1 + # 发布和订阅连接池大小 + subscriptionConnectionPoolSize: 50 + # 单个连接最大订阅数量 + subscriptionsPerConnection: 5 + # DNS监测时间间隔,单位:毫秒 + dnsMonitoringInterval: 5000 diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 5f1404e1f..2c75fcd1b 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -151,6 +151,12 @@ spring-boot-configuration-processor + + + org.redisson + redisson-spring-boot-starter + + 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 index 22a610db0..6c4c2393e 100644 --- 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 @@ -1,234 +1,219 @@ package com.ruoyi.common.core.redis; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; +import com.google.common.collect.Lists; +import org.redisson.api.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.BoundSetOperations; -import org.springframework.data.redis.core.HashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Component; +import java.util.*; +import java.util.concurrent.TimeUnit; + /** * spring redis 工具类 * - * @author ruoyi + * @author shenxinquan **/ -@SuppressWarnings(value = { "unchecked", "rawtypes" }) +@SuppressWarnings(value = {"unchecked", "rawtypes"}) @Component -public class RedisCache -{ - @Autowired - public RedisTemplate redisTemplate; +public class RedisCache { - /** - * 缓存基本的对象,Integer、String、实体类等 - * - * @param key 缓存的键值 - * @param value 缓存的值 - */ - public void setCacheObject(final String key, final T value) - { - redisTemplate.opsForValue().set(key, value); - } + @Autowired + private RedissonClient redissonClient; - /** - * 缓存基本的对象,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) - { - redisTemplate.opsForValue().set(key, value, timeout, timeUnit); - } + /** + * 缓存基本的对象,Integer、String、实体类等 + * + * @param key 缓存的键值 + * @param value 缓存的值 + */ + public void setCacheObject(final String key, final T value) { + redissonClient.getBucket(key).set(value); + } - /** - * 设置有效时间 - * - * @param key Redis键 - * @param timeout 超时时间 - * @return true=设置成功;false=设置失败 - */ - public boolean expire(final String key, final long timeout) - { - return expire(key, timeout, TimeUnit.SECONDS); - } + /** + * 缓存基本的对象,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 超时时间 - * @param unit 时间单位 - * @return true=设置成功;false=设置失败 - */ - public boolean expire(final String key, final long timeout, final TimeUnit unit) - { - return redisTemplate.expire(key, timeout, unit); - } + /** + * 设置有效时间 + * + * @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 缓存键值 - * @return 缓存键值对应的数据 - */ - public T getCacheObject(final String key) - { - ValueOperations operation = redisTemplate.opsForValue(); - return operation.get(key); - } + /** + * 设置有效时间 + * + * @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 - */ - public boolean deleteObject(final String key) - { - return redisTemplate.delete(key); - } + /** + * 获得缓存的基本对象。 + * + * @param key 缓存键值 + * @return 缓存键值对应的数据 + */ + public T getCacheObject(final String key) { + RBucket rBucket = redissonClient.getBucket(key); + return rBucket.get(); + } - /** - * 删除集合对象 - * - * @param collection 多个对象 - * @return - */ - public long deleteObject(final Collection collection) - { - return redisTemplate.delete(collection); - } + /** + * 删除单个对象 + * + * @param key + */ + public boolean deleteObject(final String key) { + return redissonClient.getBucket(key).delete(); + } - /** - * 缓存List数据 - * - * @param key 缓存的键值 - * @param dataList 待缓存的List数据 - * @return 缓存的对象 - */ - public long setCacheList(final String key, final List dataList) - { - Long count = redisTemplate.opsForList().rightPushAll(key, dataList); - return count == null ? 0 : count; - } + /* */ - /** - * 获得缓存的list对象 - * - * @param key 缓存的键值 - * @return 缓存键值对应的数据 - */ - public List getCacheList(final String key) - { - return redisTemplate.opsForList().range(key, 0, -1); - } + /** + * 删除集合对象 + * + * @param collection 多个对象 + * @return + */ + public long deleteObject(final Collection collection) { + return redissonClient.getKeys().delete(Arrays.toString(collection.toArray())); + } - /** - * 缓存Set - * - * @param key 缓存键值 - * @param dataSet 缓存的数据 - * @return 缓存数据的对象 - */ - public BoundSetOperations setCacheSet(final String key, final Set dataSet) - { - BoundSetOperations setOperation = redisTemplate.boundSetOps(key); - Iterator it = dataSet.iterator(); - while (it.hasNext()) - { - setOperation.add(it.next()); - } - return setOperation; - } + /** + * 缓存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); + } - /** - * 获得缓存的set - * - * @param key - * @return - */ - public Set getCacheSet(final String key) - { - return redisTemplate.opsForSet().members(key); - } + /** + * 获得缓存的list对象 + * + * @param key 缓存的键值 + * @return 缓存键值对应的数据 + */ + public List getCacheList(final String key) { + RList rList = redissonClient.getList(key); + return rList.readAll(); + } - /** - * 缓存Map - * - * @param key - * @param dataMap - */ - public void setCacheMap(final String key, final Map dataMap) - { - if (dataMap != null) { - redisTemplate.opsForHash().putAll(key, dataMap); - } - } + /** + * 缓存Set + * + * @param key 缓存键值 + * @param dataSet 缓存的数据 + * @return 缓存数据的对象 + */ + public boolean setCacheSet(final String key, final Set dataSet) { + RSet rSet = redissonClient.getSet(key); + return rSet.addAll(dataSet); + } - /** - * 获得缓存的Map - * - * @param key - * @return - */ - public Map getCacheMap(final String key) - { - return redisTemplate.opsForHash().entries(key); - } + /** + * 获得缓存的set + * + * @param key + * @return + */ + public Set getCacheSet(final String key) { + RSet rSet = redissonClient.getSet(key); + return rSet.readAll(); + } - /** - * 往Hash中存入数据 - * - * @param key Redis键 - * @param hKey Hash键 - * @param value 值 - */ - public void setCacheMapValue(final String key, final String hKey, final T value) - { - redisTemplate.opsForHash().put(key, hKey, value); - } + /** + * 缓存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); + } + } - /** - * 获取Hash中的数据 - * - * @param key Redis键 - * @param hKey Hash键 - * @return Hash中的对象 - */ - public T getCacheMapValue(final String key, final String hKey) - { - HashOperations opsForHash = redisTemplate.opsForHash(); - return opsForHash.get(key, hKey); - } + /** + * 获得缓存的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 hKeys Hash键集合 - * @return Hash对象集合 - */ - public List getMultiCacheMapValue(final String key, final Collection hKeys) - { - return redisTemplate.opsForHash().multiGet(key, hKeys); - } + /** + * 往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); + } - /** - * 获得缓存的基本对象列表 - * - * @param pattern 字符串前缀 - * @return 对象列表 - */ - public Collection keys(final String pattern) - { - return redisTemplate.keys(pattern); - } + /** + * 获取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 List getMultiCacheMapValue(final String key, final Collection hKeys) { + RListMultimap rListMultimap = redissonClient.getListMultimap(key); + return rListMultimap.getAll(hKeys); + } + + /** + * 获得缓存的基本对象列表 + * + * @param pattern 字符串前缀 + * @return 对象列表 + */ + public Collection keys(final String pattern) { + Iterable iterable = redissonClient.getKeys().getKeysByPattern(pattern); + return Lists.newArrayList(iterable); + } } 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 af471f49b..b86872985 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 @@ -1,42 +1,69 @@ package com.ruoyi.framework.config; -import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer; +import com.ruoyi.framework.config.properties.RedissonProperties; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.codec.JsonJacksonCodec; +import org.redisson.config.Config; +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.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.StringRedisSerializer; + +import java.io.IOException; /** * redis配置 * - * @author ruoyi + * @author Lion Li */ @Configuration @EnableCaching -public class RedisConfig extends CachingConfigurerSupport -{ - @Bean - @SuppressWarnings(value = { "unchecked", "rawtypes" }) - public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) - { - RedisTemplate template = new RedisTemplate<>(); - template.setConnectionFactory(connectionFactory); +public class RedisConfig extends CachingConfigurerSupport { - GenericFastJsonRedisSerializer serializer = new GenericFastJsonRedisSerializer(); - StringRedisSerializer keySerializer = new StringRedisSerializer(); + private static final String REDIS_PROTOCOL_PREFIX = "redis://"; + private static final String REDISS_PROTOCOL_PREFIX = "rediss://"; - // 使用StringRedisSerializer来序列化和反序列化redis的key值 - template.setKeySerializer(keySerializer); - template.setValueSerializer(serializer); + @Autowired + private RedisProperties redisProperties; - // Hash的key也采用StringRedisSerializer的序列化方式 - template.setHashKeySerializer(keySerializer); - template.setHashValueSerializer(serializer); + @Autowired + private RedissonProperties redissonProperties; - template.afterPropertiesSet(); - return template; - } + @Bean(destroyMethod = "shutdown") + @ConditionalOnMissingBean(RedissonClient.class) + public RedissonClient redisson() throws IOException { + String prefix = REDIS_PROTOCOL_PREFIX; + if (redisProperties.isSsl()) { + prefix = REDISS_PROTOCOL_PREFIX; + } + Config config = new Config(); + config.setThreads(redissonProperties.getThreads()) + .setNettyThreads(redissonProperties.getNettyThreads()) + .setCodec(JsonJacksonCodec.INSTANCE) + .setTransportMode(redissonProperties.getTransportMode()); + + RedissonProperties.SingleServerConfig singleServerConfig = redissonProperties.getSingleServerConfig(); + // 使用单机模式 + config.useSingleServer() + .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) + .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) + .setDatabase(redisProperties.getDatabase()) + .setPassword(redisProperties.getPassword()) + .setTimeout(singleServerConfig.getTimeout()) + .setRetryAttempts(singleServerConfig.getRetryAttempts()) + .setRetryInterval(singleServerConfig.getRetryInterval()) + .setSubscriptionsPerConnection(singleServerConfig.getSubscriptionsPerConnection()) + .setClientName(singleServerConfig.getClientName()) + .setIdleConnectionTimeout(singleServerConfig.getIdleConnectionTimeout()) + .setSubscriptionConnectionMinimumIdleSize(singleServerConfig.getSubscriptionConnectionMinimumIdleSize()) + .setSubscriptionConnectionPoolSize(singleServerConfig.getSubscriptionConnectionPoolSize()) + .setConnectionMinimumIdleSize(singleServerConfig.getConnectionMinimumIdleSize()) + .setConnectionPoolSize(singleServerConfig.getConnectionPoolSize()) + .setDnsMonitoringInterval(singleServerConfig.getDnsMonitoringInterval()); + return Redisson.create(config); + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java new file mode 100644 index 000000000..99db89eff --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/RedissonProperties.java @@ -0,0 +1,101 @@ +package com.ruoyi.framework.config.properties; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.redisson.client.codec.Codec; +import org.redisson.config.TransportMode; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * Redisson 配置属性 + * + * @author Lion Li + */ +@Data +@Component +@ConfigurationProperties(prefix = "redisson") +public class RedissonProperties { + + /** + * 线程池数量,默认值 = 当前处理核数量 * 2 + */ + private int threads; + + /** + * Netty线程池数量,默认值 = 当前处理核数量 * 2 + */ + private int nettyThreads; + + /** + * 传输模式 + */ + private TransportMode transportMode; + + /** + * 单机服务配置 + */ + private SingleServerConfig singleServerConfig; + + @Data + @NoArgsConstructor + public static class SingleServerConfig { + + /** + * 客户端名称 + */ + private String clientName; + + /** + * 最小空闲连接数 + */ + private int connectionMinimumIdleSize; + + /** + * 连接池大小 + */ + private int connectionPoolSize; + + /** + * 连接空闲超时,单位:毫秒 + */ + private int idleConnectionTimeout; + + /** + * 命令等待超时,单位:毫秒 + */ + private int timeout; + + /** + * 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。 + */ + private int retryAttempts; + + /** + * 命令重试发送时间间隔,单位:毫秒 + */ + private int retryInterval; + + /** + * 发布和订阅连接的最小空闲连接数 + */ + private int subscriptionConnectionMinimumIdleSize; + + /** + * 发布和订阅连接池大小 + */ + private int subscriptionConnectionPoolSize; + + /** + * 单个连接最大订阅数量 + */ + private int subscriptionsPerConnection; + + /** + * DNS监测时间间隔,单位:毫秒 + */ + private int dnsMonitoringInterval; + + } + +} From 7bbeea0b81f33f22023021ab13b51705b7d3a2bf 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: Mon, 31 May 2021 23:38:30 +0800 Subject: [PATCH 30/48] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20=E5=A2=9E=E5=8A=A0=20redisson=20=E5=86=85=E5=AE=B9?= 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 2305fe14b..ce17def9d 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ * 集成 Feign 接口化管理 Http 请求(如三方请求 支付,短信,推送等) * 移除 自带服务监控 改为 spring-boot-admin 全方位监控 * 增加 demo 模块示例(给不会增加模块的小伙伴做参考) +* 增加 redisson 支持分布式锁 功能更强大 ### 代码改动 @@ -38,6 +39,7 @@ * 代码生成模板 增加 文档注解 与 校验注解 简化通用操作 * 项目修改为 maven多环境配置 * 项目配置修改为 application.yml 统一管理 +* 数据权限修改为 适配支持单表、多表 ### 其他 From d815317d7c5f0a155c9beeed7940a193de441262 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: Tue, 1 Jun 2021 10:21:56 +0800 Subject: [PATCH 31/48] =?UTF-8?q?=E5=8F=91=E5=B8=83=20v2.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- ruoyi-ui/package.json | 2 +- ruoyi-ui/src/views/index.vue | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6cbda80bb..a17897433 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ RuoYi-Vue-Plus后台管理系统 - 2.2.1 + 2.3.0 2.3.11.RELEASE UTF-8 UTF-8 diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index e951b8d64..2fc1921b9 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi-vue-plus", - "version": "2.2.1", + "version": "2.3.0", "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 91beb8445..c246ac97e 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -80,6 +80,16 @@ 更新日志 + +
    +
  1. add 升级 luttuce 为 redisson 性能更强 工具更全
  2. +
  3. add 增加测试数据sql文件
  4. +
  5. add 增加demo模块 单表演示案例(包含数据权限)
  6. +
  7. update 完美修复 数据权限功能(支持单表多表过滤)
  8. +
  9. update 优化代码生成模板
  10. +
  11. update 优化 system 模块 批量操作性能
  12. +
+
  1. add 增加 security 权限框架 @Async 异步注解配置
  2. From d9dd76f2aeb289562b72c41039e2a4f812701d6e 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: Tue, 1 Jun 2021 10:54:59 +0800 Subject: [PATCH 32/48] =?UTF-8?q?=E5=8F=91=E5=B8=83=20v2.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index c246ac97e..29d4dbb5c 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -200,7 +200,7 @@ export default { data() { return { // 版本号 - version: "2.2.1", + version: "2.3.0", }; }, methods: { From d1351503a8f15685ff053efafc1d08540cb4239e 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: Tue, 1 Jun 2021 23:14:42 +0800 Subject: [PATCH 33/48] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B9=A6=E5=86=99=E6=A0=BC=E5=BC=8F=20=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/framework/aspectj/DataScopeAspect.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index e8ef10185..383f4b64d 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -159,6 +159,7 @@ public class DataScopeAspect { } } + @SuppressWarnings("unchecked") private static void putDataScope(JoinPoint joinPoint, String sql) { Object params = joinPoint.getArgs()[0]; if (Validator.isNotNull(params)) { @@ -167,8 +168,8 @@ public class DataScopeAspect { baseEntity.getParams().put(DATA_SCOPE, sql); } else { try { - Method getParams = params.getClass().getDeclaredMethod("getParams", null); - Map invoke = (Map) getParams.invoke(params, null); + Method getParams = params.getClass().getDeclaredMethod("getParams"); + Map invoke = (Map) getParams.invoke(params); invoke.put(DATA_SCOPE, sql); } catch (Exception e) { // 方法未找到 不处理 From 83ba79dca28f2b383938cfe59c55cac3b401d006 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, 2 Jun 2021 09:41:12 +0800 Subject: [PATCH 34/48] =?UTF-8?q?update=20=E5=A2=9E=E5=8A=A0redis=E7=A9=BA?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/framework/config/RedisConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 b86872985..e86f5bc03 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 @@ -1,5 +1,6 @@ package com.ruoyi.framework.config; +import cn.hutool.core.util.StrUtil; import com.ruoyi.framework.config.properties.RedissonProperties; import org.redisson.Redisson; import org.redisson.api.RedissonClient; @@ -52,7 +53,7 @@ public class RedisConfig extends CachingConfigurerSupport { .setAddress(prefix + redisProperties.getHost() + ":" + redisProperties.getPort()) .setConnectTimeout(((Long) redisProperties.getTimeout().toMillis()).intValue()) .setDatabase(redisProperties.getDatabase()) - .setPassword(redisProperties.getPassword()) + .setPassword(StrUtil.isNotBlank(redisProperties.getPassword()) ? redisProperties.getPassword() : null) .setTimeout(singleServerConfig.getTimeout()) .setRetryAttempts(singleServerConfig.getRetryAttempts()) .setRetryInterval(singleServerConfig.getRetryInterval()) From 45fe77ce4af66d9d9b2198d851bc2ee28043bdf7 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, 2 Jun 2021 09:49:16 +0800 Subject: [PATCH 35/48] =?UTF-8?q?update=20=E6=96=87=E6=A1=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20Oracle=20=E5=88=86=E6=94=AF=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ce17def9d..7aac0bf1d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ * 同步升级 RuoYi-Vue 3.5.0 * 单模块 fast 分支 [RuoYi-Vue-Plus-fast](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) +* Oracle 模块 oracle 分支 [RuoYi-Vue-Plus-oracle](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/oracle/) ## 关注作者(扫码请备注: "加群") From edd2981076432b730677b37737c5b1e4508959ed Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 2 Jun 2021 11:45:30 +0800 Subject: [PATCH 36/48] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3swagger=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/tool/TestController.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java index 2ae0c54ac..4588a7a53 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.controller.BaseController; @@ -16,6 +17,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; @@ -55,34 +57,38 @@ public class TestController extends BaseController } else { - return AjaxResult.error("用户不存在"); + return error("用户不存在"); } } @ApiOperation("新增用户") - @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer"), + @ApiImplicitParam(name = "username", value = "用户名称", dataType = "String"), + @ApiImplicitParam(name = "password", value = "用户密码", dataType = "String"), + @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String") + }) @PostMapping("/save") public AjaxResult save(UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { - return AjaxResult.error("用户ID不能为空"); + return error("用户ID不能为空"); } return AjaxResult.success(users.put(user.getUserId(), user)); } @ApiOperation("更新用户") - @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") @PutMapping("/update") - public AjaxResult update(UserEntity user) + public AjaxResult update(@RequestBody UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { - return AjaxResult.error("用户ID不能为空"); + return error("用户ID不能为空"); } if (users.isEmpty() || !users.containsKey(user.getUserId())) { - return AjaxResult.error("用户不存在"); + return error("用户不存在"); } users.remove(user.getUserId()); return AjaxResult.success(users.put(user.getUserId(), user)); @@ -96,16 +102,16 @@ public class TestController extends BaseController if (!users.isEmpty() && users.containsKey(userId)) { users.remove(userId); - return AjaxResult.success(); + return success(); } else { - return AjaxResult.error("用户不存在"); + return error("用户不存在"); } } } -@ApiModel("用户实体") +@ApiModel(value = "UserEntity", description = "用户实体") class UserEntity { @ApiModelProperty("用户ID") From b7f3c68eca343de30ca36a68cd796188b5086f72 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 2 Jun 2021 11:45:40 +0800 Subject: [PATCH 37/48] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E8=AF=BB=E5=8F=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/file/ImageUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java index 411ef15e0..3dfc9bbce 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java @@ -94,6 +94,7 @@ public class ImageUtils } finally { + IOUtils.closeQuietly(in); IOUtils.closeQuietly(baos); } } From 7c20d6e28cc2bedc9d823b53290769fad1bba527 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, 2 Jun 2021 12:47:54 +0800 Subject: [PATCH 38/48] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B9=A6=E5=86=99=E6=A0=BC=E5=BC=8F=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/framework/aspectj/DataScopeAspect.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index 383f4b64d..830dbe594 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -8,6 +8,7 @@ import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.common.utils.reflect.ReflectUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.framework.web.service.TokenService; import org.aspectj.lang.JoinPoint; @@ -159,7 +160,6 @@ public class DataScopeAspect { } } - @SuppressWarnings("unchecked") private static void putDataScope(JoinPoint joinPoint, String sql) { Object params = joinPoint.getArgs()[0]; if (Validator.isNotNull(params)) { @@ -167,13 +167,8 @@ public class DataScopeAspect { BaseEntity baseEntity = (BaseEntity) params; baseEntity.getParams().put(DATA_SCOPE, sql); } else { - try { - Method getParams = params.getClass().getDeclaredMethod("getParams"); - Map invoke = (Map) getParams.invoke(params); - invoke.put(DATA_SCOPE, sql); - } catch (Exception e) { - // 方法未找到 不处理 - } + Map invoke = ReflectUtils.invokeGetter(params, "params"); + invoke.put(DATA_SCOPE, sql); } } } From 2ee2e4505a34f80873806c152faca4af514e1113 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, 2 Jun 2021 14:28:40 +0800 Subject: [PATCH 39/48] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B9=A6=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application-dev.yml | 2 +- ruoyi-admin/src/main/resources/application-prod.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 71e5b6f4f..eb54d9c64 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -81,7 +81,7 @@ redisson: # 单节点配置 singleServerConfig: # 客户端名称 - clientName: ${ruoyi-vue-plus.name} + clientName: ${ruoyi.name} # 最小空闲连接数 connectionMinimumIdleSize: 32 # 连接池大小 diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index eba8a8981..2ebdcbdc6 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -81,7 +81,7 @@ redisson: # 单节点配置 singleServerConfig: # 客户端名称 - clientName: ${ruoyi-vue-plus.name} + clientName: ${ruoyi.name} # 最小空闲连接数 connectionMinimumIdleSize: 32 # 连接池大小 From 0fe064b8a20056bd57e2302166cfc5a7a753f004 Mon Sep 17 00:00:00 2001 From: sxq <812980466@qq.com> Date: Wed, 2 Jun 2021 15:14:04 +0800 Subject: [PATCH 40/48] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dreddison=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E7=9A=84bug?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/core/redis/RedisCache.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 index 6c4c2393e..3c8bc9233 100644 --- 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 @@ -96,8 +96,12 @@ public class RedisCache { * @param collection 多个对象 * @return */ - public long deleteObject(final Collection collection) { - return redissonClient.getKeys().delete(Arrays.toString(collection.toArray())); + public void deleteObject(final Collection collection) { + RBatch batch = redissonClient.createBatch(); + collection.forEach(t->{ + batch.getBucket(t.toString()).deleteAsync(); + }); + batch.execute(); } /** From 430addf5203b744cdd3c0b5755fe6165d0f535d4 Mon Sep 17 00:00:00 2001 From: kdyzm Date: Wed, 2 Jun 2021 16:40:58 +0800 Subject: [PATCH 41/48] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91?= =?UTF-8?q?=E4=B8=BA=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E5=89=8D=E7=AB=AF=E4=BB=A3=E7=A0=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0loading=EF=BC=9B=E5=88=A0=E9=99=A4=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0=E5=8F=98=E6=9B=B4=E4=B8=BA?= =?UTF-8?q?=E7=AE=AD=E5=A4=B4=E8=A1=A8=E8=BE=BE=E5=BC=8F?= 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 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 b384ba5ee..c0114493c 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -534,9 +534,11 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { + this.loading = true; this.reset(); const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids get${BusinessName}(${pkColumn.javaField}).then(response => { + this.loading = false; this.form = response.data; #foreach ($column in $columns) #if($column.htmlType == "checkbox") @@ -554,6 +556,7 @@ export default { submitForm() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { + this.loading = true; #foreach ($column in $columns) #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); @@ -564,12 +567,14 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { + this.loading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { add${BusinessName}(this.form).then(response => { + this.loading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); @@ -585,9 +590,11 @@ export default { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" - }).then(function() { + }).then(()=> { + this.loading = true; return del${BusinessName}(${pkColumn.javaField}s); }).then(() => { + this.loading = false; this.getList(); this.msgSuccess("删除成功"); }) From 9590de2c1971b596c047deddd926c2b80ade2c67 Mon Sep 17 00:00:00 2001 From: kdyzm Date: Wed, 2 Jun 2021 17:08:00 +0800 Subject: [PATCH 42/48] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=91=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=EF=BC=9A?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0loading=E3=80=81=E4=BF=AE=E6=94=B9=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8C=89=E9=92=AE=E7=9A=84=E5=9B=9E=E8=B0=83=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=BA=E7=AE=AD=E5=A4=B4=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/vm/vue/index-tree.vue.vm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 969dba855..ca9974979 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 @@ -480,12 +480,14 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { + this.loading = true; this.reset(); this.getTreeselect(); if (row != null) { this.form.${treeParentCode} = row.${treeCode}; } get${BusinessName}(row.${pkColumn.javaField}).then(response => { + this.loading = false; this.form = response.data; #foreach ($column in $columns) #if($column.htmlType == "checkbox") @@ -500,6 +502,7 @@ export default { submitForm() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { + this.loading = true; #foreach ($column in $columns) #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); @@ -507,12 +510,14 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { + this.loading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { add${BusinessName}(this.form).then(response => { + this.loading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); @@ -527,9 +532,11 @@ export default { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" - }).then(function() { + }).then(() => { + this.loading = true; return del${BusinessName}(row.${pkColumn.javaField}); }).then(() => { + this.loading = false; this.getList(); this.msgSuccess("删除成功"); }) From 329c95196e5803e1472f0c7bda087f6771b2789f 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, 2 Jun 2021 17:15:20 +0800 Subject: [PATCH 43/48] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=A1=88=E4=BE=8B?= 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 | 4 ++-- ruoyi-ui/src/views/demo/demo/index.vue | 9 ++++++++- ruoyi-ui/src/views/demo/tree/index.vue | 9 ++++++++- sql/test.sql | 4 ++-- 4 files changed, 20 insertions(+), 6 deletions(-) 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 c0114493c..1c87a465e 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -556,7 +556,7 @@ export default { submitForm() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { - this.loading = true; + this.loading = true; #foreach ($column in $columns) #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); @@ -590,7 +590,7 @@ export default { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" - }).then(()=> { + }).then(() => { this.loading = true; return del${BusinessName}(${pkColumn.javaField}s); }).then(() => { diff --git a/ruoyi-ui/src/views/demo/demo/index.vue b/ruoyi-ui/src/views/demo/demo/index.vue index b831ad9b3..c884b38fc 100644 --- a/ruoyi-ui/src/views/demo/demo/index.vue +++ b/ruoyi-ui/src/views/demo/demo/index.vue @@ -277,9 +277,11 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { + this.loading = true; this.reset(); const id = row.id || this.ids getDemo(id).then(response => { + this.loading = false; this.form = response.data; this.open = true; this.title = "修改测试单表"; @@ -289,14 +291,17 @@ export default { submitForm() { this.$refs["form"].validate(valid => { if (valid) { + this.loading = true; if (this.form.id != null) { updateDemo(this.form).then(response => { + this.loading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addDemo(this.form).then(response => { + this.loading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); @@ -312,9 +317,11 @@ export default { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" - }).then(function() { + }).then(() => { + this.loading = true; return delDemo(ids); }).then(() => { + this.loading = false; this.getList(); this.msgSuccess("删除成功"); }) diff --git a/ruoyi-ui/src/views/demo/tree/index.vue b/ruoyi-ui/src/views/demo/tree/index.vue index ddf767777..b65b2bd50 100644 --- a/ruoyi-ui/src/views/demo/tree/index.vue +++ b/ruoyi-ui/src/views/demo/tree/index.vue @@ -233,12 +233,14 @@ export default { }, /** 修改按钮操作 */ handleUpdate(row) { + this.loading = true; this.reset(); this.getTreeselect(); if (row != null) { this.form.parentId = row.id; } getTree(row.id).then(response => { + this.loading = false; this.form = response.data; this.open = true; this.title = "修改测试树表"; @@ -248,14 +250,17 @@ export default { submitForm() { this.$refs["form"].validate(valid => { if (valid) { + this.loading = true; if (this.form.id != null) { updateTree(this.form).then(response => { + this.loading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addTree(this.form).then(response => { + this.loading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); @@ -270,9 +275,11 @@ export default { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" - }).then(function() { + }).then(() => { + this.loading = true; return delTree(row.id); }).then(() => { + this.loading = false; this.getList(); this.msgSuccess("删除成功"); }) diff --git a/sql/test.sql b/sql/test.sql index b7003ce20..601360a77 100644 --- a/sql/test.sql +++ b/sql/test.sql @@ -12,7 +12,7 @@ CREATE TABLE test_demo create_by varchar(64) NULL DEFAULT NULL COMMENT '创建人', update_time datetime(0) NULL DEFAULT NULL COMMENT '更新时间', update_by varchar(64) NULL DEFAULT NULL COMMENT '更新人', - del_flag int(0) NULL DEFAULT NULL COMMENT '删除标志', + del_flag int(0) NULL DEFAULT 0 COMMENT '删除标志', PRIMARY KEY (id) USING BTREE ) ENGINE = InnoDB COMMENT = '测试单表'; @@ -29,7 +29,7 @@ CREATE TABLE test_tree create_by varchar(64) NULL DEFAULT NULL COMMENT '创建人', update_time datetime(0) NULL DEFAULT NULL COMMENT '更新时间', update_by varchar(64) NULL DEFAULT NULL COMMENT '更新人', - del_flag int(0) NULL DEFAULT NULL COMMENT '删除标志', + del_flag int(0) NULL DEFAULT 0 COMMENT '删除标志', PRIMARY KEY (id) USING BTREE ) ENGINE = InnoDB COMMENT = '测试树表'; From 6b789e2eb07349f0423e7d064f625adb779faa6c Mon Sep 17 00:00:00 2001 From: kdyzm Date: Wed, 2 Jun 2021 18:13:34 +0800 Subject: [PATCH 44/48] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8A=A8=E4=BD=9Cloading=E4=BB=8E=E9=A1=B5=E9=9D=A2lo?= =?UTF-8?q?ading=E5=88=B0=E6=8C=89=E9=92=AEloading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/vm/vue/index-tree.vue.vm | 10 ++++++---- ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 10 ++++++---- ruoyi-ui/src/views/demo/demo/index.vue | 10 ++++++---- ruoyi-ui/src/views/demo/tree/index.vue | 10 ++++++---- 4 files changed, 24 insertions(+), 16 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 ca9974979..f1247aba3 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 @@ -247,7 +247,7 @@ #end @@ -302,6 +302,8 @@ export default { }, data() { return { + //按钮loading + buttonLoading: false, // 遮罩层 loading: true, // 显示搜索条件 @@ -502,7 +504,7 @@ export default { submitForm() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { - this.loading = true; + this.buttonLoading = true; #foreach ($column in $columns) #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); @@ -510,14 +512,14 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { add${BusinessName}(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); 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 1c87a465e..9f58575bd 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -301,7 +301,7 @@ #end @@ -353,6 +353,8 @@ export default { }, data() { return { + //按钮loading + buttonLoading: false, // 遮罩层 loading: true, // 导出遮罩层 @@ -556,7 +558,7 @@ export default { submitForm() { this.#[[$]]#refs["form"].validate(valid => { if (valid) { - this.loading = true; + this.buttonLoading = true; #foreach ($column in $columns) #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); @@ -567,14 +569,14 @@ export default { #end if (this.form.${pkColumn.javaField} != null) { update${BusinessName}(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { add${BusinessName}(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); diff --git a/ruoyi-ui/src/views/demo/demo/index.vue b/ruoyi-ui/src/views/demo/demo/index.vue index c884b38fc..48fa36819 100644 --- a/ruoyi-ui/src/views/demo/demo/index.vue +++ b/ruoyi-ui/src/views/demo/demo/index.vue @@ -152,7 +152,7 @@ @@ -168,6 +168,8 @@ export default { }, data() { return { + //按钮loading + buttonLoading: false, // 遮罩层 loading: true, // 导出遮罩层 @@ -291,17 +293,17 @@ export default { submitForm() { this.$refs["form"].validate(valid => { if (valid) { - this.loading = true; + this.buttonLoading = true; if (this.form.id != null) { updateDemo(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addDemo(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); diff --git a/ruoyi-ui/src/views/demo/tree/index.vue b/ruoyi-ui/src/views/demo/tree/index.vue index b65b2bd50..afe96c4ae 100644 --- a/ruoyi-ui/src/views/demo/tree/index.vue +++ b/ruoyi-ui/src/views/demo/tree/index.vue @@ -102,7 +102,7 @@ @@ -121,6 +121,8 @@ export default { }, data() { return { + //按钮loading + buttonLoading: false, // 遮罩层 loading: true, // 显示搜索条件 @@ -250,17 +252,17 @@ export default { submitForm() { this.$refs["form"].validate(valid => { if (valid) { - this.loading = true; + this.buttonLoading = true; if (this.form.id != null) { updateTree(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addTree(this.form).then(response => { - this.loading = false; + this.buttonLoading = false; this.msgSuccess("新增成功"); this.open = false; this.getList(); From 85470a1549f6394398b5745ed29ef65de2377d6b Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 2 Jun 2021 20:43:34 +0800 Subject: [PATCH 45/48] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E9=80=89=E6=8B=A9=E4=B8=8B=E6=8B=89=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/tool/build/RightPanel.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ruoyi-ui/src/views/tool/build/RightPanel.vue b/ruoyi-ui/src/views/tool/build/RightPanel.vue index 1acdc5794..88013a547 100644 --- a/ruoyi-ui/src/views/tool/build/RightPanel.vue +++ b/ruoyi-ui/src/views/tool/build/RightPanel.vue @@ -573,6 +573,7 @@