|
@@ -39,6 +39,7 @@ import java.util.*;
|
|
|
public class TencentCloudCosService implements ITencentCloudCosService {
|
|
public class TencentCloudCosService implements ITencentCloudCosService {
|
|
|
private final COSClient cosClient;
|
|
private final COSClient cosClient;
|
|
|
private final TencentProperties tencentProperties;
|
|
private final TencentProperties tencentProperties;
|
|
|
|
|
+ private final FsUserCourseVideoMapper fsUserCourseVideoMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -202,6 +203,23 @@ public class TencentCloudCosService implements ITencentCloudCosService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
+ public R updateUrlByVideoId(Long videoId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
|
|
+ if (courseVideo != null) {
|
|
|
|
|
+ FsVideoResource video = videoResourceMapper.selectVideoByVideoUrl(courseVideo.getVideoUrl());
|
|
|
|
|
+ if (video != null) {
|
|
|
|
|
+ updateSingleVideo(video); // 将单个视频更新逻辑提取到方法
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return R.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 为每个视频更新使用独立事务
|
|
// 为每个视频更新使用独立事务
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
public void updateSingleVideo(FsVideoResource video) {
|
|
public void updateSingleVideo(FsVideoResource video) {
|
|
@@ -275,6 +293,24 @@ public class TencentCloudCosService implements ITencentCloudCosService {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R videoTranscodeById(Long videoId) {
|
|
|
|
|
+ FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
|
|
+ if (courseVideo != null) {
|
|
|
|
|
+ FsVideoResource video = videoResourceMapper.selectVideoByVideoUrl(courseVideo.getVideoUrl());
|
|
|
|
|
+ if (video != null) {
|
|
|
|
|
+ String inputPath = "/"+video.getFileKey();
|
|
|
|
|
+ String outputPath = "/"+replaceCourse(video.getFileKey());
|
|
|
|
|
+ submitTranscodeJob(inputPath,outputPath);
|
|
|
|
|
+ FsVideoResource videoMap = new FsVideoResource();
|
|
|
|
|
+ videoMap.setId(video.getId());
|
|
|
|
|
+ videoMap.setIsTranscode(1);
|
|
|
|
|
+ videoResourceMapper.updateById(videoMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private MpsClient createMpsClient() {
|
|
private MpsClient createMpsClient() {
|
|
|
Credential cred = new Credential(tencentProperties.secretId, tencentProperties.secretKey);
|
|
Credential cred = new Credential(tencentProperties.secretId, tencentProperties.secretKey);
|
|
|
HttpProfile httpProfile = new HttpProfile();
|
|
HttpProfile httpProfile = new HttpProfile();
|