喜欢列表 和 收藏列表
总集数
This commit is contained in:
@@ -20,4 +20,5 @@ public interface CourseCollectDao extends BaseMapper<CourseCollect> {
|
|||||||
|
|
||||||
|
|
||||||
List<Course> selectClassify1In3(@Param("userId") Long userId);
|
List<Course> selectClassify1In3(@Param("userId") Long userId);
|
||||||
|
List<Course> selectClassify1ByUserId(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,10 +132,16 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||||||
@CachePut(value = "app:courseCollect", key = "#userId")
|
@CachePut(value = "app:courseCollect", key = "#userId")
|
||||||
public Result selectByUserId(Integer page, Integer limit, Long userId, Integer classify) {
|
public Result selectByUserId(Integer page, Integer limit, Long userId, Integer classify) {
|
||||||
PageHelper.startPage(page, limit);
|
PageHelper.startPage(page, limit);
|
||||||
//查 收藏记录
|
List<Course> courses = new ArrayList<>();
|
||||||
List<Course> courses = baseMapper.selectClassify1In3(userId);
|
//收藏
|
||||||
|
if (classify.equals(1)) {
|
||||||
|
//查 收藏记录
|
||||||
|
courses = baseMapper.selectClassify1In3(userId);
|
||||||
|
} else {
|
||||||
|
courses = baseMapper.selectClassify1ByUserId(userId);
|
||||||
|
}
|
||||||
if (CollectionUtil.isEmpty(courses)) {
|
if (CollectionUtil.isEmpty(courses)) {
|
||||||
return Result.success();
|
return Result.success().put("data", PageUtils.page(new PageInfo<>(courses), true));
|
||||||
}
|
}
|
||||||
//剧id
|
//剧id
|
||||||
Set<Long> courseIdList = new HashSet<>();
|
Set<Long> courseIdList = new HashSet<>();
|
||||||
@@ -151,7 +157,8 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||||||
List<CourseDetails> courseDetails1 = courseIdList.isEmpty() ? new ArrayList<>() :
|
List<CourseDetails> courseDetails1 = courseIdList.isEmpty() ? new ArrayList<>() :
|
||||||
courseDetailsService.list(new LambdaQueryWrapper<CourseDetails>().in(CourseDetails::getCourseDetailsId, courseDetailIds));
|
courseDetailsService.list(new LambdaQueryWrapper<CourseDetails>().in(CourseDetails::getCourseDetailsId, courseDetailIds));
|
||||||
Map<Long, CourseDetails> courseDetailsMap = courseDetails1.stream().collect(Collectors.toMap(CourseDetails::getCourseId, item -> item));
|
Map<Long, CourseDetails> courseDetailsMap = courseDetails1.stream().collect(Collectors.toMap(CourseDetails::getCourseId, item -> item));
|
||||||
Map<Long, Integer> countMap = courseDetailsDao.countByCourseId(courseIdList).stream()
|
List<CourseDetails> courseDetails2 = courseDetailsDao.countByCourseId(courseIdList);
|
||||||
|
Map<Long, Integer> countMap = courseDetails2.stream()
|
||||||
.collect(Collectors.toMap(CourseDetails::getCourseId, CourseDetails::getCourseDetailsCount));
|
.collect(Collectors.toMap(CourseDetails::getCourseId, CourseDetails::getCourseDetailsCount));
|
||||||
|
|
||||||
if (CollectionUtil.isNotEmpty(courseList)) {
|
if (CollectionUtil.isNotEmpty(courseList)) {
|
||||||
|
|||||||
@@ -40,5 +40,15 @@
|
|||||||
WHERE
|
WHERE
|
||||||
c1.classify = 3
|
c1.classify = 3
|
||||||
AND c1.user_id = #{userId}
|
AND c1.user_id = #{userId}
|
||||||
|
order by c1.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectClassify1ByUserId" resultType="com.sqx.modules.course.entity.Course">
|
||||||
|
SELECT c1.course_id as courseId,
|
||||||
|
c1.course_details_id as courseDetailsId
|
||||||
|
FROM `course_collect` c1
|
||||||
|
WHERE c1.classify = 3
|
||||||
|
AND c1.user_id = #{userId}
|
||||||
|
order by c1.create_time desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
SELECT course_id as courseId,
|
SELECT course_id as courseId,
|
||||||
COUNT(*) AS courseDetailsCount
|
COUNT(*) AS courseDetailsCount
|
||||||
FROM course_details
|
FROM course_details
|
||||||
where course_details_id in
|
where course_id in
|
||||||
<foreach collection="courseIdList" item="ids" open="(" separator="," close=")">
|
<foreach collection="courseIdList" item="ids" open="(" separator="," close=")">
|
||||||
#{ids}
|
#{ids}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|||||||
Reference in New Issue
Block a user