|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.dept;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
@@ -27,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
@@ -264,10 +266,17 @@ public class DeptServiceImpl implements DeptService {
|
|
|
// 查询当前登录人所属部门
|
|
|
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
AdminUserDO user = userMapper.selectById(userId);
|
|
|
- Long deptId = user.getDeptId();
|
|
|
- DeptDO dept = getDept(deptId);
|
|
|
- System.out.println("当前登录用户所属部门:" + dept.getName());
|
|
|
-
|
|
|
+ AtomicReference<Long> deptId = new AtomicReference<>(user.getDeptId());
|
|
|
+ if (CollUtil.isNotEmpty(reqVO.getDeptIds())) {
|
|
|
+ // 如果传递了参数 则是要查询指定部门的所有子部门
|
|
|
+ reqVO.getDeptIds().forEach(departmentId -> {
|
|
|
+ deptId.set(departmentId);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ DeptDO dept = getDept(deptId.get());
|
|
|
+ if (ObjUtil.isEmpty(dept)) {
|
|
|
+ throw exception(DEPT_NOT_FOUND);
|
|
|
+ }
|
|
|
// 用于存储最终需要返回的部门列表
|
|
|
List<DeptDO> resultDepts = new ArrayList<>();
|
|
|
|
|
@@ -379,7 +388,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
|
|
|
@Override
|
|
|
public List<DeptDO> companyLevelChildrenDepts(DeptListReqVO deptListReqVO) {
|
|
|
- List<DeptDO> companyLevelDepts = companyLevelDepts(null);
|
|
|
+ List<DeptDO> companyLevelDepts = companyLevelDepts(deptListReqVO);
|
|
|
List<DeptDO> resultDepts = new ArrayList<>();
|
|
|
// 查询每个公司级部门下的所有子部门
|
|
|
if (CollUtil.isNotEmpty(companyLevelDepts)) {
|