| | |
| | | itemVO.setDifficultyName(trimToEmpty(row.getDifficultyName())); |
| | | itemVO.setSalePrice(defaultPrice(row.getSalePrice())); |
| | | itemVO.setLearnUserCount(defaultNumber(row.getLearnUserCount())); |
| | | itemVO.setStudyingCount(defaultNumber(row.getStudyingCount())); |
| | | result.add(itemVO); |
| | | } |
| | | return result; |
| | |
| | | if (courseDetail.getStatus() == null || courseDetail.getStatus().intValue() != COURSE_STATUS_ENABLED) { |
| | | throw new IllegalArgumentException("养生课程不存在"); |
| | | } |
| | | // 进入课程详情即视为一次学习行为,正在学习人数自增;返回值按自增后的口径展示 |
| | | incrementStudyingCount(courseId); |
| | | |
| | | List<HealthCourseVideo> enabledVideos = listEnabledVideos(courseId); |
| | | AppHealthCourseDetailVO detailVO = new AppHealthCourseDetailVO(); |
| | |
| | | detailVO.setDifficultyName(trimToEmpty(courseDetail.getDifficultyName())); |
| | | detailVO.setSalePrice(defaultPrice(courseDetail.getSalePrice())); |
| | | detailVO.setLearnUserCount(defaultNumber(courseDetail.getLearnUserCount())); |
| | | detailVO.setStudyingCount(Integer.valueOf(defaultNumber(courseDetail.getStudyingCount()) + 1)); |
| | | detailVO.setSummary(trimToEmpty(courseDetail.getSummary())); |
| | | detailVO.setTargetUsers(trimToEmpty(courseDetail.getTargetUsers())); |
| | | detailVO.setContent(trimToEmpty(courseDetail.getContent())); |
| | |
| | | itemVO.setTeacherName(trimToEmpty(row.getTeacherName())); |
| | | itemVO.setTeacherAvatar(trimToEmpty(row.getTeacherAvatar())); |
| | | itemVO.setLearnUserCount(defaultNumber(row.getLearnUserCount())); |
| | | itemVO.setStudyingCount(defaultNumber(row.getStudyingCount())); |
| | | itemVO.setFavoritedAt(row.getFavoritedAt()); |
| | | result.add(itemVO); |
| | | } |
| | |
| | | videoVO.setLocked(Boolean.valueOf(locked)); |
| | | // 已购买章节需要直接拿到视频地址,前端才能切换为下载入口。 |
| | | videoVO.setVideoUrl(trimToEmpty(video.getVideoUrl())); |
| | | videoVO.setCreatedAt(video.getCreatedAt()); |
| | | videoVO.setUpdatedAt(video.getUpdatedAt()); |
| | | result.add(videoVO); |
| | | } |
| | | return result; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 正在学习人数自增 1,进入课程详情时调用。 |
| | | */ |
| | | private void incrementStudyingCount(Long courseId) { |
| | | LambdaUpdateWrapper<HealthCourse> updateWrapper = new LambdaUpdateWrapper<HealthCourse>() |
| | | .eq(HealthCourse::getId, courseId) |
| | | .setSql("studying_count = COALESCE(studying_count, 0) + 1"); |
| | | healthCourseMapper.update(null, updateWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 构造收藏操作返回结果,避免控制器层重复拼装。 |
| | | */ |
| | | private AppHealthCourseFavoriteResultVO buildFavoriteResult(Long courseId, boolean favorited, Integer favoriteCount) { |