public List<Map<String, Object>> getdaohang() {
List<Map<String, Object>> listone = new ArrayList<>();
String sqlone = "SELECT id,name,url FROM column_info WHERE parent ='0' ORDER BY sort asc";
listone = sqlMapper.selectList(sqlone);
if (listone.size() > 0) {
for (int j = 0; j < listone.size(); j++) {
String sqltwo = "SELECT id,name,url FROM column_info WHERE parent ='" + listone.get(j).get("id")+ "' ORDER BY sort asc";
List<Map<String, Object>> listtwo = sqlMapper.selectList(sqltwo);
if (listtwo.size() > 0) {
for (int i = 0; i < listtwo.size(); i++) {
String sqlth = "SELECT id,name,url FROM column_info WHERE parent ='" + listtwo.get(i).get("id")+ "' ORDER BY sort asc";
List<Map<String, Object>> listth = sqlMapper.selectList(sqlth);
if (listth.size() > 0) {
listtwo.get(i).put("listth", listth);
}
}
listone.get(j).put("listtwo", listtwo);
}
}
}
return listone;
}
来源:https://www.cnblogs.com/douhuan/p/10956006.html