public CommonResponsePojo getDeptUnderUnitByUnitId(IdPojo idPojo, CommonResponsePojo baseResponsePojo, String code) {
try {
UaDept uaDept = new UaDept();
uaDept.setDeptAuditStatus((byte) 1);
uaDept.setDeptStatus((byte) 1);
List<UaDept> list = uaDeptMapper.select(uaDept);
List<UaDept> treeMenuList = treeMenuList(list, idPojo.getId());
baseResponsePojo.setData(treeMenuList);
} catch (Exception e) {
}
return baseResponsePojo;
}
private List<UaDept> treeMenuList(List<UaDept> menuList, Integer parentDeptId) {
List<UaDept> list = new ArrayList<>();
for (UaDept uaDept : menuList) {
Integer menuId = uaDept.getId();
Integer pid = uaDept.getParentDeptId();
if (menuId != null && pid != null) {
if (parentDeptId.equals(pid)) {
List<UaDept> cNode = treeMenuList(menuList, menuId);
if (cNode.size() == 0) {
cNode = null;
}
uaDept.setChildMenuList(cNode);
list.add(uaDept);
}
}
}
return list;
}