Compare commits
No commits in common. "78820da98b1cf54289e9ba5bd3b36a1e4db3360a" and "f38b16b0dc6c7d461667903eed41e8ca7f3f688f" have entirely different histories.
78820da98b
...
f38b16b0dc
|
|
@ -5,7 +5,6 @@ import com.zcloud.basic.info.dto.clientobject.DepartmentTreeInfoCO;
|
||||||
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
||||||
import com.zcloud.gbscommon.zclouddepartment.response.ZcloudDepartmentInfoCo;
|
import com.zcloud.gbscommon.zclouddepartment.response.ZcloudDepartmentInfoCo;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import com.zcloud.basic.info.dto.clientobject.DepartmentTreeInfoCO;
|
||||||
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
||||||
import com.zcloud.basic.info.persistence.repository.DepartmentRepository;
|
import com.zcloud.basic.info.persistence.repository.DepartmentRepository;
|
||||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||||
import com.zcloud.gbscommon.utils.Tools;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
@ -51,18 +50,37 @@ public class DepartmentQueryExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DepartmentTreeInfoCO> listTree(DepartmentTreeQry departmentQry) {
|
public List<DepartmentTreeInfoCO> listTree(DepartmentTreeQry departmentQry) {
|
||||||
if (Objects.isNull(departmentQry.getEqCorpinfoId())) {
|
if(Objects.isNull(departmentQry.getEqCorpinfoId())){
|
||||||
departmentQry.setEqCorpinfoId(AuthContext.getTenantId());
|
departmentQry.setEqCorpinfoId(AuthContext.getTenantId());
|
||||||
|
|
||||||
}
|
}
|
||||||
Map<String, Object> parmas = PageQueryHelper.toHashMap(departmentQry);
|
Map<String, Object> parmas = PageQueryHelper.toHashMap(departmentQry);
|
||||||
List<DepartmentDO> pageResponse = departmentRepository.listTree(parmas);
|
List<DepartmentDO> pageResponse = departmentRepository.listTree(parmas);
|
||||||
if (CollUtil.isEmpty(pageResponse)) {
|
if(CollUtil.isEmpty(pageResponse)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
List<DepartmentTreeInfoCO> examCenterCOS = departmentCoConvertor.converDOsToInfoCOs(pageResponse);
|
List<DepartmentTreeInfoCO> examCenterCOS = departmentCoConvertor.converDOsToInfoCOs(pageResponse);
|
||||||
return Tools.buildEntityTree(examCenterCOS, "id", "parentId", "childrenList");
|
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 nodes;
|
||||||
|
}
|
||||||
|
|
||||||
public DepartmentCO info(Long id) {
|
public DepartmentCO info(Long id) {
|
||||||
DepartmentDO info = departmentRepository.getById(id);
|
DepartmentDO info = departmentRepository.getById(id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue