| | |
| | | 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; |
| | |
| | | */ |
| | | @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); |
| | |
| | | tree.setId(dept.getDeptId()) |
| | | .setParentId(dept.getParentId()) |
| | | .setName(dept.getDeptName()) |
| | | .setWeight(dept.getOrderNum())); |
| | | .setWeight(dept.getOrderNum()) |
| | | .putExtra("disabled", SystemConstants.DISABLE.equals(dept.getStatus()))); |
| | | Tree<Long> tree = trees.stream().filter(it -> it.getId().longValue() == d.getDeptId()).findFirst().get(); |
| | | treeList.add(tree); |
| | | } |
| | |
| | | } |
| | | 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; |
| | | } |
| | | |
| | |
| | | * @param bo 部门信息 |
| | | * @return 结果 |
| | | */ |
| | | @CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true) |
| | | @Override |
| | | public int insertDept(SysDeptBo bo) { |
| | | SysDept info = baseMapper.selectById(bo.getParentId()); |
| | |
| | | * @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); |
| | |
| | | * @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); |