From a1f4aaa646aa0c555ad062f7a93bbe0e63ff5173 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Mon, 5 Aug 2024 16:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E=E5=80=BC=E5=B0=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/courses/CoursesController.java | 5 ++- .../courses/PersonalCenterStudentListVO.java | 44 +++++++++++++++++++ .../service/courses/ICoursesService.java | 3 +- .../impl/courses/CoursesServiceImpl.java | 12 +++-- 4 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java 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;