feat: 班级学生列表返回主家长姓名与联系电话
- SchoolClassController: 学生列表补充 parentName、parentPhone - TeacherCourseController: 学生列表补充 parentName、parentPhone - 通过 ParentStudentMapper 查询主家长(isPrimary=1),关联 Parent 获取信息 Made-with: Cursor
This commit is contained in:
parent
1e73b480a0
commit
c2d194b45d
@ -21,9 +21,12 @@ import com.reading.platform.dto.response.StudentResponse;
|
||||
import com.reading.platform.entity.Clazz;
|
||||
import com.reading.platform.entity.ClassTeacher;
|
||||
import com.reading.platform.entity.Lesson;
|
||||
import com.reading.platform.entity.ParentStudent;
|
||||
import com.reading.platform.entity.Student;
|
||||
import com.reading.platform.entity.Teacher;
|
||||
import com.reading.platform.mapper.ClassTeacherMapper;
|
||||
import com.reading.platform.mapper.ParentMapper;
|
||||
import com.reading.platform.mapper.ParentStudentMapper;
|
||||
import com.reading.platform.mapper.LessonMapper;
|
||||
import com.reading.platform.service.ClassService;
|
||||
import com.reading.platform.service.StudentService;
|
||||
@ -52,6 +55,8 @@ public class SchoolClassController {
|
||||
private final StudentMapper studentMapper;
|
||||
private final TeacherService teacherService;
|
||||
private final LessonMapper lessonMapper;
|
||||
private final ParentMapper parentMapper;
|
||||
private final ParentStudentMapper parentStudentMapper;
|
||||
|
||||
@Operation(summary = "Create class")
|
||||
@Log(module = LogModule.CLASS, type = LogOperationType.CREATE, description = "创建新班级")
|
||||
@ -205,6 +210,20 @@ public class SchoolClassController {
|
||||
classService.getClassByIdWithTenantCheck(id, tenantId);
|
||||
Page<Student> page = studentService.getStudentsByClassId(id, pageNum, pageSize, keyword);
|
||||
List<StudentResponse> voList = studentMapper.toVO(page.getRecords());
|
||||
for (StudentResponse vo : voList) {
|
||||
var parentRelation = parentStudentMapper.selectOne(
|
||||
new LambdaQueryWrapper<ParentStudent>()
|
||||
.eq(ParentStudent::getStudentId, vo.getId())
|
||||
.eq(ParentStudent::getIsPrimary, 1)
|
||||
.last("LIMIT 1"));
|
||||
if (parentRelation != null) {
|
||||
var parent = parentMapper.selectById(parentRelation.getParentId());
|
||||
if (parent != null) {
|
||||
vo.setParentName(parent.getName());
|
||||
vo.setParentPhone(parent.getPhone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success(PageResult.of(voList, page.getTotal(), page.getCurrent(), page.getSize()));
|
||||
}
|
||||
|
||||
|
||||
@ -19,11 +19,14 @@ import com.reading.platform.dto.response.StudentResponse;
|
||||
import com.reading.platform.dto.response.TeacherResponse;
|
||||
import com.reading.platform.entity.Clazz;
|
||||
import com.reading.platform.entity.Lesson;
|
||||
import com.reading.platform.entity.ParentStudent;
|
||||
import com.reading.platform.entity.CoursePackage;
|
||||
import com.reading.platform.entity.Student;
|
||||
import com.reading.platform.entity.Teacher;
|
||||
import com.reading.platform.entity.CourseLesson;
|
||||
import com.reading.platform.mapper.LessonMapper;
|
||||
import com.reading.platform.mapper.ParentMapper;
|
||||
import com.reading.platform.mapper.ParentStudentMapper;
|
||||
import com.reading.platform.service.ClassService;
|
||||
import com.reading.platform.service.CourseLessonService;
|
||||
import com.reading.platform.service.CoursePackageService;
|
||||
@ -55,6 +58,8 @@ public class TeacherCourseController {
|
||||
private final StudentMapper studentMapper;
|
||||
private final TeacherMapper teacherMapper;
|
||||
private final LessonMapper lessonMapper;
|
||||
private final ParentMapper parentMapper;
|
||||
private final ParentStudentMapper parentStudentMapper;
|
||||
|
||||
@Operation(summary = "获取教师的班级列表")
|
||||
@GetMapping("/classes")
|
||||
@ -183,6 +188,20 @@ public class TeacherCourseController {
|
||||
Clazz clazz = classService.getClassByIdWithTenantCheck(id, tenantId);
|
||||
Page<Student> page = studentService.getStudentsByClassId(id, pageNum, pageSize, keyword);
|
||||
List<StudentResponse> voList = studentMapper.toVO(page.getRecords());
|
||||
for (StudentResponse vo : voList) {
|
||||
var parentRelation = parentStudentMapper.selectOne(
|
||||
new LambdaQueryWrapper<ParentStudent>()
|
||||
.eq(ParentStudent::getStudentId, vo.getId())
|
||||
.eq(ParentStudent::getIsPrimary, 1)
|
||||
.last("LIMIT 1"));
|
||||
if (parentRelation != null) {
|
||||
var parent = parentMapper.selectById(parentRelation.getParentId());
|
||||
if (parent != null) {
|
||||
vo.setParentName(parent.getName());
|
||||
vo.setParentPhone(parent.getPhone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int studentCount = studentService.getStudentListByClassId(id).size();
|
||||
long lessonCount = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user