肖海南学生列表返回值小修改

master
wenyu441069198 4 months ago
parent cd9df0f9aa
commit a1f4aaa646
  1. 5
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  2. 44
      src/main/java/com/teaching/backend/model/vo/courses/PersonalCenterStudentListVO.java
  3. 3
      src/main/java/com/teaching/backend/service/courses/ICoursesService.java
  4. 12
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.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<LinkedHashSet<UmsStudent>> getStudentList(@RequestParam String userId){
LinkedHashSet<UmsStudent> umsStudentList = coursesService.queryStudentList(userId);
public CommonResult<LinkedHashSet<PersonalCenterStudentListVO>> getStudentList(@RequestParam String userId){
LinkedHashSet<PersonalCenterStudentListVO> umsStudentList = coursesService.queryStudentList(userId);
return CommonResult.success(umsStudentList);
}

@ -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;
/**
* <p>
*
* </p>
*
* @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;
}

@ -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<Courses> {
Map<String, Object> getPagePageSize2(int page, int pageSize);
LinkedHashSet<UmsStudent> queryStudentList(String userId);
LinkedHashSet<PersonalCenterStudentListVO> queryStudentList(String userId);
}

@ -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<CoursesMapper, Courses> impl
}
@Override
public LinkedHashSet<UmsStudent> queryStudentList(String userId) {
public LinkedHashSet<PersonalCenterStudentListVO> queryStudentList(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
CourseQuery courseQuery = new CourseQuery();
courseQuery.setUserId(userId);
@ -360,7 +361,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery);
List<CoursesVO> coursesList = queryCourses.getList();
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList());
LinkedHashSet<UmsStudent> studentNameList = new LinkedHashSet<>();
LinkedHashSet<PersonalCenterStudentListVO> studentNameList = new LinkedHashSet<>();
for (String courseId : courseIds) {
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId);
List<CourseLearningRecord> courseLearningRecordList = new ArrayList<>();
@ -371,7 +372,12 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> 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;

Loading…
Cancel
Save