From 4d566071db7853c66805a1ffac2fd9c93a6aac8a Mon Sep 17 00:00:00 2001 From: xlsea <m@xlsea.cn> Date: 星期一, 16 十二月 2024 19:26:37 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysDeptServiceImpl.java | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 41 insertions(+), 7 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..0199ec7 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 @@ -1,5 +1,6 @@ package org.dromara.system.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.tree.Tree; @@ -10,6 +11,7 @@ import lombok.RequiredArgsConstructor; import org.dromara.common.core.constant.CacheNames; import org.dromara.common.core.constant.SystemConstants; +import org.dromara.common.core.domain.dto.DeptDTO; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.service.DeptService; import org.dromara.common.core.utils.*; @@ -27,6 +29,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; @@ -66,8 +69,6 @@ */ @Override public List<Tree<Long>> selectDeptTreeList(SysDeptBo bo) { - // 鍙煡璇㈡湭绂佺敤閮ㄩ棬 - bo.setStatus(SystemConstants.NORMAL); LambdaQueryWrapper<SysDept> lqw = buildQueryWrapper(bo); List<SysDeptVo> depts = baseMapper.selectDeptList(lqw); return buildDeptTreeSelect(depts); @@ -109,8 +110,9 @@ tree.setId(dept.getDeptId()) .setParentId(dept.getParentId()) .setName(dept.getDeptName()) - .setWeight(dept.getOrderNum())); - Tree<Long> tree = trees.stream().filter(it -> it.getId().longValue() == d.getDeptId()).findFirst().get(); + .setWeight(dept.getOrderNum()) + .putExtra("disabled", SystemConstants.DISABLE.equals(dept.getStatus()))); + Tree<Long> tree = StreamUtils.findFirst(trees, it -> it.getId().longValue() == d.getDeptId()); treeList.add(tree); } } @@ -144,7 +146,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; } @@ -172,6 +174,31 @@ } } return String.join(StringUtils.SEPARATOR, list); + } + + /** + * 鏍规嵁閮ㄩ棬ID鏌ヨ閮ㄩ棬璐熻矗浜� + * + * @param deptId 閮ㄩ棬ID锛岀敤浜庢寚瀹氶渶瑕佹煡璇㈢殑閮ㄩ棬 + * @return 杩斿洖璇ラ儴闂ㄧ殑璐熻矗浜篒D + */ + @Override + public Long selectDeptLeaderById(Long deptId) { + SysDeptVo vo = SpringUtils.getAopProxy(this).selectDeptById(deptId); + return vo.getLeader(); + } + + /** + * 鏌ヨ閮ㄩ棬 + * + * @return 閮ㄩ棬鍒楄〃 + */ + @Override + public List<DeptDTO> selectDeptsByList() { + List<SysDeptVo> list = baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>() + .select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getParentId) + .eq(SysDept::getStatus, SystemConstants.NORMAL)); + return BeanUtil.copyToList(list, DeptDTO.class); } /** @@ -250,6 +277,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 +296,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 +372,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