diff --git a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java index ac2e4c7..6a507d9 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java @@ -51,6 +51,8 @@ public interface ICoursesService extends IService { Map getPagePageSize2(int page, int pageSize); List queryStudentList(String userId); + LinkedHashSet queryTeacherByStudentLearningRecordList(String userId); + LinkedHashSet queryTeacherByStudentList(String userId); List getUserInfByCourse(Long userId); diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 24f8d03..313b3aa 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -360,8 +360,7 @@ public class CoursesServiceImpl extends ServiceImpl impl @Override public List queryStudentList(String userId) { - LinkedHashSet umsStudentManageList = queryTeacherByStudentList(userId); - System.out.println("1111111"+umsStudentManageList); + LinkedHashSet umsStudentManageList = queryTeacherByStudentLearningRecordList(userId); List personalCenterStudentListVOList = new ArrayList<>(); PersonalCenterStudentListVO personalCenterStudentListVO = null; for (UmsStudentManage umsStudentManage : umsStudentManageList) { @@ -375,7 +374,7 @@ public class CoursesServiceImpl extends ServiceImpl impl } @Override - public LinkedHashSet queryTeacherByStudentList(String userId) { + public LinkedHashSet queryTeacherByStudentLearningRecordList(String userId) { String roleId = umsUserMapper.getByIdRoleId(userId); CourseQuery courseQuery = new CourseQuery(); courseQuery.setUserId(userId); @@ -404,7 +403,27 @@ public class CoursesServiceImpl extends ServiceImpl impl throw new BusinessException(400,"只有老师才有此功能"); } - + @Override + public LinkedHashSet queryTeacherByStudentList(String userId) { + String roleId = umsUserMapper.getByIdRoleId(userId); + CourseQuery courseQuery = new CourseQuery(); + courseQuery.setUserId(userId); + LinkedHashSet umsStudentManageList = new LinkedHashSet<>(); + if (roleId.equals("1")){ + PageDTO queryCourses = queryCourses(courseQuery); + List coursesList = queryCourses.getList(); + List courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList()); + for (String courseId : courseIds) { + List studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId); + for (StudentCourses studentUsername : studentUsernames) { + UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(String.valueOf(studentUsername.getStudent())); + umsStudentManageList.add(umsStudentManage); + } + } + return umsStudentManageList; + } + throw new BusinessException(400,"只有老师才有此功能"); + } @Override public List getPagePageSize(int page, int pageSize) {