部门接口调整
parent
dd8c53c1b2
commit
9aa5b0bc0c
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -50,37 +51,18 @@ public class DepartmentQueryExe {
|
|||
}
|
||||
|
||||
public List<DepartmentTreeInfoCO> listTree(DepartmentTreeQry departmentQry) {
|
||||
if(Objects.isNull(departmentQry.getEqCorpinfoId())){
|
||||
if (Objects.isNull(departmentQry.getEqCorpinfoId())) {
|
||||
departmentQry.setEqCorpinfoId(AuthContext.getTenantId());
|
||||
|
||||
}
|
||||
Map<String, Object> parmas = PageQueryHelper.toHashMap(departmentQry);
|
||||
List<DepartmentDO> pageResponse = departmentRepository.listTree(parmas);
|
||||
if(CollUtil.isEmpty(pageResponse)) {
|
||||
if (CollUtil.isEmpty(pageResponse)) {
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue