/**
* 仅适用于数据量小的情况下,否则会有并发问题 慎用
*/
@ResponseBody
@RequestMapping(value = "/getLayuiList", method = RequestMethod.POST)
public Object partWorkGetWorkList() {
//查出所有的大区
List<RegionArea> areaList1 = regionAreaDao.createLambdaQuery()
.andEq(RegionArea::getParentId, -1)
.select();
List<HashMap<String, Object>> resultV3 = new ArrayList<>();
for (RegionArea area : areaList1) {
HashMap<String, Object> mapr = new HashMap<>();
//查出省下面的所有市
List<RegionArea> areaList = regionAreaDao.createLambdaQuery()
.andEq(RegionArea::getParentId, area.getId())
.select();
List<HashMap<String, Object>> result = new ArrayList<>();
List<RegionArea> list = null;
for (RegionArea a : areaList) {
List<HashMap<String, Object>> resultV2 = new ArrayList<>();
//查出市下面的所有区
list = regionAreaDao.createLambdaQuery()
.andEq(RegionArea::getParentId, a.getId())
.select();
List<HashMap<String, Object>> result1=null;
result1 = new ArrayList<>();
for(RegionArea b:list){
HashMap<String, Object> map1 = new HashMap<>();
map1.put("id", b.getId());//id,title,spread等的命名是layui需要的,所以需要把获取到的list重新遍历一遍并命名成layui需要的字段名称
map1.put("title", b.getName());
map1.put("spread", false);
result1.add(map1);
}
HashMap<String, Object> map = new HashMap<>();
map.put("id", a.getId());//id,title,spread等的命名是layui需要的,所以需要把获取到的list重新遍历一遍并命名成layui需要的字段名称
map.put("title", a.getName());
map.put("spread", false);
map.put("children", result1);
result.add(map);
}
mapr.put("id", area.getId());//id,title,spread等的命名是layui需要的,所以需要把获取到的list重新遍历一遍并命名成layui需要的字段名称
mapr.put("title", area.getName());
mapr.put("spread", false);
mapr.put("children", result);
resultV3.add(mapr);
}
return resultV3;
}