//无限级递归查询
public RespEntity orgTreeList(String jsonParam) {
// jsonParam = HttpRequestUtil.commonHttpRequestParamConvert(getRequest());
return RespEntity.success(getOrganizations("0"));
}
public List<Organization> getOrganizations(String pid){
List<Organization> list = new ArrayList<>();
List<Organization> oneList = organizationMapper.selectList(new QueryWrapper<Organization>().eq("pid",pid));
for(Organization one : oneList){
List<Organization> twoList = getOrganizations(one.getId());
one.put("orgs",twoList);
list.add(one);
}
return list;
}
//四级递归查询
public List<Organization> list(String pid) {
一级
List<Organization> oneList = organizationMapper.selectList(new QueryWrapper<Organization>().eq("pid", "0"));
for (Organization one : oneList) {
//二级
List<Organization> twoList = organizationMapper.selectList(new QueryWrapper<Organization>().eq("pid", one.getId()));
for (Organization two : twoList) {
三级
List<Organization> threeList = organizationMapper.selectList(new QueryWrapper<Organization>().eq("pid", two.getId()));
for (Organization three : threeList) {
四级
List<Organization> fourList = organizationMapper.selectList(new QueryWrapper<Organization>().eq("pid", three.getId()));
three.put("orgs", fourList);
}
two.put("orgs", threeList);
}
one.put("orgs", twoList);
}
return oneList;
}