tlias智能学习辅助系统--班级人数统计(统计)
1.ReportController.java
2.interface StudentService
3.StudentServiceImpl.java
4.interface StudentMapper
1.ReportController.java
// 班级人数统计 @GetMapping(\"/studentCountData\") @Operation(summary = \"班级人数统计\") public Result getStudentCount(){ log.info(\"班级人数统计\"); ClazzCountOption clazzCountOption = studentService.getStudentCount(); return Result.success(clazzCountOption); }
2.interface StudentService
// 班级人数统计 ClazzCountOption getStudentCount();
3.StudentServiceImpl.java
// 班级人数统计 @Override public ClazzCountOption getStudentCount() { List<Map> countList = studentMapper.getStudentCount(); if(!CollectionUtils.isEmpty(countList)){ List clazzList = countList.stream().map(map -> { return map.get(\"cname\"); }).toList(); List dataList = countList.stream().map(map -> { return map.get(\"scount\"); }).toList(); return new ClazzCountOption(clazzList, dataList); } return null; }
4.interface StudentMapper
// 班级人数统计 @Select(\"select c.name cname , count(s.id) scount from clazz c left join student s on s.clazz_id = c.id group by c.name order by count(s.id) desc\") List<Map> getStudentCount();