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

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. 26
      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("查询最新收藏") @ApiOperation("查询最新收藏")
@PostMapping("/newCollect") @PostMapping("/newCollect")
public CommonResult<CoursesVO> newCollect(@RequestParam String userId) { public CommonResult<List<CoursesVO>> newCollect(@RequestParam String userId) {
CoursesVO newCoursesVO = seCourseFavourService.queryNewCollect(userId); List<CoursesVO> newCoursesVO = seCourseFavourService.queryNewCollect(userId);
if (newCoursesVO == null){ if (newCoursesVO == null){
CommonResult.failed("用户或角色错误"); CommonResult.failed("用户或角色错误");
} }

@ -61,7 +61,7 @@ public class CourseLearningRecordController {
* 个人中心课程列表 * 个人中心课程列表
* @return * @return
*/ */
@ApiOperation("查询前4的课程") @ApiOperation("按新旧排序查询的课程列表")
@PostMapping("/courseList") @PostMapping("/courseList")
public CommonResult<List<CoursesVO>> courseList(@RequestParam String userId) { public CommonResult<List<CoursesVO>> courseList(@RequestParam String userId) {
List<CoursesVO> coursesVOList = courseLearningRecordService.queryCourseList(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.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour; import com.teaching.backend.model.entity.favour.SeCourseFavour;
import java.util.List;
/** /**
* 课程点赞数据库操作 * 课程点赞数据库操作
*/ */
public interface SeCourseFavourMapper extends BaseMapper<SeCourseFavour> { 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 * @param userId
* @return * @return
*/ */
CoursesVO queryNewCollect(String userId); List<CoursesVO> queryNewCollect(String userId);
} }

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

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

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

Loading…
Cancel
Save