diff --git a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java index 5a61c49..fe2548b 100644 --- a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java +++ b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java @@ -99,8 +99,8 @@ public class SeCourseFavourController { */ @ApiOperation("查询最新收藏") @PostMapping("/newCollect") - public CommonResult newCollect(@RequestParam String userId) { - CoursesVO newCoursesVO = seCourseFavourService.queryNewCollect(userId); + public CommonResult> newCollect(@RequestParam String userId) { + List newCoursesVO = seCourseFavourService.queryNewCollect(userId); if (newCoursesVO == null){ CommonResult.failed("用户或角色错误"); } diff --git a/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java index 808cb8e..ed7b1b3 100644 --- a/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java +++ b/src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java @@ -61,7 +61,7 @@ public class CourseLearningRecordController { * 个人中心课程列表 * @return */ - @ApiOperation("查询前4的课程") + @ApiOperation("按新旧排序查询的课程列表") @PostMapping("/courseList") public CommonResult> courseList(@RequestParam String userId) { List coursesVOList = courseLearningRecordService.queryCourseList(userId); diff --git a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java index 3c9c766..55adb81 100644 --- a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java +++ b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java @@ -4,15 +4,17 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.favour.SeCourseFavour; +import java.util.List; + /** * 课程点赞数据库操作 */ public interface SeCourseFavourMapper extends BaseMapper { - String queryAllNewCollectCourse(); + List queryAllNewCollectCourse(); - String queryStudentNewCollectCourse(String userId); + List queryStudentNewCollectCourse(String userId); } diff --git a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java index 9723cbf..a8d1076 100644 --- a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java +++ b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java @@ -61,5 +61,5 @@ public interface SeCourseFavourService extends IService { * @param userId * @return */ - CoursesVO queryNewCollect(String userId); + List queryNewCollect(String userId); } diff --git a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java index bebe162..a260644 100644 --- a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java @@ -156,21 +156,27 @@ public class SeCourseFavourServiceImpl extends ServiceImpl queryNewCollect(String userId) { String roleId = umsUserMapper.getbyIdRoleId(userId); - CoursesVO coursesVO = new CoursesVO(); + List coursesList = new ArrayList<>(); if (roleId.equals("1")){ //老师 - String courseId = seCourseFavourMapper.queryAllNewCollectCourse(); - Courses courses = coursesMapper.selectById(courseId); - BeanUtil.copyProperties(courses,coursesVO); - return coursesVO; + List courseIdList = seCourseFavourMapper.queryAllNewCollectCourse(); + for (String courseId : courseIdList) { + Courses courses = coursesMapper.selectById(courseId); + coursesList.add(courses); + } + List coursesVOList = BeanUtil.copyToList(coursesList, CoursesVO.class); + return coursesVOList; }else if (roleId.equals("2")){ //学生 - String courseId = seCourseFavourMapper.queryStudentNewCollectCourse(userId); - Courses courses = coursesMapper.selectById(courseId); - BeanUtil.copyProperties(courses,coursesVO); - return coursesVO; + List courseIdList = seCourseFavourMapper.queryStudentNewCollectCourse(userId); + for (String courseId : courseIdList) { + Courses courses = coursesMapper.selectById(courseId); + coursesList.add(courses); + } + List coursesVOList = BeanUtil.copyToList(coursesList,CoursesVO.class); + return coursesVOList; }else { return null; } diff --git a/src/main/resources/mapper/CourseLearningRecordMapper.xml b/src/main/resources/mapper/CourseLearningRecordMapper.xml index 65d9f52..d117fc7 100644 --- a/src/main/resources/mapper/CourseLearningRecordMapper.xml +++ b/src/main/resources/mapper/CourseLearningRecordMapper.xml @@ -19,14 +19,13 @@ course_learning_number cln ORDER BY number - DESC LIMIT 4; + DESC; diff --git a/src/main/resources/mapper/SeCourseFavourMapper.xml b/src/main/resources/mapper/SeCourseFavourMapper.xml index 26ae03d..f310d5d 100644 --- a/src/main/resources/mapper/SeCourseFavourMapper.xml +++ b/src/main/resources/mapper/SeCourseFavourMapper.xml @@ -10,7 +10,7 @@ se_course_favour scf ORDER BY createtime - DESC LIMIT 1; + DESC;