1.双层for循环
List<Map<String, Object>> result = newsflDao.fltree(userid);
List<Map<String, Object>> listvalue = new ArrayList<>();
List<Map<String, Object>> nodes;
for (Map<String, Object> stringObjectMap : result) {
nodes = new ArrayList<>();
for (Map<String, Object> objectMap : result) {
//给每个分类后面添加是否关注,默认为未关注
if(!stringObjectMap.containsKey("is_gz")){
stringObjectMap.put("is_gz",0);
}
//把子类放进nodes中
if (stringObjectMap.get("code").equals(objectMap.get("parent_code"))) {
nodes.add(objectMap);
}
}
if (nodes.size() > 0) {
stringObjectMap.put("nodes", nodes);
listvalue.add(stringOb