From b4678b74ab4de1f42580993985c1dfade485fe41 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 11 十一月 2024 13:52:16 +0800 Subject: [PATCH] update 优化 使用ObjectUtils新增方法封装代码 --- ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java index 44ff90e..a3f0b6f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java @@ -27,6 +27,7 @@ import org.dromara.system.service.ISysDeptService; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import org.springframework.cache.annotation.Caching; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -144,7 +145,7 @@ } SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>() .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId())); - dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null); + dept.setParentName(ObjectUtils.notNullGetter(parentDept, SysDeptVo::getDeptName)); return dept; } @@ -250,6 +251,7 @@ * @param bo 閮ㄩ棬淇℃伅 * @return 缁撴灉 */ + @CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true) @Override public int insertDept(SysDeptBo bo) { SysDept info = baseMapper.selectById(bo.getParentId()); @@ -268,7 +270,10 @@ * @param bo 閮ㄩ棬淇℃伅 * @return 缁撴灉 */ - @CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId") + @Caching(evict = { + @CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId"), + @CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true) + }) @Override public int updateDept(SysDeptBo bo) { SysDept dept = MapstructUtils.convert(bo, SysDept.class); @@ -341,7 +346,10 @@ * @param deptId 閮ㄩ棬ID * @return 缁撴灉 */ - @CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId") + @Caching(evict = { + @CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId"), + @CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, key = "#deptId") + }) @Override public int deleteDeptById(Long deptId) { return baseMapper.deleteById(deptId); -- Gitblit v1.9.3