|
|
@@ -317,6 +317,27 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
fsUserCourseVideo.setListingStartTime(null);
|
|
|
fsUserCourseVideo.setListingEndTime(null);
|
|
|
}
|
|
|
+
|
|
|
+ // 如果修改了排序号,需要处理排序冲突
|
|
|
+ if (fsUserCourseVideo.getCourseSort() != null) {
|
|
|
+ // 获取原视频信息
|
|
|
+ FsUserCourseVideo oldVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(fsUserCourseVideo.getVideoId());
|
|
|
+ if (oldVideo != null && oldVideo.getCourseSort() != null) {
|
|
|
+ Long newSort = fsUserCourseVideo.getCourseSort();
|
|
|
+ Long oldSort = oldVideo.getCourseSort();
|
|
|
+
|
|
|
+ // 如果排序号发生了变化
|
|
|
+ if (!newSort.equals(oldSort)) {
|
|
|
+ // 检查新排序号是否已存在(排除当前视频)
|
|
|
+ Long count = fsUserCourseVideoMapper.selectFsUserCourseVideoByCourseSort(oldVideo.getCourseId(), newSort);
|
|
|
+ if (count > 0) {
|
|
|
+ // 新排序号已存在,需要将该排序号及之后的所有视频排序号+1
|
|
|
+ fsUserCourseVideoMapper.adjustCourseSortForUpdate(oldVideo.getCourseId(), newSort, fsUserCourseVideo.getVideoId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String videoRedisKey = "h5user:video:duration:" + fsUserCourseVideo.getVideoId();
|
|
|
redisCache.setCacheObject(videoRedisKey, fsUserCourseVideo.getDuration());
|
|
|
return fsUserCourseVideoMapper.updateFsUserCourseVideo(fsUserCourseVideo);
|
|
|
@@ -356,6 +377,17 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
@Override
|
|
|
public int deleteFsUserCourseVideoByVideoIds(String[] videoIds)
|
|
|
{
|
|
|
+ // 先获取要删除的视频信息,用于后续调整排序
|
|
|
+ if (videoIds != null && videoIds.length > 0) {
|
|
|
+ for (String videoIdStr : videoIds) {
|
|
|
+ Long videoId = Long.valueOf(videoIdStr);
|
|
|
+ FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
+ if (video != null && video.getCourseId() != null && video.getCourseSort() != null) {
|
|
|
+ // 删除视频后,将该排序号之后的所有视频排序号-1,保持排序连续
|
|
|
+ fsUserCourseVideoMapper.adjustCourseSortAfterDelete(video.getCourseId(), video.getCourseSort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return fsUserCourseVideoMapper.deleteFsUserCourseVideoByVideoIds(videoIds);
|
|
|
}
|
|
|
|
|
|
@@ -2575,9 +2607,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
videoResourceList = videoResourceList.stream()
|
|
|
.sorted(Comparator.comparing(FsVideoResource::getSort).thenComparing(FsVideoResource::getId))
|
|
|
.collect(Collectors.toList());
|
|
|
- FsUserCourseVideo param = new FsUserCourseVideo();
|
|
|
- param.setCourseId(vo.getCourseId());
|
|
|
- List<FsUserCourseVideo> videoList = selectFsUserCourseVideoList(param);
|
|
|
+ FsUserCourseVideo queryParam = new FsUserCourseVideo();
|
|
|
+ queryParam.setCourseId(vo.getCourseId());
|
|
|
+ List<FsUserCourseVideo> videoList = selectFsUserCourseVideoList(queryParam);
|
|
|
AtomicLong i = new AtomicLong(videoList.size() + 1);
|
|
|
String json = configService.selectConfigByKey("course.config");
|
|
|
CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
@@ -2615,18 +2647,26 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
LocalTime startTime = LocalTime.MIDNIGHT;
|
|
|
LocalTime endTime = LocalTime.of(23, 59, 59);
|
|
|
//获取营期数据
|
|
|
- coursePeriodsList.stream().filter(e -> e.getPeriodStatus() != 3).forEach(video -> {
|
|
|
- //循环新增到对应营期中
|
|
|
- collect.forEach(userCourseVideo->{
|
|
|
- FsUserCoursePeriodDays periodDaysEntity = new FsUserCoursePeriodDays();
|
|
|
- periodDaysEntity.setPeriodId(video.getPeriodId());//营期ID
|
|
|
- periodDaysEntity.setCourseId(video.getCourseId());//课程ID
|
|
|
- periodDaysEntity.setStartTime(startTime);
|
|
|
- periodDaysEntity.setVideoIds(Collections.singletonList(userCourseVideo.getVideoId()));
|
|
|
- periodDaysEntity.setEndTime1(endTime);
|
|
|
- periodDaysEntity.setJoinTime(endTime);
|
|
|
- fsUserCoursePeriodDaysService.addCourse(periodDaysEntity);
|
|
|
- });
|
|
|
+ coursePeriodsList.stream().filter(e -> e.getPeriodStatus() != 3).forEach(period -> {
|
|
|
+ // 修复:改用批量添加方法,避免课次号倒序问题
|
|
|
+ // 提取新增视频的ID列表
|
|
|
+ List<Long> newVideoIds = collect.stream()
|
|
|
+ .map(FsUserCourseVideo::getVideoId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 构建批量添加参数
|
|
|
+ BatchAddCourseSectionParam batchParam = new BatchAddCourseSectionParam();
|
|
|
+ batchParam.setPeriodId(period.getPeriodId());
|
|
|
+ batchParam.setCourseId(period.getCourseId());
|
|
|
+ batchParam.setVideoIds(newVideoIds);
|
|
|
+ batchParam.setStartTime(startTime);
|
|
|
+ batchParam.setEndDateTime(endTime);
|
|
|
+ batchParam.setJoinTime(endTime);
|
|
|
+ batchParam.setAutoSort(true); // 自动按courseSort排序
|
|
|
+ batchParam.setSkipDuplicate(true); // 跳过重复视频
|
|
|
+
|
|
|
+ // 调用批量添加方法
|
|
|
+ fsUserCoursePeriodDaysService.batchAddCourseSections(batchParam);
|
|
|
});
|
|
|
}
|
|
|
}
|