|
@@ -26,6 +26,7 @@ import com.tencentcloudapi.mps.v20190612.models.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
@@ -159,25 +160,64 @@ public class TencentCloudCosService implements ITencentCloudCosService {
|
|
|
return config;
|
|
|
}
|
|
|
|
|
|
+// @Override
|
|
|
+// @Transactional
|
|
|
+// public R updateUrl() {
|
|
|
+// try {
|
|
|
+// //查出已转码的视频并且没有文件key的
|
|
|
+// List<FsVideoResource> videos = videoResourceMapper.selectVideoIsTranscode();
|
|
|
+// for (FsVideoResource video : videos ){
|
|
|
+// String newUrl = replaceCourse(video.getLine1());
|
|
|
+// FsVideoResource videoMap = new FsVideoResource();
|
|
|
+// videoMap.setId(video.getId());
|
|
|
+// videoMap.setLine1(newUrl);
|
|
|
+// videoMap.setTranscodeFileKey(replaceCourse(video.getFileKey()));
|
|
|
+// videoResourceMapper.updateById(videoMap);
|
|
|
+// //更新课程管理目录的视频
|
|
|
+// FsUserCourseVideo courseVideo = new FsUserCourseVideo();
|
|
|
+// courseVideo.setFileKey(video.getFileKey());
|
|
|
+// courseVideo.setLineOne(newUrl);
|
|
|
+// courseVideo.setTranscodeFileKey(videoMap.getTranscodeFileKey());
|
|
|
+// courseVideoMapper.updateFsUserCourseVideoByFileKey(courseVideo);
|
|
|
+//
|
|
|
+// }
|
|
|
+// return R.ok();
|
|
|
+// }catch (Exception e){
|
|
|
+// return R.error();
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
public R updateUrl() {
|
|
|
try {
|
|
|
- //查出已转码的视频并且没有文件key的
|
|
|
- List<FsVideoResource> videos = videoResourceMapper.selectVideoIsTranscode();
|
|
|
- for (FsVideoResource video : videos ){
|
|
|
- String newUrl = replaceCourse(video.getLine1());
|
|
|
- FsVideoResource videoMap = new FsVideoResource();
|
|
|
- videoMap.setId(video.getId());
|
|
|
- videoMap.setLine1(newUrl);
|
|
|
- videoMap.setTranscodeFileKey(replaceCourse(video.getFileKey()));
|
|
|
- videoResourceMapper.updateById(videoMap);
|
|
|
+ List<FsVideoResource> videos = videoResourceMapper.selectVideoIsTranscode();
|
|
|
+ for (FsVideoResource video : videos) {
|
|
|
+ updateSingleVideo(video); // 将单个视频更新逻辑提取到方法
|
|
|
}
|
|
|
return R.ok();
|
|
|
- }catch (Exception e){
|
|
|
- return R.error();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error(e.getMessage());
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ // 为每个视频更新使用独立事务
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public void updateSingleVideo(FsVideoResource video) {
|
|
|
+ String newUrl = replaceCourse(video.getLine1());
|
|
|
+
|
|
|
+ FsVideoResource videoMap = new FsVideoResource();
|
|
|
+ videoMap.setId(video.getId());
|
|
|
+ videoMap.setLine1(newUrl);
|
|
|
+ videoMap.setTranscodeFileKey(replaceCourse(video.getFileKey()));
|
|
|
+ videoResourceMapper.updateById(videoMap);
|
|
|
+
|
|
|
+ FsUserCourseVideo courseVideo = new FsUserCourseVideo();
|
|
|
+ courseVideo.setFileKey(video.getFileKey());
|
|
|
+ courseVideo.setLineOne(newUrl);
|
|
|
+ courseVideo.setTranscodeFileKey(videoMap.getTranscodeFileKey());
|
|
|
+ courseVideoMapper.updateFsUserCourseVideoByFileKey(courseVideo);
|
|
|
}
|
|
|
|
|
|
private byte[] getObjectInputStream() throws IOException {
|