好久没父子集查询,开始死活想不起来怎么递归,这里做个记录
public ResponseData getModuleList(String belongCode) { //先获取所有顶级指标 ArrayList<HashMap<String, Object>> rstList = new ArrayList<>(); List<HashMap<String, Object>> topModuleList = this.baseMapper.queryTopModuleList(belongCode); for (HashMap<String, Object> topModules:topModuleList) { querySonList(topModules); rstList.add(topModules); } return new SuccessResponseData(rstList); } private void querySonList(HashMap<String, Object> topModules){ String id = topModules.get("id").toString(); //查询子集 List<HashMap<String, Object>> sonLIst = this.baseMapper.querySonModuleList(id); if(null!=sonLIst){ topModules.put("subs", sonLIst); for (HashMap<String, Object> sonModule:sonLIst) { querySonList(sonModule); } } }