| | |
| | | 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; |
| | |
| | | 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.*; |
| | |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.cache.annotation.Caching; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | */ |
| | | @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())); |
| | | 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); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | return String.join(StringUtils.SEPARATOR, list); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门ID查询部门负责人 |
| | | * |
| | | * @param deptId 部门ID,用于指定需要查询的部门 |
| | | * @return 返回该部门的负责人ID |
| | | */ |
| | | @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); |
| | | } |
| | | |
| | | /** |
| | |
| | | @CacheEvict(cacheNames = CacheNames.SYS_DEPT_AND_CHILD, allEntries = true) |
| | | }) |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateDept(SysDeptBo bo) { |
| | | SysDept dept = MapstructUtils.convert(bo, SysDept.class); |
| | | SysDept oldDept = baseMapper.selectById(dept.getDeptId()); |