public List<Map<String,Object>> findOrganization(){
List<Map<String,String>> collegeList = new ArrayList<>();//学院列表
List<Map<String,Object>> schoolList = new ArrayList<>();//学校列表
List<School> schools = schoolRepository.findAll();
for (School school: schools) {
Map<String,Object> schoolMap = new HashMap<>();//单个学校
List<College> colleges = collegeRepository.findBySchoolId(school.getId());
for (College college: colleges) {
Map<String, String> collegeMap = new HashMap<>();//单个学院
collegeMap.put("collegeId", college.getId());
collegeMap.put("collegeName", college.getName());
collegeList.add(collegeMap);
}
schoolMap.put("schoolName", school.getName());
schoolMap.put("collegeList", collegeList);
schoolList.add(schoolMap);
}
return schoolList;
}
转载于:https://my.oschina.net/zhangshsURL/blog/1581900