部门接口调整

main
zhaokai 2025-11-04 14:43:02 +08:00
parent dd8c53c1b2
commit 9aa5b0bc0c
2 changed files with 5 additions and 22 deletions

View File

@ -5,6 +5,7 @@ import com.zcloud.basic.info.dto.clientobject.DepartmentTreeInfoCO;
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
import com.zcloud.gbscommon.zclouddepartment.response.ZcloudDepartmentInfoCo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import java.util.List;

View File

@ -15,6 +15,7 @@ import com.zcloud.basic.info.dto.clientobject.DepartmentTreeInfoCO;
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
import com.zcloud.basic.info.persistence.repository.DepartmentRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.gbscommon.utils.Tools;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -52,7 +53,6 @@ public class DepartmentQueryExe {
public List<DepartmentTreeInfoCO> listTree(DepartmentTreeQry departmentQry) {
if (Objects.isNull(departmentQry.getEqCorpinfoId())) {
departmentQry.setEqCorpinfoId(AuthContext.getTenantId());
}
Map<String, Object> parmas = PageQueryHelper.toHashMap(departmentQry);
List<DepartmentDO> pageResponse = departmentRepository.listTree(parmas);
@ -60,27 +60,9 @@ public class DepartmentQueryExe {
return Collections.emptyList();
}
List<DepartmentTreeInfoCO> examCenterCOS = departmentCoConvertor.converDOsToInfoCOs(pageResponse);
Map<Long, List<DepartmentTreeInfoCO>> childrenMap = new HashMap<>();
for (DepartmentTreeInfoCO dept : examCenterCOS) {
childrenMap
.computeIfAbsent(dept.getParentId(), k -> new ArrayList<>())
.add(dept);
}
return buildTree(childrenMap, 0L);
}
private List<DepartmentTreeInfoCO> buildTree(Map<Long, List<DepartmentTreeInfoCO>> childrenMap, Long parentId) {
List<DepartmentTreeInfoCO> nodes = childrenMap.get(parentId);
if (nodes == null) {
return Collections.emptyList();
}
for (DepartmentTreeInfoCO node : nodes) {
// 递归构建子节点
List<DepartmentTreeInfoCO> children = buildTree(childrenMap, node.getId());
node.setChildrenList(children);
return Tools.buildEntityTree(examCenterCOS, "id", "parentId", "childrenList");
}
return nodes;
}
public DepartmentCO info(Long id) {
DepartmentDO info = departmentRepository.getById(id);