点赞数负数的情况
This commit is contained in:
@@ -127,11 +127,14 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||||||
.eq(CourseDetails::getCourseId, collect.getCourseId())
|
.eq(CourseDetails::getCourseId, collect.getCourseId())
|
||||||
.eq(CourseDetails::getCourseDetailsId, collect.getCourseDetailsId());
|
.eq(CourseDetails::getCourseDetailsId, collect.getCourseDetailsId());
|
||||||
CourseDetails courseDetails = courseDetailsService.getOne(queryWrapper);
|
CourseDetails courseDetails = courseDetailsService.getOne(queryWrapper);
|
||||||
|
int goods = courseDetails.getGoodNum() == null || courseDetails.getGoodNum() < 0 ? 0 : courseDetails.getGoodNum() - (isGood.equals(1) ? 1 : -1);
|
||||||
|
if (goods < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LambdaUpdateWrapper<CourseDetails> updateWrapper = new LambdaUpdateWrapper<CourseDetails>()
|
LambdaUpdateWrapper<CourseDetails> updateWrapper = new LambdaUpdateWrapper<CourseDetails>()
|
||||||
.eq(CourseDetails::getCourseId, collect.getCourseId())
|
.eq(CourseDetails::getCourseId, collect.getCourseId())
|
||||||
.eq(CourseDetails::getCourseDetailsId, collect.getCourseDetailsId())
|
.eq(CourseDetails::getCourseDetailsId, collect.getCourseDetailsId())
|
||||||
.set(CourseDetails::getGoodNum, courseDetails.getGoodNum() == null ? 0 : courseDetails.getGoodNum() - (isGood.equals(1) ? 1 : -1));
|
.set(CourseDetails::getGoodNum, goods);
|
||||||
courseDetailsService.update(updateWrapper);
|
courseDetailsService.update(updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +146,7 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||||||
if (classify.equals(1)) {
|
if (classify.equals(1)) {
|
||||||
//收藏记录
|
//收藏记录
|
||||||
courses = baseMapper.selectClassify1In3(userId);
|
courses = baseMapper.selectClassify1In3(userId);
|
||||||
}else if (classify.equals(2)){
|
} else if (classify.equals(2)) {
|
||||||
//点赞
|
//点赞
|
||||||
courses = baseMapper.selectClassify2(userId);
|
courses = baseMapper.selectClassify2(userId);
|
||||||
} else {
|
} else {
|
||||||
@@ -156,14 +159,14 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||||||
//详情id
|
//详情id
|
||||||
Set<Long> courseDetailIds = new HashSet<>();
|
Set<Long> courseDetailIds = new HashSet<>();
|
||||||
//剧集-观看记录时间
|
//剧集-观看记录时间
|
||||||
Map<Long,String> upTime = new HashMap<>();
|
Map<Long, String> upTime = new HashMap<>();
|
||||||
courses.forEach(s -> {
|
courses.forEach(s -> {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
courseIdList.add(s.getCourseId());
|
courseIdList.add(s.getCourseId());
|
||||||
courseDetailIds.add(s.getCourseDetailsId());
|
courseDetailIds.add(s.getCourseDetailsId());
|
||||||
upTime.put(s.getCourseId(),s.getUpdateTime());
|
upTime.put(s.getCourseId(), s.getUpdateTime());
|
||||||
});
|
});
|
||||||
List<Course> courseList = courseIdList.isEmpty() ? new ArrayList<>() :
|
List<Course> courseList = courseIdList.isEmpty() ? new ArrayList<>() :
|
||||||
courseDao.selectList(new LambdaQueryWrapper<Course>().in(Course::getCourseId, courseIdList));
|
courseDao.selectList(new LambdaQueryWrapper<Course>().in(Course::getCourseId, courseIdList));
|
||||||
|
|||||||
Reference in New Issue
Block a user