diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java index 9809dd5..7e14395 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -11,6 +11,7 @@ import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.umsAdmin.UmsStudent; import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.vo.courses.CoursesVO; +import com.teaching.backend.model.vo.courses.PersonalCenterStudentListVO; import com.teaching.backend.service.courses.ICoursesService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -131,8 +132,8 @@ public class CoursesController { @ApiOperation("查询学生列表") @PostMapping("/studentList") - public CommonResult> getStudentList(@RequestParam String userId){ - LinkedHashSet umsStudentList = coursesService.queryStudentList(userId); + public CommonResult> getStudentList(@RequestParam String userId){ + LinkedHashSet umsStudentList = coursesService.queryStudentList(userId); return CommonResult.success(umsStudentList); } diff --git a/src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java b/src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java new file mode 100644 index 0000000..e0fe434 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java @@ -0,0 +1,44 @@ +package com.teaching.backend.model.vo.courses; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +/** + *

+ * + *

+ * + * @author zjh + * @since 2024-06-12 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +public class PersonalCenterStudentListVO implements Serializable { + + + /** + * 头像 + */ + private String icon; + + /** + * 姓名 + */ + private String name; + + /** + * 学号 + */ + private String number; + +} 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 11ec74f..dcd643c 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java @@ -8,6 +8,7 @@ import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.umsAdmin.UmsStudent; import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.vo.courses.CoursesVO; +import com.teaching.backend.model.vo.courses.PersonalCenterStudentListVO; import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO; import javax.servlet.http.HttpServletResponse; @@ -46,5 +47,5 @@ public interface ICoursesService extends IService { Map getPagePageSize2(int page, int pageSize); - LinkedHashSet queryStudentList(String userId); + LinkedHashSet queryStudentList(String 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 dc52e6d..454688b 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 @@ -29,6 +29,7 @@ import com.teaching.backend.model.entity.umsAdmin.UmsUser; import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; import com.teaching.backend.model.vo.courses.CoursesVO; +import com.teaching.backend.model.vo.courses.PersonalCenterStudentListVO; import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO; import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.utils.CourseCode; @@ -352,7 +353,7 @@ public class CoursesServiceImpl extends ServiceImpl impl } @Override - public LinkedHashSet queryStudentList(String userId) { + public LinkedHashSet queryStudentList(String userId) { String roleId = umsUserMapper.getbyIdRoleId(userId); CourseQuery courseQuery = new CourseQuery(); courseQuery.setUserId(userId); @@ -360,7 +361,7 @@ public class CoursesServiceImpl extends ServiceImpl impl PageDTO queryCourses = queryCourses(courseQuery); List coursesList = queryCourses.getList(); List courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList()); - LinkedHashSet studentNameList = new LinkedHashSet<>(); + LinkedHashSet studentNameList = new LinkedHashSet<>(); for (String courseId : courseIds) { List studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId); List courseLearningRecordList = new ArrayList<>(); @@ -371,7 +372,12 @@ public class CoursesServiceImpl extends ServiceImpl impl courseLearningRecordList = courseLearningRecordList.stream().sorted(Comparator.comparing(CourseLearningRecord::getTimes).reversed()).collect(Collectors.toList()); for (CourseLearningRecord courseLearningRecord : courseLearningRecordList) { UmsStudent umsStudent = umsStudentMapper.selectByUserId(Integer.valueOf(courseLearningRecord.getUserId())); - studentNameList.add(umsStudent); + UmsUser user = umsUserMapper.selectById(courseLearningRecord.getUserId()); + PersonalCenterStudentListVO pcsl = new PersonalCenterStudentListVO(); + pcsl.setName(umsStudent.getName()); + pcsl.setNumber(umsStudent.getNumber()); + pcsl.setIcon(user.getIcon()); + studentNameList.add(pcsl); } } return studentNameList;