|
|
@@ -3,6 +3,8 @@ package com.tuoheng.admin.service.dept.query; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.DataPermissionEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.code.dept.QueryDeptChildListCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.DeptMapper; |
|
|
@@ -13,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@@ -35,17 +38,23 @@ public class QueryChildListService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JsonResult getChildList(String deptId) { |
|
|
|
log.info("进入查询子部门列表业务"); |
|
|
|
String tenantId = CurrentUserUtil.getTenantId(); |
|
|
|
User user = CurrentUserUtil.getUserInfo(); |
|
|
|
String tenantId = user.getTenantId(); |
|
|
|
JsonResult result = this.check(tenantId, deptId); |
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("根据id查询子部门列表业务:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); |
|
|
|
List<String> deptIdList; |
|
|
|
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { |
|
|
|
deptIdList = deptMapper.selectAllChildListById(deptId); |
|
|
|
} else { |
|
|
|
deptIdList = new ArrayList<>(); |
|
|
|
deptIdList.add(user.getDeptId()); |
|
|
|
} |
|
|
|
if (CollectionUtil.isEmpty(deptIdList)) { |
|
|
|
log.info("获取部门列表为空"); |
|
|
|
return JsonResult.error(QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getCode(), QueryDeptChildListCodeEnum.DEPT_LIST_IS_FAILED.getMsg()); |
|
|
|
return JsonResult.success(); |
|
|
|
} |
|
|
|
List<Dept> deptList = deptMapper.selectListByIdList(deptIdList); |
|
|
|
return JsonResult.success(deptList); |