肖海南个人信息收藏列表修改

master
wenyu441069198 4 months ago
parent a1f4aaa646
commit 2bd2968cc6
  1. 4
      src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
  2. 2
      src/main/java/com/teaching/backend/controller/records/CourseLearningRecordController.java
  3. 6
      src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java
  4. 2
      src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
  5. 22
      src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
  6. 5
      src/main/resources/mapper/CourseLearningRecordMapper.xml
  7. 4
      src/main/resources/mapper/SeCourseFavourMapper.xml

@ -99,8 +99,8 @@ public class SeCourseFavourController {
*/
@ApiOperation("查询最新收藏")
@PostMapping("/newCollect")
public CommonResult<CoursesVO> newCollect(@RequestParam String userId) {
CoursesVO newCoursesVO = seCourseFavourService.queryNewCollect(userId);
public CommonResult<List<CoursesVO>> newCollect(@RequestParam String userId) {
List<CoursesVO> newCoursesVO = seCourseFavourService.queryNewCollect(userId);
if (newCoursesVO == null){
CommonResult.failed("用户或角色错误");
}

@ -61,7 +61,7 @@ public class CourseLearningRecordController {
* 个人中心课程列表
* @return
*/
@ApiOperation("查询前4的课程")
@ApiOperation("按新旧排序查询的课程列表")
@PostMapping("/courseList")
public CommonResult<List<CoursesVO>> courseList(@RequestParam String userId) {
List<CoursesVO> coursesVOList = courseLearningRecordService.queryCourseList(userId);

@ -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<SeCourseFavour> {
String queryAllNewCollectCourse();
List<String> queryAllNewCollectCourse();
String queryStudentNewCollectCourse(String userId);
List<String> queryStudentNewCollectCourse(String userId);
}

@ -61,5 +61,5 @@ public interface SeCourseFavourService extends IService<SeCourseFavour> {
* @param userId
* @return
*/
CoursesVO queryNewCollect(String userId);
List<CoursesVO> queryNewCollect(String userId);
}

@ -156,21 +156,27 @@ public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper,
}
@Override
public CoursesVO queryNewCollect(String userId) {
public List<CoursesVO> queryNewCollect(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
CoursesVO coursesVO = new CoursesVO();
List<Courses> coursesList = new ArrayList<>();
if (roleId.equals("1")){
//老师
String courseId = seCourseFavourMapper.queryAllNewCollectCourse();
List<String> courseIdList = seCourseFavourMapper.queryAllNewCollectCourse();
for (String courseId : courseIdList) {
Courses courses = coursesMapper.selectById(courseId);
BeanUtil.copyProperties(courses,coursesVO);
return coursesVO;
coursesList.add(courses);
}
List<CoursesVO> coursesVOList = BeanUtil.copyToList(coursesList, CoursesVO.class);
return coursesVOList;
}else if (roleId.equals("2")){
//学生
String courseId = seCourseFavourMapper.queryStudentNewCollectCourse(userId);
List<String> courseIdList = seCourseFavourMapper.queryStudentNewCollectCourse(userId);
for (String courseId : courseIdList) {
Courses courses = coursesMapper.selectById(courseId);
BeanUtil.copyProperties(courses,coursesVO);
return coursesVO;
coursesList.add(courses);
}
List<CoursesVO> coursesVOList = BeanUtil.copyToList(coursesList,CoursesVO.class);
return coursesVOList;
}else {
return null;
}

@ -19,14 +19,13 @@
course_learning_number cln
ORDER BY
number
DESC LIMIT 4;
DESC;
</select>
<select id="selectMaxCourseId" resultType="java.lang.String" parameterType="java.lang.String">
SELECT course_id, COUNT(*) as frequency
FROM course_learning_record
WHERE user_id = #{userId}
GROUP BY course_id
ORDER BY frequency DESC
LIMIT 4;
ORDER BY frequency DESC;
</select>
</mapper>

@ -10,7 +10,7 @@
se_course_favour scf
ORDER BY
createtime
DESC LIMIT 1;
DESC;
</select>
<select id="queryStudentNewCollectCourse" resultType="java.lang.String">
SELECT
@ -21,7 +21,7 @@
scf.user_id = #{userId}
ORDER BY
createtime
DESC LIMIT 1;
DESC;
</select>
</mapper>

Loading…
Cancel
Save