diff --git a/README.md b/README.md index c32ef90fa..b51fe78b0 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ * 权限认证使用Jwt,支持多终端认证系统。 * 支持加载动态权限菜单,多方式轻松权限控制。 * 高效率开发,使用代码生成器可以一键生成前后端代码。 +* 提供了一个Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。 * 感谢[Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://gitee.com/elunez/eladmin-web?_from=gitee_search)。 * 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud) * 阿里云优惠券:[点我进入](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)   diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 344ee3780..e4396f979 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,11 +1,11 @@ { "name": "ruoyi", - "version": "2.2.0", + "version": "2.3.0", "description": "若依管理系统", "author": "若依", "license": "MIT", "scripts": { - "dev": "vue-cli-service serve", + "dev": "vue-cli-service serve --open", "build:prod": "vue-cli-service build", "build:stage": "vue-cli-service build --mode staging", "preview": "node build/index.js --preview", diff --git a/ruoyi-ui/src/api/system/config.js b/ruoyi-ui/src/api/system/config.js index f2e792c58..aff093d43 100644 --- a/ruoyi-ui/src/api/system/config.js +++ b/ruoyi-ui/src/api/system/config.js @@ -51,6 +51,14 @@ export function delConfig(configId) { }) } +// 清理参数缓存 +export function clearCache() { + return request({ + url: '/system/config/clearCache', + method: 'delete' + }) +} + // 导出参数 export function exportConfig(query) { return request({ @@ -58,4 +66,4 @@ export function exportConfig(query) { method: 'get', params: query }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/api/system/dict/data.js b/ruoyi-ui/src/api/system/dict/data.js index 55972043b..d7aca8923 100644 --- a/ruoyi-ui/src/api/system/dict/data.js +++ b/ruoyi-ui/src/api/system/dict/data.js @@ -20,7 +20,7 @@ export function getData(dictCode) { // 根据字典类型查询字典数据信息 export function getDicts(dictType) { return request({ - url: '/system/dict/data/dictType/' + dictType, + url: '/system/dict/data/type/' + dictType, method: 'get' }) } diff --git a/ruoyi-ui/src/api/system/dict/type.js b/ruoyi-ui/src/api/system/dict/type.js index b8d974e11..37034d2fc 100644 --- a/ruoyi-ui/src/api/system/dict/type.js +++ b/ruoyi-ui/src/api/system/dict/type.js @@ -43,6 +43,14 @@ export function delType(dictId) { }) } +// 清理参数缓存 +export function clearCache() { + return request({ + url: '/system/dict/type/clearCache', + method: 'delete' + }) +} + // 导出字典类型 export function exportType(query) { return request({ @@ -58,4 +66,4 @@ export function optionselect() { url: '/system/dict/type/optionselect', method: 'get' }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/assets/styles/element-variables.scss b/ruoyi-ui/src/assets/styles/element-variables.scss index 30a0e6bc7..8b7a48e9e 100644 --- a/ruoyi-ui/src/assets/styles/element-variables.scss +++ b/ruoyi-ui/src/assets/styles/element-variables.scss @@ -6,7 +6,7 @@ /* theme color */ $--color-primary: #1890ff; $--color-success: #13ce66; -$--color-warning: #FFBA00; +$--color-warning: #ffba00; $--color-danger: #ff4949; // $--color-info: #1E1E1E; diff --git a/ruoyi-ui/src/components/SvgIcon/index.vue b/ruoyi-ui/src/components/SvgIcon/index.vue index dbca903a6..e4bf5ade1 100644 --- a/ruoyi-ui/src/components/SvgIcon/index.vue +++ b/ruoyi-ui/src/components/SvgIcon/index.vue @@ -1,7 +1,7 @@ diff --git a/ruoyi-ui/src/layout/components/Sidebar/Link.vue b/ruoyi-ui/src/layout/components/Sidebar/Link.vue index eb4dd1079..530b3d5b3 100644 --- a/ruoyi-ui/src/layout/components/Sidebar/Link.vue +++ b/ruoyi-ui/src/layout/components/Sidebar/Link.vue @@ -1,7 +1,5 @@ - @@ -16,19 +14,28 @@ export default { required: true } }, + computed: { + isExternal() { + return isExternal(this.to) + }, + type() { + if (this.isExternal) { + return 'a' + } + return 'router-link' + } + }, methods: { - linkProps(url) { - if (isExternal(url)) { + linkProps(to) { + if (this.isExternal) { return { - is: 'a', - href: url, + href: to, target: '_blank', rel: 'noopener' } } return { - is: 'router-link', - to: url + to: to } } } diff --git a/ruoyi-ui/src/layout/components/Sidebar/index.vue b/ruoyi-ui/src/layout/components/Sidebar/index.vue index 3b6958467..c030aa15d 100644 --- a/ruoyi-ui/src/layout/components/Sidebar/index.vue +++ b/ruoyi-ui/src/layout/components/Sidebar/index.vue @@ -13,8 +13,8 @@ mode="vertical" > diff --git a/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue b/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue index 0ec76e72f..34a7e55fa 100644 --- a/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue +++ b/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue @@ -19,12 +19,21 @@ export default { return this.$refs.scrollContainer.$refs.wrap } }, + mounted() { + this.scrollWrapper.addEventListener('scroll', this.emitScroll, true) + }, + beforeDestroy() { + this.scrollWrapper.removeEventListener('scroll', this.emitScroll) + }, methods: { handleScroll(e) { const eventDelta = e.wheelDelta || -e.deltaY * 40 const $scrollWrapper = this.scrollWrapper $scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4 }, + emitScroll() { + this.$emit('scroll') + }, moveToTarget(currentTag) { const $container = this.$refs.scrollContainer.$el const $containerWidth = $container.offsetWidth diff --git a/ruoyi-ui/src/layout/components/TagsView/index.vue b/ruoyi-ui/src/layout/components/TagsView/index.vue index ccccc71e4..19a20114e 100644 --- a/ruoyi-ui/src/layout/components/TagsView/index.vue +++ b/ruoyi-ui/src/layout/components/TagsView/index.vue @@ -1,318 +1,303 @@ diff --git a/ruoyi-ui/src/views/monitor/job/index.vue b/ruoyi-ui/src/views/monitor/job/index.vue index 3a693608d..c5f2f40f6 100644 --- a/ruoyi-ui/src/views/monitor/job/index.vue +++ b/ruoyi-ui/src/views/monitor/job/index.vue @@ -438,8 +438,6 @@ export default { this.msgSuccess("修改成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } else { @@ -448,8 +446,6 @@ export default { this.msgSuccess("新增成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } @@ -485,4 +481,4 @@ export default { } } }; - \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/config/index.vue b/ruoyi-ui/src/views/system/config/index.vue index 035ec82a7..dffe61180 100644 --- a/ruoyi-ui/src/views/system/config/index.vue +++ b/ruoyi-ui/src/views/system/config/index.vue @@ -88,6 +88,15 @@ v-hasPermi="['system:config:export']" >导出 + + 清理缓存 + @@ -165,7 +174,7 @@ \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue index b503d8527..c1e5d47a5 100644 --- a/ruoyi-ui/src/views/system/dept/index.vue +++ b/ruoyi-ui/src/views/system/dept/index.vue @@ -56,17 +56,17 @@ \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/menu/index.vue b/ruoyi-ui/src/views/system/menu/index.vue index 61a22e54d..e9b8c9efd 100644 --- a/ruoyi-ui/src/views/system/menu/index.vue +++ b/ruoyi-ui/src/views/system/menu/index.vue @@ -49,16 +49,16 @@ - + \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue index fa2a9b20b..c9389fda4 100644 --- a/ruoyi-ui/src/views/system/role/index.vue +++ b/ruoyi-ui/src/views/system/role/index.vue @@ -482,8 +482,6 @@ export default { this.msgSuccess("修改成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } else { @@ -493,8 +491,6 @@ export default { this.msgSuccess("新增成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } @@ -510,8 +506,6 @@ export default { this.msgSuccess("修改成功"); this.openDataScope = false; this.getList(); - } else { - this.msgError(response.msg); } }); } @@ -545,4 +539,4 @@ export default { } } }; - \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 0bfa88aab..ec0a789b8 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -572,8 +572,6 @@ export default { resetUserPwd(row.userId, value).then(response => { if (response.code === 200) { this.msgSuccess("修改成功,新密码是:" + value); - } else { - this.msgError(response.msg); } }); }).catch(() => {}); @@ -588,8 +586,6 @@ export default { this.msgSuccess("修改成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } else { @@ -598,8 +594,6 @@ export default { this.msgSuccess("新增成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } diff --git a/ruoyi-ui/src/views/system/user/profile/resetPwd.vue b/ruoyi-ui/src/views/system/user/profile/resetPwd.vue index 3de5dfd92..0ff3435b6 100644 --- a/ruoyi-ui/src/views/system/user/profile/resetPwd.vue +++ b/ruoyi-ui/src/views/system/user/profile/resetPwd.vue @@ -59,8 +59,6 @@ export default { response => { if (response.code === 200) { this.msgSuccess("修改成功"); - } else { - this.msgError(response.msg); } } ); diff --git a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue index 2fd78e2a3..9bb5d4a7e 100644 --- a/ruoyi-ui/src/views/system/user/profile/userAvatar.vue +++ b/ruoyi-ui/src/views/system/user/profile/userAvatar.vue @@ -122,8 +122,6 @@ export default { this.open = false; this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl; this.msgSuccess("修改成功"); - } else { - this.msgError(response.msg); } this.$refs.cropper.clearCrop(); }); @@ -135,4 +133,4 @@ export default { } } }; - \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/user/profile/userInfo.vue b/ruoyi-ui/src/views/system/user/profile/userInfo.vue index e50198fc2..48b8537b9 100644 --- a/ruoyi-ui/src/views/system/user/profile/userInfo.vue +++ b/ruoyi-ui/src/views/system/user/profile/userInfo.vue @@ -2,7 +2,7 @@ - + @@ -64,8 +64,6 @@ export default { updateUserProfile(this.user).then(response => { if (response.code === 200) { this.msgSuccess("修改成功"); - } else { - this.msgError(response.msg); } }); } diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index b62fbbfde..4cf5f2839 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -82,12 +82,6 @@ module.exports = { }) .end() - config - // https://webpack.js.org/configuration/devtool/#development - .when(process.env.NODE_ENV === 'development', - config => config.devtool('cheap-source-map') - ) - config .when(process.env.NODE_ENV !== 'development', config => { diff --git a/ruoyi/pom.xml b/ruoyi/pom.xml index 7de05120e..982e7b37e 100644 --- a/ruoyi/pom.xml +++ b/ruoyi/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi - 2.2.0 + 2.3.0 jar ruoyi @@ -25,7 +25,7 @@ 1.8 1.3.2 1.2.5 - 1.2.68 + 1.2.70 1.1.14 2.5 1.3.3 diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java index 81f14efa0..1f7b9960b 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java @@ -109,6 +109,16 @@ public class Constants */ public static final String JWT_AUTHORITIES = "authorities"; + /** + * 参数管理 cache key + */ + public static final String SYS_CONFIG_KEY = "sys_config:"; + + /** + * 字典管理 cache key + */ + public static final String SYS_DICT_KEY = "sys_dict:"; + /** * 资源映射路径 前缀 */ diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java new file mode 100644 index 000000000..0c1ee5dba --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -0,0 +1,64 @@ +package com.ruoyi.common.utils; + +import java.util.Collection; +import java.util.List; +import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.framework.redis.RedisCache; +import com.ruoyi.project.system.domain.SysDictData; + +/** + * 字典工具类 + * + * @author ruoyi + */ +public class DictUtils +{ + /** + * 设置字典缓存 + * + * @param key 参数键 + * @param dictDatas 字典数据列表 + */ + public static void setDictCache(String key, List dictDatas) + { + SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas); + } + + /** + * 获取字典缓存 + * + * @param key 参数键 + * @return dictDatas 字典数据列表 + */ + public static List getDictCache(String key) + { + Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); + if (StringUtils.isNotNull(cacheObj)) + { + List DictDatas = StringUtils.cast(cacheObj); + return DictDatas; + } + return null; + } + + /** + * 清空字典缓存 + */ + public static void clearDictCache() + { + Collection keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*"); + SpringUtils.getBean(RedisCache.class).deleteObject(keys); + } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + public static String getCacheKey(String configKey) + { + return Constants.SYS_DICT_KEY + configKey; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java index e32daa51b..7e3969f1f 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java +++ b/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java @@ -450,4 +450,10 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } return sb.toString(); } + + @SuppressWarnings("unchecked") + public static T cast(Object obj) + { + return (T) obj; + } } \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java index db9566967..0f32e7602 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java @@ -118,4 +118,16 @@ public class SysConfigController extends BaseController { return toAjax(configService.deleteConfigByIds(configIds)); } + + /** + * 清空缓存 + */ + @PreAuthorize("@ss.hasPermi('system:config:remove')") + @Log(title = "参数管理", businessType = BusinessType.CLEAN) + @DeleteMapping("/clearCache") + public AjaxResult clearCache() + { + configService.clearCache(); + return AjaxResult.success(); + } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java index 3fa53d5d6..964878598 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java @@ -21,6 +21,7 @@ import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.page.TableDataInfo; import com.ruoyi.project.system.domain.SysDictData; import com.ruoyi.project.system.service.ISysDictDataService; +import com.ruoyi.project.system.service.ISysDictTypeService; /** * 数据字典信息 @@ -34,6 +35,9 @@ public class SysDictDataController extends BaseController @Autowired private ISysDictDataService dictDataService; + @Autowired + private ISysDictTypeService dictTypeService; + @PreAuthorize("@ss.hasPermi('system:dict:list')") @GetMapping("/list") public TableDataInfo list(SysDictData dictData) @@ -66,10 +70,10 @@ public class SysDictDataController extends BaseController /** * 根据字典类型查询字典数据信息 */ - @GetMapping(value = "/dictType/{dictType}") + @GetMapping(value = "/type/{dictType}") public AjaxResult dictType(@PathVariable String dictType) { - return AjaxResult.success(dictDataService.selectDictDataByType(dictType)); + return AjaxResult.success(dictTypeService.selectDictDataByType(dictType)); } /** diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java index 82d93d92c..bda874854 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java @@ -107,6 +107,18 @@ public class SysDictTypeController extends BaseController return toAjax(dictTypeService.deleteDictTypeByIds(dictIds)); } + /** + * 清空缓存 + */ + @PreAuthorize("@ss.hasPermi('system:dict:remove')") + @Log(title = "字典类型", businessType = BusinessType.CLEAN) + @DeleteMapping("/clearCache") + public AjaxResult clearCache() + { + dictTypeService.clearCache(); + return AjaxResult.success(); + } + /** * 获取字典选择框列表 */ diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java index ec2411088..f5aa2f0f7 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java @@ -50,14 +50,6 @@ public interface ISysConfigService */ public int updateConfig(SysConfig config); - /** - * 删除参数配置信息 - * - * @param configId 参数ID - * @return 结果 - */ - public int deleteConfigById(Long configId); - /** * 批量删除参数信息 * @@ -66,6 +58,11 @@ public interface ISysConfigService */ public int deleteConfigByIds(Long[] configIds); + /** + * 清空缓存数据 + */ + public void clearCache(); + /** * 校验参数键名是否唯一 * diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java index 8330365bd..f34bef135 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java @@ -18,14 +18,6 @@ public interface ISysDictDataService */ public List selectDictDataList(SysDictData dictData); - /** - * 根据字典类型查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据集合信息 - */ - public List selectDictDataByType(String dictType); - /** * 根据字典类型和字典键值查询字典数据信息 * @@ -43,14 +35,6 @@ public interface ISysDictDataService */ public SysDictData selectDictDataById(Long dictCode); - /** - * 通过字典ID删除字典数据信息 - * - * @param dictCode 字典数据ID - * @return 结果 - */ - public int deleteDictDataById(Long dictCode); - /** * 批量删除字典数据信息 * diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java index 7c650db00..9b69411c0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java @@ -1,6 +1,7 @@ package com.ruoyi.project.system.service; import java.util.List; +import com.ruoyi.project.system.domain.SysDictData; import com.ruoyi.project.system.domain.SysDictType; /** @@ -25,6 +26,14 @@ public interface ISysDictTypeService */ public List selectDictTypeAll(); + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + public List selectDictDataByType(String dictType); + /** * 根据字典类型ID查询信息 * @@ -41,14 +50,6 @@ public interface ISysDictTypeService */ public SysDictType selectDictTypeByType(String dictType); - /** - * 通过字典ID删除字典信息 - * - * @param dictId 字典ID - * @return 结果 - */ - public int deleteDictTypeById(Long dictId); - /** * 批量删除字典信息 * @@ -57,6 +58,11 @@ public interface ISysDictTypeService */ public int deleteDictTypeByIds(Long[] dictIds); + /** + * 清空缓存数据 + */ + public void clearCache(); + /** * 新增保存字典类型信息 * diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java index 684338879..fcb26d45f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java @@ -1,10 +1,15 @@ package com.ruoyi.project.system.service.impl; +import java.util.Collection; import java.util.List; +import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.framework.redis.RedisCache; import com.ruoyi.project.system.domain.SysConfig; import com.ruoyi.project.system.mapper.SysConfigMapper; import com.ruoyi.project.system.service.ISysConfigService; @@ -20,6 +25,22 @@ public class SysConfigServiceImpl implements ISysConfigService @Autowired private SysConfigMapper configMapper; + @Autowired + private RedisCache redisCache; + + /** + * 项目启动时,初始化参数到缓存 + */ + @PostConstruct + public void init() + { + List configsList = configMapper.selectConfigList(new SysConfig()); + for (SysConfig config : configsList) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + } + /** * 查询参数配置信息 * @@ -43,10 +64,20 @@ public class SysConfigServiceImpl implements ISysConfigService @Override public String selectConfigByKey(String configKey) { + String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); + if (StringUtils.isNotEmpty(configValue)) + { + return configValue; + } SysConfig config = new SysConfig(); config.setConfigKey(configKey); SysConfig retConfig = configMapper.selectConfig(config); - return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : ""; + if (StringUtils.isNotNull(retConfig)) + { + redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); + return retConfig.getConfigValue(); + } + return StringUtils.EMPTY; } /** @@ -70,7 +101,12 @@ public class SysConfigServiceImpl implements ISysConfigService @Override public int insertConfig(SysConfig config) { - return configMapper.insertConfig(config); + int row = configMapper.insertConfig(config); + if (row > 0) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; } /** @@ -82,19 +118,12 @@ public class SysConfigServiceImpl implements ISysConfigService @Override public int updateConfig(SysConfig config) { - return configMapper.updateConfig(config); - } - - /** - * 删除参数配置信息 - * - * @param configId 参数ID - * @return 结果 - */ - @Override - public int deleteConfigById(Long configId) - { - return configMapper.deleteConfigById(configId); + int row = configMapper.updateConfig(config); + if (row > 0) + { + redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; } /** @@ -106,7 +135,22 @@ public class SysConfigServiceImpl implements ISysConfigService @Override public int deleteConfigByIds(Long[] configIds) { - return configMapper.deleteConfigByIds(configIds); + int count = configMapper.deleteConfigByIds(configIds); + if (count > 0) + { + Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); + redisCache.deleteObject(keys); + } + return count; + } + + /** + * 清空缓存数据 + */ + public void clearCache() + { + Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); + redisCache.deleteObject(keys); } /** @@ -126,4 +170,15 @@ public class SysConfigServiceImpl implements ISysConfigService } return UserConstants.UNIQUE; } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + private String getCacheKey(String configKey) + { + return Constants.SYS_CONFIG_KEY + configKey; + } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java index d3ac0bf46..0f531b722 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java @@ -3,6 +3,7 @@ package com.ruoyi.project.system.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.common.utils.DictUtils; import com.ruoyi.project.system.domain.SysDictData; import com.ruoyi.project.system.mapper.SysDictDataMapper; import com.ruoyi.project.system.service.ISysDictDataService; @@ -30,18 +31,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService return dictDataMapper.selectDictDataList(dictData); } - /** - * 根据字典类型查询字典数据 - * - * @param dictType 字典类型 - * @return 字典数据集合信息 - */ - @Override - public List selectDictDataByType(String dictType) - { - return dictDataMapper.selectDictDataByType(dictType); - } - /** * 根据字典类型和字典键值查询字典数据信息 * @@ -67,18 +56,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService return dictDataMapper.selectDictDataById(dictCode); } - /** - * 通过字典ID删除字典数据信息 - * - * @param dictCode 字典数据ID - * @return 结果 - */ - @Override - public int deleteDictDataById(Long dictCode) - { - return dictDataMapper.deleteDictDataById(dictCode); - } - /** * 批量删除字典数据信息 * @@ -87,7 +64,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService */ public int deleteDictDataByIds(Long[] dictCodes) { - return dictDataMapper.deleteDictDataByIds(dictCodes); + int row = dictDataMapper.deleteDictDataByIds(dictCodes); + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; } /** @@ -99,7 +81,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService @Override public int insertDictData(SysDictData dictData) { - return dictDataMapper.insertDictData(dictData); + int row = dictDataMapper.insertDictData(dictData); + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; } /** @@ -111,6 +98,11 @@ public class SysDictDataServiceImpl implements ISysDictDataService @Override public int updateDictData(SysDictData dictData) { - return dictDataMapper.updateDictData(dictData); + int row = dictDataMapper.updateDictData(dictData); + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java index 8249dca31..41ce43f43 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java @@ -1,11 +1,15 @@ package com.ruoyi.project.system.service.impl; import java.util.List; +import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.project.system.domain.SysDictData; import com.ruoyi.project.system.domain.SysDictType; import com.ruoyi.project.system.mapper.SysDictDataMapper; import com.ruoyi.project.system.mapper.SysDictTypeMapper; @@ -25,6 +29,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService @Autowired private SysDictDataMapper dictDataMapper; + /** + * 项目启动时,初始化字典到缓存 + */ + @PostConstruct + public void init() + { + List dictTypeList = dictTypeMapper.selectDictTypeAll(); + for (SysDictType dictType : dictTypeList) + { + List dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType()); + DictUtils.setDictCache(dictType.getDictType(), dictDatas); + } + } + /** * 根据条件分页查询字典类型 * @@ -48,6 +66,29 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService return dictTypeMapper.selectDictTypeAll(); } + /** + * 根据字典类型查询字典数据 + * + * @param dictType 字典类型 + * @return 字典数据集合信息 + */ + @Override + public List selectDictDataByType(String dictType) + { + List dictDatas = DictUtils.getDictCache(dictType); + if (StringUtils.isNotNull(dictDatas)) + { + return dictDatas; + } + dictDatas = dictDataMapper.selectDictDataByType(dictType); + if (StringUtils.isNotNull(dictDatas)) + { + DictUtils.setDictCache(dictType, dictDatas); + return dictDatas; + } + return null; + } + /** * 根据字典类型ID查询信息 * @@ -71,18 +112,6 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService return dictTypeMapper.selectDictTypeByType(dictType); } - /** - * 通过字典ID删除字典信息 - * - * @param dictId 字典ID - * @return 结果 - */ - @Override - public int deleteDictTypeById(Long dictId) - { - return dictTypeMapper.deleteDictTypeById(dictId); - } - /** * 批量删除字典类型信息 * @@ -91,7 +120,28 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService */ public int deleteDictTypeByIds(Long[] dictIds) { - return dictTypeMapper.deleteDictTypeByIds(dictIds); + for (Long dictId : dictIds) + { + SysDictType dictType = selectDictTypeById(dictId); + if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) + { + throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName())); + } + } + int count = dictTypeMapper.deleteDictTypeByIds(dictIds); + if (count > 0) + { + DictUtils.clearDictCache(); + } + return count; + } + + /** + * 清空缓存数据 + */ + public void clearCache() + { + DictUtils.clearDictCache(); } /** @@ -103,7 +153,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService @Override public int insertDictType(SysDictType dictType) { - return dictTypeMapper.insertDictType(dictType); + int row = dictTypeMapper.insertDictType(dictType); + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; } /** @@ -118,7 +173,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService { SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType()); - return dictTypeMapper.updateDictType(dictType); + int row = dictTypeMapper.updateDictType(dictType); + if (row > 0) + { + DictUtils.clearDictCache(); + } + return row; } /** diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java index 46ed87850..f24822977 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java @@ -140,7 +140,7 @@ public class SysMenuServiceImpl implements ISysMenuService { RouterVo router = new RouterVo(); router.setHidden("1".equals(menu.getVisible())); - router.setName(StringUtils.capitalize(menu.getPath())); + router.setName(getRouteName(menu)); router.setPath(getRouterPath(menu)); router.setComponent(getComponent(menu)); router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon())); @@ -299,6 +299,23 @@ public class SysMenuServiceImpl implements ISysMenuService return UserConstants.UNIQUE; } + /** + * 获取路由名称 + * + * @param menu 菜单信息 + * @return 路由名称 + */ + public String getRouteName(SysMenu menu) + { + String routerName = StringUtils.capitalize(menu.getPath()); + // 非外链并且是一级目录(类型为目录) + if (isMeunFrame(menu)) + { + routerName = StringUtils.EMPTY; + } + return routerName; + } + /** * 获取路由地址 * diff --git a/ruoyi/src/main/resources/application.yml b/ruoyi/src/main/resources/application.yml index c569e0e41..764e0c61a 100644 --- a/ruoyi/src/main/resources/application.yml +++ b/ruoyi/src/main/resources/application.yml @@ -3,7 +3,7 @@ ruoyi: # 名称 name: RuoYi # 版本 - version: 2.2.0 + version: 2.3.0 # 版权年份 copyrightYear: 2019 # 实例演示开关 diff --git a/ruoyi/src/main/resources/vm/sql/sql.vm b/ruoyi/src/main/resources/vm/sql/sql.vm index 36a485dfd..5ceea082e 100644 --- a/ruoyi/src/main/resources/vm/sql/sql.vm +++ b/ruoyi/src/main/resources/vm/sql/sql.vm @@ -6,17 +6,17 @@ values('${functionName}', '3', '1', '${businessName}', '${moduleName}/${business SELECT @parentId := LAST_INSERT_ID(); -- 按钮 SQL -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values('${functionName}查询', @parentId, '1', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values('${functionName}新增', @parentId, '2', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values('${functionName}修改', @parentId, '3', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values('${functionName}删除', @parentId, '4', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values('${functionName}导出', @parentId, '5', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); \ No newline at end of file diff --git a/ruoyi/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi/src/main/resources/vm/vue/index-tree.vue.vm index 1a74fca67..ffea73650 100644 --- a/ruoyi/src/main/resources/vm/vue/index-tree.vue.vm +++ b/ruoyi/src/main/resources/vm/vue/index-tree.vue.vm @@ -375,8 +375,6 @@ export default { this.msgSuccess("修改成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } else { @@ -385,8 +383,6 @@ export default { this.msgSuccess("新增成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } diff --git a/ruoyi/src/main/resources/vm/vue/index.vue.vm b/ruoyi/src/main/resources/vm/vue/index.vue.vm index 003aae62f..8cf19f454 100644 --- a/ruoyi/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi/src/main/resources/vm/vue/index.vue.vm @@ -392,8 +392,6 @@ export default { this.msgSuccess("修改成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); } else { @@ -402,8 +400,6 @@ export default { this.msgSuccess("新增成功"); this.open = false; this.getList(); - } else { - this.msgError(response.msg); } }); }