|
|
|
@ -407,25 +407,28 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public LinkedHashSet<UmsStudentManage> queryTeacherByStudentList(String userId) { |
|
|
|
|
public List<UmsStudentManage> queryTeacherByStudentList(String userId) { |
|
|
|
|
String roleId = umsUserMapper.getByIdRoleId(userId); |
|
|
|
|
CourseQuery courseQuery = new CourseQuery(); |
|
|
|
|
courseQuery.setUserId(userId); |
|
|
|
|
LinkedHashSet<UmsStudentManage> umsStudentManageList = new LinkedHashSet<>(); |
|
|
|
|
if (roleId.equals("1")){ |
|
|
|
|
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery); |
|
|
|
|
PageDTO<CoursesVO> queryCourses = queryForTeacher(courseQuery); |
|
|
|
|
List<CoursesVO> coursesList = queryCourses.getList(); |
|
|
|
|
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList()); |
|
|
|
|
for (String courseId : courseIds) { |
|
|
|
|
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId); |
|
|
|
|
for (StudentCourses studentUsername : studentUsernames) { |
|
|
|
|
UmsStudentManage umsStudentManage = umsStudentManageMapper.queryStudent(String.valueOf(studentUsername.getStudent())); |
|
|
|
|
if (umsStudentManage != null){ |
|
|
|
|
umsStudentManageList.add(umsStudentManage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return umsStudentManageList; |
|
|
|
|
|
|
|
|
|
// 首先,收集所有需要查询的学生ID
|
|
|
|
|
Set<Long> studentIds = coursesList.stream() |
|
|
|
|
.map(CoursesVO::getId) |
|
|
|
|
.flatMap(courseId -> studentCoursesMapper.selectBatchSomeStudent(courseId).stream() |
|
|
|
|
.map(StudentCourses::getStudent)) // 假设getStudent返回Long类型
|
|
|
|
|
.collect(Collectors.toSet()); // 使用Set去重
|
|
|
|
|
|
|
|
|
|
// 然后,一次性查询所有学生信息
|
|
|
|
|
List<UmsStudentManage> umsStudentManageLists = studentIds.stream() |
|
|
|
|
.map(studentId -> umsStudentManageMapper.queryStudent(String.valueOf(studentId))) // 假设queryStudent接受Long类型参数
|
|
|
|
|
.filter(Objects::nonNull) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
return umsStudentManageLists; |
|
|
|
|
} |
|
|
|
|
throw new BusinessException(400,"只有老师才有此功能"); |
|
|
|
|
} |
|
|
|
|