From e523764b0f300e5055d6f4bc680aa40d2590504f Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期六, 29 五月 2021 19:14:45 +0800 Subject: [PATCH] 发布 2.2.1 --- ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 10 ruoyi-ui/src/views/index.vue | 13 ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java | 41 + ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java | 10 ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java | 10 pom.xml | 10 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java | 13 README.md | 46 ++ ruoyi-ui/src/views/system/config/index.vue | 14 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java | 16 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java | 5 ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml | 13 ruoyi-ui/src/api/system/config.js | 6 ruoyi-ui/src/views/system/dict/index.vue | 14 ruoyi-ui/package.json | 2 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java | 13 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java | 16 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java | 184 ++++---- ruoyi-ui/src/api/system/dict/type.js | 6 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java | 374 +++++++++--------- ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml | 10 ruoyi-admin/src/main/resources/application-dev.yml | 14 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java | 337 ++++++++-------- 24 files changed, 668 insertions(+), 511 deletions(-) diff --git a/README.md b/README.md index 796d57f..2a58722 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,11 @@ 鍏充簬vue涓巄oot鏁村悎閮ㄧ讲 * [鍓嶇闈欐�佽祫婧愬浣曟暣鍚堝埌鍚庣璁块棶](https://doc.ruoyi.vip/ruoyi-vue/other/faq.html#鍓嶇闈欐�佽祫婧愬浣曟暣鍚堝埌鍚庣璁块棶) +鍏充簬淇敼鍖呭悕 +* 灏嗘枃浠跺す鍏ㄩ儴淇敼涓� com.xxx +* 浣跨敤IDEA鍏ㄥ眬鏇挎崲 com.ruoyi 鏇挎崲涓� com.xxx +* 涓ョ鎵嬪姩淇敼 + ## 鍐呯疆鍔熻兘 1. 鐢ㄦ埛绠$悊锛氱敤鎴锋槸绯荤粺鎿嶄綔鑰咃紝璇ュ姛鑳戒富瑕佸畬鎴愮郴缁熺敤鎴烽厤缃�� @@ -100,6 +105,47 @@ 17. 鍦ㄧ嚎鏋勫缓鍣細鎷栧姩琛ㄥ崟鍏冪礌鐢熸垚鐩稿簲鐨凥TML浠g爜銆� 18. 杩炴帴姹犵洃瑙嗭細鐩戣褰撳墠绯荤粺鏁版嵁搴撹繛鎺ユ睜鐘舵�侊紝鍙繘琛屽垎鏋怱QL鎵惧嚭绯荤粺鎬ц兘鐡堕銆� +## 婕旂ず鍥句緥 + +<table border="1" cellpadding="1" cellspacing="1" style="width:500px"> + <tbody> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-972235bcbe3518dedd351ff0e2ee7d1031c.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-5e0097702fa91e2e36391de8127676a7fa1.png" width="1920" /></td> + </tr> + <tr> + <td> + <p><img src="https://oscimg.oschina.net/oscnet/up-e56e3828f48cd9886d88731766f06d5f3c1.png" width="1920" /></p> + </td> + <td><img src="https://oscimg.oschina.net/oscnet/up-0715990ea1a9f254ec2138fcd063c1f556a.png" width="1920" /></td> + </tr> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-eaf5417ccf921bb64abb959e3d8e290467f.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-fc285cf33095ebf8318de6999af0f473861.png" width="1920" /></td> + </tr> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-60c83fd8bd61c29df6dbf47c88355e9c272.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-7f731948c8b73c7d90f67f9e1c7a534d5c3.png" width="1920" /></td> + </tr> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-e4de89b5e2d20c52d3c3a47f9eb88eb8526.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-8791d823a508eb90e67c604f36f57491a67.png" width="1920" /></td> + </tr> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-4589afd99982ead331785299b894174feb6.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-8ea177cdacaea20995daf2f596b15232561.png" width="1920" /></td> + </tr> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-32d1d04c55c11f74c9129fbbc58399728c4.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-04fa118f7631b7ae6fd72299ca0a1430a63.png" width="1920" /></td> + </tr> + <tr> + <td><img src="https://oscimg.oschina.net/oscnet/up-fe7e85b65827802bfaadf3acd42568b58c7.png" width="1920" /></td> + <td><img src="https://oscimg.oschina.net/oscnet/up-eff2b02a54f8188022d8498cfe6af6fcc06.png" width="1920" /></td> + </tr> + </tbody> +</table> + ## 鍦ㄧ嚎浣撻獙 - admin/admin123 diff --git a/pom.xml b/pom.xml index a197fd3..6d52bf6 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ <description>RuoYi-Vue-Plus鍚庡彴绠$悊绯荤粺</description> <properties> - <ruoyi-vue-plus.version>2.2.0</ruoyi-vue-plus.version> + <ruoyi-vue-plus.version>2.2.1</ruoyi-vue-plus.version> <spring-boot.version>2.3.11.RELEASE</spring-boot.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -249,6 +249,14 @@ <profiles> <profile> + <id>local</id> + <properties> + <!-- 鐜鏍囪瘑锛岄渶瑕佷笌閰嶇疆鏂囦欢鐨勫悕绉扮浉瀵瑰簲 --> + <profiles.active>local</profiles.active> + <logging.level>debug</logging.level> + </properties> + </profile> + <profile> <id>dev</id> <properties> <!-- 鐜鏍囪瘑锛岄渶瑕佷笌閰嶇疆鏂囦欢鐨勫悕绉扮浉瀵瑰簲 --> 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 d26de0a..c8e9191 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 @@ -20,7 +20,7 @@ /** * 鍙傛暟閰嶇疆 淇℃伅鎿嶄綔澶勭悊 - * + * * @author ruoyi */ @RestController @@ -110,18 +110,19 @@ @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 157030f..a272a6e 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 @@ -21,7 +21,7 @@ /** * 鏁版嵁瀛楀吀淇℃伅 - * + * * @author ruoyi */ @RestController @@ -107,6 +107,7 @@ @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 306b6f2..e2e0625 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 @@ -19,7 +19,7 @@ /** * 鏁版嵁瀛楀吀淇℃伅 - * + * * @author ruoyi */ @RestController @@ -96,18 +96,19 @@ @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-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 3a2a03d..06456dd 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 @@ 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 @@ # redis 閰嶇疆 redis: # 鍦板潃 - host: 39.101.143.184 + host: localhost # 绔彛锛岄粯璁や负6379 port: 6379 # 鏁版嵁搴撶储寮� database: 0 # 瀵嗙爜 - password: ryvue + password: # 杩炴帴瓒呮椂鏃堕棿 timeout: 10s lettuce: 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 45addb3..7da0c66 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 @@ -156,6 +156,16 @@ } /** + * 鍒犻櫎鎸囧畾瀛楀吀缂撳瓨 + * + * @param key 瀛楀吀閿� + */ + public static void removeDictCache(String key) + { + SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key)); + } + + /** * 娓呯┖瀛楀吀缂撳瓨 */ public static void clearDictCache() 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 4d2f9bb..0a766e5 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 @@ -68,6 +68,7 @@ @Before("dataScopePointCut()") public void doBefore(JoinPoint point) throws Throwable { + clearDataScope(point); handleDataScope(point); } @@ -144,18 +145,8 @@ if (StrUtil.isNotBlank(sqlString.toString())) { - Object params = joinPoint.getArgs()[0]; - if (Validator.isNotNull(params)) - { - try { - Method getParams = params.getClass().getDeclaredMethod("getParams", null); - Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null); - invoke.put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); - } catch (Exception e) { - e.printStackTrace(); - } - } - } + putDataScope(joinPoint, sqlString.substring(4)); + } } /** @@ -173,4 +164,30 @@ } return null; } + + /** + * 鎷兼帴鏉冮檺sql鍓嶅厛娓呯┖params.dataScope鍙傛暟闃叉娉ㄥ叆 + */ + private void clearDataScope(final JoinPoint joinPoint) + { + Object params = joinPoint.getArgs()[0]; + if (Validator.isNotNull(params)) + { + putDataScope(joinPoint, ""); + } + } + + private static void putDataScope(JoinPoint joinPoint, String sql) { + Object params = joinPoint.getArgs()[0]; + if (Validator.isNotNull(params)) + { + try { + Method getParams = params.getClass().getDeclaredMethod("getParams", null); + Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null); + invoke.put(DATA_SCOPE, sql); + } catch (Exception e) { + // 鏂规硶鏈壘鍒� 涓嶅鐞� + } + } + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java index 7f09d7c..3d8971d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java @@ -1,7 +1,10 @@ package com.ruoyi.system.mapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.page.BaseMapperPlus; + +import java.util.List; /** * 瀛楀吀琛� 鏁版嵁灞� @@ -10,4 +13,11 @@ */ public interface SysDictDataMapper extends BaseMapperPlus<SysDictData> { + default List<SysDictData> selectDictDataByType(String dictType) { + return selectList( + new LambdaQueryWrapper<SysDictData>() + .eq(SysDictData::getStatus, "0") + .eq(SysDictData::getDictType, dictType) + .orderByAsc(SysDictData::getDictSort)); + } } 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 8384627..569ecf9 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 @@ -62,12 +62,22 @@ * @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 7cf20f0..5a19aa7 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 @@ -47,7 +47,7 @@ * @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 87b3c88..a806cbd 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 @@ -62,12 +62,22 @@ * @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 fbf6ec8..2376d8b 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,7 +20,6 @@ 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; @@ -33,175 +32,191 @@ @Service public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService { - @Autowired - private RedisCache redisCache; + @Autowired + private SysConfigMapper configMapper; - /** - * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧弬鏁板埌缂撳瓨 - */ - @PostConstruct - public void init() { - List<SysConfig> configsList = baseMapper.selectList(new LambdaQueryWrapper<>()); - for (SysConfig config : configsList) { - redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } - } + @Autowired + private RedisCache redisCache; - @Override - public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config) { - Map<String, Object> params = config.getParams(); - LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() - .like(StrUtil.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) - .eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) - .like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) - .apply(Validator.isNotEmpty(params.get("beginTime")), - "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')", - params.get("endTime")); - return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); - } + /** + * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧弬鏁板埌缂撳瓨 + */ + @PostConstruct + public void init() { + loadingConfigCache(); + } - /** - * 鏌ヨ鍙傛暟閰嶇疆淇℃伅 - * - * @param configId 鍙傛暟閰嶇疆ID - * @return 鍙傛暟閰嶇疆淇℃伅 - */ - @Override - @DataSource(DataSourceType.MASTER) - public SysConfig selectConfigById(Long configId) { - return baseMapper.selectById(configId); - } + @Override + public TableDataInfo<SysConfig> selectPageConfigList(SysConfig config) { + Map<String, Object> params = config.getParams(); + LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() + .like(StrUtil.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) + .eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) + .like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) + .apply(Validator.isNotEmpty(params.get("beginTime")), + "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')", + params.get("endTime")); + return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); + } - /** - * 鏍规嵁閿悕鏌ヨ鍙傛暟閰嶇疆淇℃伅 - * - * @param configKey 鍙傛暟key - * @return 鍙傛暟閿�� - */ - @Override - public String selectConfigByKey(String configKey) { - String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); - if (Validator.isNotEmpty(configValue)) { - return configValue; - } - SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() - .eq(SysConfig::getConfigKey, configKey)); - if (Validator.isNotNull(retConfig)) { - redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); - return retConfig.getConfigValue(); - } - return StrUtil.EMPTY; - } + /** + * 鏌ヨ鍙傛暟閰嶇疆淇℃伅 + * + * @param configId 鍙傛暟閰嶇疆ID + * @return 鍙傛暟閰嶇疆淇℃伅 + */ + @Override + @DataSource(DataSourceType.MASTER) + public SysConfig selectConfigById(Long configId) { + return baseMapper.selectById(configId); + } - /** - * 鏌ヨ鍙傛暟閰嶇疆鍒楄〃 - * - * @param config 鍙傛暟閰嶇疆淇℃伅 - * @return 鍙傛暟閰嶇疆闆嗗悎 - */ - @Override - public List<SysConfig> selectConfigList(SysConfig config) { - Map<String, Object> params = config.getParams(); - LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() - .like(StrUtil.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) - .eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) - .like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) - .apply(Validator.isNotEmpty(params.get("beginTime")), - "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')", - params.get("endTime")); - return baseMapper.selectList(lqw); - } + /** + * 鏍规嵁閿悕鏌ヨ鍙傛暟閰嶇疆淇℃伅 + * + * @param configKey 鍙傛暟key + * @return 鍙傛暟閿�� + */ + @Override + public String selectConfigByKey(String configKey) { + String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); + if (Validator.isNotEmpty(configValue)) { + return configValue; + } + SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>() + .eq(SysConfig::getConfigKey, configKey)); + if (Validator.isNotNull(retConfig)) { + redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); + return retConfig.getConfigValue(); + } + return StrUtil.EMPTY; + } - /** - * 鏂板鍙傛暟閰嶇疆 - * - * @param config 鍙傛暟閰嶇疆淇℃伅 - * @return 缁撴灉 - */ - @Override - public int insertConfig(SysConfig config) { - int row = baseMapper.insert(config); - if (row > 0) { - redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } - return row; - } + /** + * 鏌ヨ鍙傛暟閰嶇疆鍒楄〃 + * + * @param config 鍙傛暟閰嶇疆淇℃伅 + * @return 鍙傛暟閰嶇疆闆嗗悎 + */ + @Override + public List<SysConfig> selectConfigList(SysConfig config) { + Map<String, Object> params = config.getParams(); + LambdaQueryWrapper<SysConfig> lqw = new LambdaQueryWrapper<SysConfig>() + .like(StrUtil.isNotBlank(config.getConfigName()), SysConfig::getConfigName, config.getConfigName()) + .eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType()) + .like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey()) + .apply(Validator.isNotEmpty(params.get("beginTime")), + "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')", + params.get("endTime")); + return baseMapper.selectList(lqw); + } - /** - * 淇敼鍙傛暟閰嶇疆 - * - * @param config 鍙傛暟閰嶇疆淇℃伅 - * @return 缁撴灉 - */ - @Override - public int updateConfig(SysConfig config) { - int row = baseMapper.updateById(config); - if (row > 0) { - redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); - } - return row; - } + /** + * 鏂板鍙傛暟閰嶇疆 + * + * @param config 鍙傛暟閰嶇疆淇℃伅 + * @return 缁撴灉 + */ + @Override + public int insertConfig(SysConfig config) { + int row = baseMapper.insert(config); + if (row > 0) { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } - /** - * 鎵归噺鍒犻櫎鍙傛暟淇℃伅 - * - * @param configIds 闇�瑕佸垹闄ょ殑鍙傛暟ID - * @return 缁撴灉 - */ - @Override - public int deleteConfigByIds(Long[] configIds) { - for (Long configId : configIds) { - SysConfig config = selectConfigById(configId); - if (StrUtil.equals(UserConstants.YES, config.getConfigType())) { - throw new CustomException(String.format("鍐呯疆鍙傛暟銆�%1$s銆戜笉鑳藉垹闄� ", config.getConfigKey())); - } - } - int count = baseMapper.deleteBatchIds(Arrays.asList(configIds)); - if (count > 0) { - Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); - redisCache.deleteObject(keys); - } - return count; - } + /** + * 淇敼鍙傛暟閰嶇疆 + * + * @param config 鍙傛暟閰嶇疆淇℃伅 + * @return 缁撴灉 + */ + @Override + public int updateConfig(SysConfig config) { + int row = baseMapper.updateById(config); + if (row > 0) { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } - /** - * 娓呯┖缂撳瓨鏁版嵁 - */ - @Override - public void clearCache() { - Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); - redisCache.deleteObject(keys); - } + /** + * 鎵归噺鍒犻櫎鍙傛暟淇℃伅 + * + * @param configIds 闇�瑕佸垹闄ょ殑鍙傛暟ID + * @return 缁撴灉 + */ + @Override + public void deleteConfigByIds(Long[] configIds) { + for (Long configId : configIds) { + SysConfig config = selectConfigById(configId); + if (StrUtil.equals(UserConstants.YES, config.getConfigType())) { + throw new CustomException(String.format("鍐呯疆鍙傛暟銆�%1$s銆戜笉鑳藉垹闄� ", config.getConfigKey())); + } + configMapper.deleteById(configId); + redisCache.deleteObject(getCacheKey(config.getConfigKey())); + } + } - /** - * 鏍¢獙鍙傛暟閿悕鏄惁鍞竴 - * - * @param config 鍙傛暟閰嶇疆淇℃伅 - * @return 缁撴灉 - */ - @Override - public String checkConfigKeyUnique(SysConfig config) { - Long configId = Validator.isNull(config.getConfigId()) ? -1L : config.getConfigId(); - SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey())); - if (Validator.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } + /** + * 鍔犺浇鍙傛暟缂撳瓨鏁版嵁 + */ + @Override + public void loadingConfigCache() { + List<SysConfig> configsList = selectConfigList(new SysConfig()); + for (SysConfig config : configsList) { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + } - /** - * 璁剧疆cache key - * - * @param configKey 鍙傛暟閿� - * @return 缂撳瓨閿甼ey - */ - private String getCacheKey(String configKey) { - return Constants.SYS_CONFIG_KEY + configKey; - } + /** + * 娓呯┖鍙傛暟缂撳瓨鏁版嵁 + */ + @Override + public void clearConfigCache() { + Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); + redisCache.deleteObject(keys); + } + + /** + * 閲嶇疆鍙傛暟缂撳瓨鏁版嵁 + */ + @Override + public void resetConfigCache() { + clearConfigCache(); + loadingConfigCache(); + } + + /** + * 鏍¢獙鍙傛暟閿悕鏄惁鍞竴 + * + * @param config 鍙傛暟閰嶇疆淇℃伅 + * @return 缁撴灉 + */ + @Override + public String checkConfigKeyUnique(SysConfig config) { + Long configId = Validator.isNull(config.getConfigId()) ? -1L : config.getConfigId(); + SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey())); + if (Validator.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 璁剧疆cache key + * + * @param configKey 鍙傛暟閿� + * @return 缂撳瓨閿甼ey + */ + private String getCacheKey(String configKey) { + return Constants.SYS_CONFIG_KEY + configKey; + } } 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 faae4aa..7038565 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 @@ -11,7 +11,6 @@ import com.ruoyi.system.service.ISysDictDataService; import org.springframework.stereotype.Service; -import java.util.Arrays; import java.util.List; /** @@ -22,100 +21,103 @@ @Service public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService { - @Override - public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData) { - LambdaQueryWrapper<SysDictData> lqw = new LambdaQueryWrapper<SysDictData>() - .eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) - .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) - .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) - .orderByAsc(SysDictData::getDictSort); - return PageUtils.buildDataInfo(page(PageUtils.buildPage(),lqw)); - } + @Override + public TableDataInfo<SysDictData> selectPageDictDataList(SysDictData dictData) { + LambdaQueryWrapper<SysDictData> lqw = new LambdaQueryWrapper<SysDictData>() + .eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) + .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) + .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) + .orderByAsc(SysDictData::getDictSort); + return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); + } - /** - * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀鏁版嵁 - * - * @param dictData 瀛楀吀鏁版嵁淇℃伅 - * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 - */ - @Override - public List<SysDictData> selectDictDataList(SysDictData dictData) { - return list(new LambdaQueryWrapper<SysDictData>() - .eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) - .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) - .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) - .orderByAsc(SysDictData::getDictSort)); - } + /** + * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀鏁版嵁 + * + * @param dictData 瀛楀吀鏁版嵁淇℃伅 + * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 + */ + @Override + public List<SysDictData> selectDictDataList(SysDictData dictData) { + return list(new LambdaQueryWrapper<SysDictData>() + .eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType()) + .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel()) + .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus()) + .orderByAsc(SysDictData::getDictSort)); + } - /** - * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏搁敭鍊兼煡璇㈠瓧鍏告暟鎹俊鎭� - * - * @param dictType 瀛楀吀绫诲瀷 - * @param dictValue 瀛楀吀閿�� - * @return 瀛楀吀鏍囩 - */ - @Override - public String selectDictLabel(String dictType, String dictValue) { - return getOne(new LambdaQueryWrapper<SysDictData>() - .select(SysDictData::getDictLabel) - .eq(SysDictData::getDictType, dictType) - .eq(SysDictData::getDictValue, dictValue)) - .getDictLabel(); - } + /** + * 鏍规嵁瀛楀吀绫诲瀷鍜屽瓧鍏搁敭鍊兼煡璇㈠瓧鍏告暟鎹俊鎭� + * + * @param dictType 瀛楀吀绫诲瀷 + * @param dictValue 瀛楀吀閿�� + * @return 瀛楀吀鏍囩 + */ + @Override + public String selectDictLabel(String dictType, String dictValue) { + return getOne(new LambdaQueryWrapper<SysDictData>() + .select(SysDictData::getDictLabel) + .eq(SysDictData::getDictType, dictType) + .eq(SysDictData::getDictValue, dictValue)) + .getDictLabel(); + } - /** - * 鏍规嵁瀛楀吀鏁版嵁ID鏌ヨ淇℃伅 - * - * @param dictCode 瀛楀吀鏁版嵁ID - * @return 瀛楀吀鏁版嵁 - */ - @Override - public SysDictData selectDictDataById(Long dictCode) { - return getById(dictCode); - } + /** + * 鏍规嵁瀛楀吀鏁版嵁ID鏌ヨ淇℃伅 + * + * @param dictCode 瀛楀吀鏁版嵁ID + * @return 瀛楀吀鏁版嵁 + */ + @Override + public SysDictData selectDictDataById(Long dictCode) { + return getById(dictCode); + } - /** - * 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅 - * - * @param dictCodes 闇�瑕佸垹闄ょ殑瀛楀吀鏁版嵁ID - * @return 缁撴灉 - */ - @Override - public int deleteDictDataByIds(Long[] dictCodes) { - int row = baseMapper.deleteBatchIds(Arrays.asList(dictCodes)); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } + /** + * 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅 + * + * @param dictCodes 闇�瑕佸垹闄ょ殑瀛楀吀鏁版嵁ID + * @return 缁撴灉 + */ + @Override + public void deleteDictDataByIds(Long[] dictCodes) { + for (Long dictCode : dictCodes) { + SysDictData data = selectDictDataById(dictCode); + baseMapper.deleteById(dictCode); + List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + } - /** - * 鏂板淇濆瓨瀛楀吀鏁版嵁淇℃伅 - * - * @param dictData 瀛楀吀鏁版嵁淇℃伅 - * @return 缁撴灉 - */ - @Override - public int insertDictData(SysDictData dictData) { - int row = baseMapper.insert(dictData); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } + /** + * 鏂板淇濆瓨瀛楀吀鏁版嵁淇℃伅 + * + * @param data 瀛楀吀鏁版嵁淇℃伅 + * @return 缁撴灉 + */ + @Override + public int insertDictData(SysDictData data) { + int row = baseMapper.insert(data); + if (row > 0) { + List<SysDictData> dictDatas = baseMapper.selectDictDataByType(data.getDictType()); + DictUtils.setDictCache(data.getDictType(), dictDatas); + } + return row; + } - /** - * 淇敼淇濆瓨瀛楀吀鏁版嵁淇℃伅 - * - * @param dictData 瀛楀吀鏁版嵁淇℃伅 - * @return 缁撴灉 - */ - @Override - public int updateDictData(SysDictData dictData) { - int row = baseMapper.updateById(dictData); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } + /** + * 淇敼淇濆瓨瀛楀吀鏁版嵁淇℃伅 + * + * @param data 瀛楀吀鏁版嵁淇℃伅 + * @return 缁撴灉 + */ + @Override + public int updateDictData(SysDictData data) { + int row = baseMapper.updateById(data); + if (row > 0) { + List<SysDictData> dictDatas = baseMapper.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 87acff4..79a4036 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,7 +21,6 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -33,197 +32,208 @@ @Service public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService { - @Autowired - private SysDictDataMapper dictDataMapper; + @Autowired + private SysDictTypeMapper dictTypeMapper; - /** - * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧瓧鍏稿埌缂撳瓨 - */ - @PostConstruct - public void init() { - List<SysDictType> dictTypeList = list(); - for (SysDictType dictType : dictTypeList) { - List<SysDictData> dictDatas = dictDataMapper.selectList( - new LambdaQueryWrapper<SysDictData>() - .eq(SysDictData::getStatus, 0) - .eq(SysDictData::getDictType, dictType.getDictType()) - .orderByAsc(SysDictData::getDictSort)); - DictUtils.setDictCache(dictType.getDictType(), dictDatas); - } - } + @Autowired + private SysDictDataMapper dictDataMapper; - @Override - public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType) { - Map<String, Object> params = dictType.getParams(); - LambdaQueryWrapper<SysDictType> lqw = new LambdaQueryWrapper<SysDictType>() - .like(StrUtil.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) - .eq(StrUtil.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) - .like(StrUtil.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) - .apply(Validator.isNotEmpty(params.get("beginTime")), - "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')", - params.get("endTime")); - return PageUtils.buildDataInfo(page(PageUtils.buildPage(),lqw)); - } + /** + * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧瓧鍏稿埌缂撳瓨 + */ + @PostConstruct + public void init() { + loadingDictCache(); + } - /** - * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀绫诲瀷 - * - * @param dictType 瀛楀吀绫诲瀷淇℃伅 - * @return 瀛楀吀绫诲瀷闆嗗悎淇℃伅 - */ - @Override - public List<SysDictType> selectDictTypeList(SysDictType dictType) { - Map<String, Object> params = dictType.getParams(); - return list(new LambdaQueryWrapper<SysDictType>() - .like(StrUtil.isNotBlank(dictType.getDictName()),SysDictType::getDictName, dictType.getDictName()) - .eq(StrUtil.isNotBlank(dictType.getStatus()),SysDictType::getStatus, dictType.getStatus()) - .like(StrUtil.isNotBlank(dictType.getDictType()),SysDictType::getDictType, dictType.getDictType()) - .apply(Validator.isNotEmpty(params.get("beginTime")), - "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')", - params.get("endTime"))); - } + @Override + public TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType) { + Map<String, Object> params = dictType.getParams(); + LambdaQueryWrapper<SysDictType> lqw = new LambdaQueryWrapper<SysDictType>() + .like(StrUtil.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) + .eq(StrUtil.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) + .like(StrUtil.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) + .apply(Validator.isNotEmpty(params.get("beginTime")), + "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')", + params.get("endTime")); + return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw)); + } - /** - * 鏍规嵁鎵�鏈夊瓧鍏哥被鍨� - * - * @return 瀛楀吀绫诲瀷闆嗗悎淇℃伅 - */ - @Override - public List<SysDictType> selectDictTypeAll() { - return list(); - } + /** + * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瀛楀吀绫诲瀷 + * + * @param dictType 瀛楀吀绫诲瀷淇℃伅 + * @return 瀛楀吀绫诲瀷闆嗗悎淇℃伅 + */ + @Override + public List<SysDictType> selectDictTypeList(SysDictType dictType) { + Map<String, Object> params = dictType.getParams(); + return list(new LambdaQueryWrapper<SysDictType>() + .like(StrUtil.isNotBlank(dictType.getDictName()), SysDictType::getDictName, dictType.getDictName()) + .eq(StrUtil.isNotBlank(dictType.getStatus()), SysDictType::getStatus, dictType.getStatus()) + .like(StrUtil.isNotBlank(dictType.getDictType()), SysDictType::getDictType, dictType.getDictType()) + .apply(Validator.isNotEmpty(params.get("beginTime")), + "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')", + params.get("endTime"))); + } - /** - * 鏍规嵁瀛楀吀绫诲瀷鏌ヨ瀛楀吀鏁版嵁 - * - * @param dictType 瀛楀吀绫诲瀷 - * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 - */ - @Override - public List<SysDictData> selectDictDataByType(String dictType) { - List<SysDictData> dictDatas = DictUtils.getDictCache(dictType); - if (CollUtil.isNotEmpty(dictDatas)) { - return dictDatas; - } - dictDatas = dictDataMapper.selectList(new LambdaQueryWrapper<SysDictData>() - .eq(SysDictData::getStatus, 0) - .eq(SysDictData::getDictType, dictType) - .orderByAsc(SysDictData::getDictSort)); - if (CollUtil.isNotEmpty(dictDatas)) { - DictUtils.setDictCache(dictType, dictDatas); - return dictDatas; - } - return null; - } + /** + * 鏍规嵁鎵�鏈夊瓧鍏哥被鍨� + * + * @return 瀛楀吀绫诲瀷闆嗗悎淇℃伅 + */ + @Override + public List<SysDictType> selectDictTypeAll() { + return list(); + } - /** - * 鏍规嵁瀛楀吀绫诲瀷ID鏌ヨ淇℃伅 - * - * @param dictId 瀛楀吀绫诲瀷ID - * @return 瀛楀吀绫诲瀷 - */ - @Override - public SysDictType selectDictTypeById(Long dictId) { - return getById(dictId); - } + /** + * 鏍规嵁瀛楀吀绫诲瀷鏌ヨ瀛楀吀鏁版嵁 + * + * @param dictType 瀛楀吀绫诲瀷 + * @return 瀛楀吀鏁版嵁闆嗗悎淇℃伅 + */ + @Override + public List<SysDictData> selectDictDataByType(String dictType) { + List<SysDictData> dictDatas = DictUtils.getDictCache(dictType); + if (CollUtil.isNotEmpty(dictDatas)) { + return dictDatas; + } + dictDatas = dictDataMapper.selectDictDataByType(dictType); + if (CollUtil.isNotEmpty(dictDatas)) { + DictUtils.setDictCache(dictType, dictDatas); + return dictDatas; + } + return null; + } - /** - * 鏍规嵁瀛楀吀绫诲瀷鏌ヨ淇℃伅 - * - * @param dictType 瀛楀吀绫诲瀷 - * @return 瀛楀吀绫诲瀷 - */ - @Override - public SysDictType selectDictTypeByType(String dictType) { - return getOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType)); - } + /** + * 鏍规嵁瀛楀吀绫诲瀷ID鏌ヨ淇℃伅 + * + * @param dictId 瀛楀吀绫诲瀷ID + * @return 瀛楀吀绫诲瀷 + */ + @Override + public SysDictType selectDictTypeById(Long dictId) { + return getById(dictId); + } - /** - * 鎵归噺鍒犻櫎瀛楀吀绫诲瀷淇℃伅 - * - * @param dictIds 闇�瑕佸垹闄ょ殑瀛楀吀ID - * @return 缁撴灉 - */ - @Override - public int deleteDictTypeByIds(Long[] dictIds) { - for (Long dictId : dictIds) { - SysDictType dictType = selectDictTypeById(dictId); - if (dictDataMapper.selectCount(new LambdaQueryWrapper<SysDictData>() - .eq(SysDictData::getDictType, dictType.getDictType())) > 0) { - throw new CustomException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", dictType.getDictName())); - } - } - int count = baseMapper.deleteBatchIds(Arrays.asList(dictIds)); - if (count > 0) { - DictUtils.clearDictCache(); - } - return count; - } + /** + * 鏍规嵁瀛楀吀绫诲瀷鏌ヨ淇℃伅 + * + * @param dictType 瀛楀吀绫诲瀷 + * @return 瀛楀吀绫诲瀷 + */ + @Override + public SysDictType selectDictTypeByType(String dictType) { + return getOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType)); + } - /** - * 娓呯┖缂撳瓨鏁版嵁 - */ - @Override - public void clearCache() { - DictUtils.clearDictCache(); - } + /** + * 鎵归噺鍒犻櫎瀛楀吀绫诲瀷淇℃伅 + * + * @param dictIds 闇�瑕佸垹闄ょ殑瀛楀吀ID + * @return 缁撴灉 + */ + @Override + public void deleteDictTypeByIds(Long[] dictIds) { + for (Long dictId : dictIds) { + SysDictType dictType = selectDictTypeById(dictId); + if (dictDataMapper.selectCount(new LambdaQueryWrapper<SysDictData>() + .eq(SysDictData::getDictType, dictType.getDictType())) > 0) { + throw new CustomException(String.format("%1$s宸插垎閰�,涓嶈兘鍒犻櫎", dictType.getDictName())); + } + dictTypeMapper.deleteById(dictId); + DictUtils.removeDictCache(dictType.getDictType()); + } + } - /** - * 鏂板淇濆瓨瀛楀吀绫诲瀷淇℃伅 - * - * @param dictType 瀛楀吀绫诲瀷淇℃伅 - * @return 缁撴灉 - */ - @Override - public int insertDictType(SysDictType dictType) { - int row = baseMapper.insert(dictType); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } + /** + * 鍔犺浇瀛楀吀缂撳瓨鏁版嵁 + */ + @Override + public void loadingDictCache() { + List<SysDictType> dictTypeList = list(); + for (SysDictType dictType : dictTypeList) { + List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); + DictUtils.setDictCache(dictType.getDictType(), dictDatas); + } + } - /** - * 淇敼淇濆瓨瀛楀吀绫诲瀷淇℃伅 - * - * @param dictType 瀛楀吀绫诲瀷淇℃伅 - * @return 缁撴灉 - */ - @Override - @Transactional - public int updateDictType(SysDictType dictType) { - SysDictType oldDict = getById(dictType.getDictId()); - dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() - .set(SysDictData::getDictType, dictType.getDictType()) - .eq(SysDictData::getDictType, oldDict.getDictType())); - int row = baseMapper.updateById(dictType); - if (row > 0) { - DictUtils.clearDictCache(); - } - return row; - } + /** + * 娓呯┖瀛楀吀缂撳瓨鏁版嵁 + */ + @Override + public void clearDictCache() { + DictUtils.clearDictCache(); + } - /** - * 鏍¢獙瀛楀吀绫诲瀷绉版槸鍚﹀敮涓� - * - * @param dict 瀛楀吀绫诲瀷 - * @return 缁撴灉 - */ - @Override - public String checkDictTypeUnique(SysDictType dict) { - Long dictId = Validator.isNull(dict.getDictId()) ? -1L : dict.getDictId(); - SysDictType dictType = getOne(new LambdaQueryWrapper<SysDictType>() - .eq(SysDictType::getDictType, dict.getDictType()) - .last("limit 1")); - if (Validator.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } + /** + * 閲嶇疆瀛楀吀缂撳瓨鏁版嵁 + */ + @Override + public void resetDictCache() { + clearDictCache(); + loadingDictCache(); + } + + /** + * 鏂板淇濆瓨瀛楀吀绫诲瀷淇℃伅 + * + * @param dict 瀛楀吀绫诲瀷淇℃伅 + * @return 缁撴灉 + */ + @Override + public int insertDictType(SysDictType dict) { + int row = baseMapper.insert(dict); + if (row > 0) { + DictUtils.setDictCache(dict.getDictType(), null); + } + return row; + } + + /** + * 淇敼淇濆瓨瀛楀吀绫诲瀷淇℃伅 + * + * @param dict 瀛楀吀绫诲瀷淇℃伅 + * @return 缁撴灉 + */ + @Override + @Transactional + public int updateDictType(SysDictType dict) { + SysDictType oldDict = getById(dict.getDictId()); + dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>() + .set(SysDictData::getDictType, dict.getDictType()) + .eq(SysDictData::getDictType, oldDict.getDictType())); + int row = baseMapper.updateById(dict); + if (row > 0) { + List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType()); + DictUtils.setDictCache(dict.getDictType(), dictDatas); + } + return row; + } + + /** + * 鏍¢獙瀛楀吀绫诲瀷绉版槸鍚﹀敮涓� + * + * @param dict 瀛楀吀绫诲瀷 + * @return 缁撴灉 + */ + @Override + public String checkDictTypeUnique(SysDictType dict) { + Long dictId = Validator.isNull(dict.getDictId()) ? -1L : dict.getDictId(); + SysDictType dictType = getOne(new LambdaQueryWrapper<SysDictType>() + .eq(SysDictType::getDictType, dict.getDictType()) + .last("limit 1")); + if (Validator.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 0f99671..21f6854 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -40,7 +40,9 @@ AND status = #{status} </if> <!-- 鏁版嵁鑼冨洿杩囨护 --> - ${params.dataScope} + <if test="params.dataScope != null and params.dataScope != ''"> + AND ( ${params.dataScope} ) + </if> order by d.parent_id, d.order_num </select> @@ -49,11 +51,10 @@ from sys_dept d left join sys_role_dept rd on d.dept_id = rd.dept_id where rd.role_id = #{roleId} - <if test="deptCheckStrictly"> - and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = - rd.dept_id and rd.role_id = #{roleId}) - </if> + <if test="deptCheckStrictly"> + and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId}) + </if> order by d.parent_id, d.order_num </select> -</mapper> \ No newline at end of file +</mapper> diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index 2e7162f..1a542f8 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -58,7 +58,9 @@ and date_format(r.create_time,'%y%m%d') <= date_format(#{role.params.endTime},'%y%m%d') </if> <!-- 鏁版嵁鑼冨洿杩囨护 --> - ${role.params.dataScope} + <if test="role.params.dataScope != null and role.params.dataScope != ''"> + AND ( ${role.params.dataScope} ) + </if> order by r.role_sort </select> @@ -81,7 +83,9 @@ and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') </if> <!-- 鏁版嵁鑼冨洿杩囨护 --> - ${params.dataScope} + <if test="params.dataScope != null and params.dataScope != ''"> + AND ( ${params.dataScope} ) + </if> order by r.role_sort </select> @@ -103,4 +107,4 @@ WHERE r.del_flag = '0' and u.user_name = #{userName} </select> -</mapper> \ No newline at end of file +</mapper> diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 1135dee..df59332 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -106,7 +106,9 @@ ancestors) )) </if> <!-- 鏁版嵁鑼冨洿杩囨护 --> - ${user.params.dataScope} + <if test="user.params.dataScope != null and user.params.dataScope != ''"> + AND ( ${user.params.dataScope} ) + </if> </select> <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> @@ -135,7 +137,9 @@ ancestors) )) </if> <!-- 鏁版嵁鑼冨洿杩囨护 --> - ${params.dataScope} + <if test="params.dataScope != null and params.dataScope != ''"> + AND ( ${params.dataScope} ) + </if> </select> <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult"> @@ -149,4 +153,4 @@ </select> -</mapper> \ No newline at end of file +</mapper> diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 4bdce36..e951b8d 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi-vue-plus", - "version": "2.2.0", + "version": "2.2.1", "description": "RuoYi-Vue-Plus鍚庡彴绠$悊绯荤粺", "author": "LionLi", "license": "MIT", diff --git a/ruoyi-ui/src/api/system/config.js b/ruoyi-ui/src/api/system/config.js index aff093d..4c5cb6b 100644 --- a/ruoyi-ui/src/api/system/config.js +++ b/ruoyi-ui/src/api/system/config.js @@ -51,10 +51,10 @@ }) } -// 娓呯悊鍙傛暟缂撳瓨 -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 37034d2..2f0532d 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 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/index.vue b/ruoyi-ui/src/views/index.vue index 9e07ee9..8dc5060 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -80,6 +80,17 @@ <span>鏇存柊鏃ュ織</span> </div> <el-collapse accordion> + <el-collapse-item title="v2.2.1 - 2021-5-29"> + <ol> + <li>add 澧炲姞 security 鏉冮檺妗嗘灦 @Async 寮傛娉ㄨВ閰嶇疆</li> + <li>update 浼樺寲鏁版嵁鏉冮檺sql 瑙e喅MP apply娉ㄥ叆闄勫甫 AND 璇硶闂</li> + <li>update 浼樺寲dataScope鍙傛暟闃叉娉ㄥ叆</li> + <li>update 浼樺寲鍙傛暟&瀛楀吀缂撳瓨鎿嶄綔</li> + <li>update 澧炲姞淇敼鍖呭悕鏂囨。</li> + <li>update 鏂囨。澧炲姞婕旂ず鍥句緥</li> + <li>fix 淇閮ㄩ棬绫籹ql绗﹀彿閿欒</li> + </ol> + </el-collapse-item> <el-collapse-item title="v2.2.0 - 2021-5-25"> <ol> <li>鍚屾鍗囩骇 RuoYi-Vue 3.5.0</li> @@ -180,7 +191,7 @@ data() { return { // 鐗堟湰鍙� - version: "2.2.0", + version: "2.2.1", }; }, methods: { diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue index 5198b00..4d6f7ae 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']" - >娓呯悊缂撳瓨</el-button> + >鍒锋柊缂撳瓨</el-button> </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> </el-row> @@ -181,7 +181,7 @@ </template> <script> -import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, clearCache } from "@/api/system/config"; +import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, refreshCache } from "@/api/system/config"; export default { name: "Config", @@ -355,10 +355,10 @@ this.exportLoading = false; }) }, - /** 娓呯悊缂撳瓨鎸夐挳鎿嶄綔 */ - handleClearCache() { - clearCache().then(response => { - this.msgSuccess("娓呯悊鎴愬姛"); + /** 鍒锋柊缂撳瓨鎸夐挳鎿嶄綔 */ + handleRefreshCache() { + refreshCache().then(() => { + this.msgSuccess("鍒锋柊鎴愬姛"); }); } } diff --git a/ruoyi-ui/src/views/system/dict/index.vue b/ruoyi-ui/src/views/system/dict/index.vue index 840ff1c..b23233e 100644 --- a/ruoyi-ui/src/views/system/dict/index.vue +++ b/ruoyi-ui/src/views/system/dict/index.vue @@ -105,9 +105,9 @@ plain icon="el-icon-refresh" size="mini" - @click="handleClearCache" + @click="handleRefreshCache" v-hasPermi="['system:dict:remove']" - >娓呯悊缂撳瓨</el-button> + >鍒锋柊缂撳瓨</el-button> </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> </el-row> @@ -189,7 +189,7 @@ </template> <script> -import { listType, getType, delType, addType, updateType, exportType, clearCache } from "@/api/system/dict/type"; +import { listType, getType, delType, addType, updateType, exportType, refreshCache } from "@/api/system/dict/type"; export default { name: "Dict", @@ -359,10 +359,10 @@ this.exportLoading = false; }) }, - /** 娓呯悊缂撳瓨鎸夐挳鎿嶄綔 */ - handleClearCache() { - clearCache().then(response => { - this.msgSuccess("娓呯悊鎴愬姛"); + /** 鍒锋柊缂撳瓨鎸夐挳鎿嶄綔 */ + handleRefreshCache() { + refreshCache().then(() => { + this.msgSuccess("鍒锋柊鎴愬姛"); }); } } -- Gitblit v1.9.3