|
@@ -130,18 +130,26 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
PageInfo<ClassGroup> pageInfo = new PageInfo<ClassGroup>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
-
|
|
|
+
|
|
|
List<ClassGroup> dataList = new ArrayList<ClassGroup>();
|
|
|
int count = this.findCount(params);
|
|
|
if (count > 0) {
|
|
|
- pageInfo.setTotal(count);
|
|
|
- params.put("offset", pageInfo.getOffset());
|
|
|
- dataList = this.getDAO().queryPage(params);
|
|
|
- }
|
|
|
- for (ClassGroup cg : dataList) {
|
|
|
- cg.setTeacherMapperList(classGroupTeacherMapperDao.findClassGroupTeachers(cg.getId() + ""));
|
|
|
- cg.setCourseScheduleList(courseScheduleDao.findCoursesByClassGroupId(cg.getId(), null));
|
|
|
- }
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = this.getDAO().queryPage(params);
|
|
|
+ List<Integer> classGroupIds = dataList.stream().map(ClassGroup::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Map<Integer, Integer>> classGroupStudentNumMaps = classGroupStudentMapperDao.countClassGroupsStudentNum(classGroupIds, null);
|
|
|
+ Map<Integer, Long> classGroupStudentNumMap = MapUtil.convertIntegerMap(classGroupStudentNumMaps);
|
|
|
+
|
|
|
+ for (ClassGroup cg : dataList) {
|
|
|
+ Long studentNum = classGroupStudentNumMap.get(cg.getId());
|
|
|
+ cg.setStudentNum(Objects.isNull(studentNum) ? 0 : studentNum.intValue());
|
|
|
+ cg.setTeacherMapperList(classGroupTeacherMapperDao.findClassGroupTeachers(cg.getId() + ""));
|
|
|
+ cg.setCourseScheduleList(courseScheduleDao.findCoursesByClassGroupId(cg.getId(), null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|
|
|
}
|