|
|
@ -19,6 +19,7 @@ import com.yunxi.scm.module.system.service.user.AdminUserService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
|
@ -41,6 +42,9 @@ public class DeptServiceImpl implements DeptService {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private DeptMapper deptMapper;
|
|
|
|
private DeptMapper deptMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
@Lazy
|
|
|
|
|
|
|
|
private AdminUserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
|
|
|
|
@CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
|
|
|
@ -205,17 +209,38 @@ public class DeptServiceImpl implements DeptService {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
@Override
|
|
|
|
// public List<DeptSimpleRespVO> buildTree(List<DeptSimpleRespVO> deptDOList, long pid) {
|
|
|
|
public List<DeptSimpleRespVO> buildTree(List<DeptSimpleRespVO> deptDOList, long pid) {
|
|
|
|
// List<DeptSimpleRespVO> treeList = new ArrayList<>();
|
|
|
|
List<DeptSimpleRespVO> treeList = new ArrayList<>();
|
|
|
|
// for (DeptSimpleRespVO dept : deptDOList) {
|
|
|
|
for (DeptSimpleRespVO dept : deptDOList) {
|
|
|
|
// if (dept.getParentId() == pid) {
|
|
|
|
if (dept.getParentId() == pid) {
|
|
|
|
// dept.setChildren(buildTree(deptDOList, dept.getId()));
|
|
|
|
dept.setChildren(buildTree(deptDOList, dept.getId()));
|
|
|
|
// treeList.add(dept);
|
|
|
|
treeList.add(dept);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// return treeList;
|
|
|
|
return treeList;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public List<DeptSimpleRespVO> setBuildTree(List<DeptSimpleRespVO> deptDOList, long pid) {
|
|
|
|
|
|
|
|
for (DeptSimpleRespVO dept : deptDOList) {
|
|
|
|
|
|
|
|
if (dept.getChildren() != null && dept.getChildren().size() > 0) {
|
|
|
|
|
|
|
|
setBuildTree(dept.getChildren(), dept.getId());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
List<AdminUserDO> adminUserList = userService.getUserListByDeptIds(Collections.singleton(dept.getId()));
|
|
|
|
|
|
|
|
List<DeptSimpleRespVO> simpleDeptList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (AdminUserDO adminUserDO : adminUserList) {
|
|
|
|
|
|
|
|
DeptSimpleRespVO deptSimpleRespVO = new DeptSimpleRespVO();
|
|
|
|
|
|
|
|
deptSimpleRespVO.setId(adminUserDO.getId());
|
|
|
|
|
|
|
|
deptSimpleRespVO.setParentId(adminUserDO.getDeptId());
|
|
|
|
|
|
|
|
deptSimpleRespVO.setName(adminUserDO.getNickname());
|
|
|
|
|
|
|
|
simpleDeptList.add(deptSimpleRespVO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dept.setChildren(simpleDeptList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return deptDOList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|