|
|
@@ -1,13 +1,12 @@
|
|
|
package cn.reghao.tnb.content.app.vod.service.impl;
|
|
|
|
|
|
+import cn.reghao.file.api.dto.ObjectMeta;
|
|
|
+import cn.reghao.file.api.dto.VideoMeta;
|
|
|
import cn.reghao.file.api.iface.JobService;
|
|
|
import cn.reghao.file.api.iface.OssService;
|
|
|
import cn.reghao.jutil.jdk.web.result.Result;
|
|
|
import cn.reghao.jutil.jdk.string.IdGenerator;
|
|
|
-import cn.reghao.oss.api.dto.ObjectChannel;
|
|
|
-import cn.reghao.oss.api.dto.ObjectInfo;
|
|
|
-import cn.reghao.oss.api.dto.media.VideoInfo;
|
|
|
-import cn.reghao.oss.api.dto.media.VideoUrlDto;
|
|
|
+import cn.reghao.tnb.content.app.vod.model.dto.VideoUrlDto;
|
|
|
import cn.reghao.tnb.common.auth.UserContext;
|
|
|
import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoFilePublish;
|
|
|
@@ -62,8 +61,8 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
String title = videoFilePublish.getFilename();
|
|
|
String videoFileId = videoFilePublish.getVideoFileId();
|
|
|
int channelCode = videoFilePublish.getChannelCode();
|
|
|
- VideoInfo videoInfo = ossService.getVideoInfo(videoFileId);
|
|
|
- if (!videoInfo.getFormatName().contains("mov,mp4")) {
|
|
|
+ VideoMeta videoMeta = ossService.getVideoMeta(videoFileId);
|
|
|
+ if (!videoMeta.getFormatName().contains("mov,mp4")) {
|
|
|
//long jobId = jobService.addConvertVideoJob(videoFileId, channelCode);
|
|
|
/*Result result1 = fileService.convertVideo(videoFileId, channelCode);
|
|
|
if (result1.getCode() == ResultStatus.SUCCESS.getCode()) {
|
|
|
@@ -74,7 +73,7 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
}
|
|
|
|
|
|
String videoId = idGenerator.getUuid();
|
|
|
- VideoFile videoFile = new VideoFile(videoId, videoInfo, channelCode);
|
|
|
+ VideoFile videoFile = new VideoFile(videoId, videoMeta, channelCode);
|
|
|
VideoPost videoPost = new VideoPost(videoId, title, videoFile);
|
|
|
videoRepository.saveVideo(videoFile, videoPost);
|
|
|
return videoId;
|
|
|
@@ -84,12 +83,12 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
Result result;
|
|
|
try {
|
|
|
String coverFileId = videoPublishSbt.getCoverFileId();
|
|
|
- ObjectInfo objectInfo = ossService.getObjectInfo(coverFileId);
|
|
|
- if (objectInfo == null) {
|
|
|
+ ObjectMeta objectMeta = ossService.getObjectMeta(coverFileId);
|
|
|
+ if (objectMeta == null) {
|
|
|
String errMsg = String.format("封面文件 %s 在 oss 中不存在", coverFileId);
|
|
|
return Result.fail(errMsg);
|
|
|
}
|
|
|
- String coverUrl = objectInfo.getUrl();
|
|
|
+ String coverUrl = objectMeta.getUrl();
|
|
|
|
|
|
String videoId = videoPublishSbt.getVideoId();
|
|
|
VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
|
@@ -107,16 +106,8 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
String videoFileId = videoFile.getObjectId();
|
|
|
|
|
|
int channelCode = videoFile.getChannelCode();
|
|
|
- ObjectChannel objectChannel = ossService.getChannel(channelCode);
|
|
|
- if (objectChannel == null ) {
|
|
|
- String errMsg = String.format("channelCode %s 的 scope 在 oss 中不存在", channelCode);
|
|
|
- return Result.fail(errMsg);
|
|
|
- }
|
|
|
-
|
|
|
int scope = videoPublishSbt.getScope();
|
|
|
- if (objectChannel.getScope() != scope) {
|
|
|
- ossService.setObjectScope(videoFileId, scope);
|
|
|
- }
|
|
|
+ ossService.checkAndSetScope(videoFileId, scope);
|
|
|
|
|
|
Set<String> tags = videoPublishSbt.getTags();
|
|
|
String tags1 = tags.toString().replace("[", "").replace("]", "");
|
|
|
@@ -173,7 +164,7 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
String videoFileId = videoUrlDto.getObjectId();
|
|
|
try {
|
|
|
int scope = videoScopeUpdate.getScope();
|
|
|
- ossService.setObjectScope(videoFileId, scope);
|
|
|
+ ossService.checkAndSetScope(videoFileId, scope);
|
|
|
videoPostMapper.updateVideoScope(videoScopeUpdate);
|
|
|
} catch (Exception e) {
|
|
|
log.error("{}", e.getMessage());
|
|
|
@@ -200,12 +191,12 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
|
|
|
String coverFileId = videoCoverUpdate.getCoverFileId();
|
|
|
try {
|
|
|
- ObjectInfo objectInfo = ossService.getObjectInfo(coverFileId);
|
|
|
- if (objectInfo == null) {
|
|
|
+ ObjectMeta objectMeta = ossService.getObjectMeta(coverFileId);
|
|
|
+ if (objectMeta == null) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String coverUrl = objectInfo.getUrl();
|
|
|
+ String coverUrl = objectMeta.getUrl();
|
|
|
videoPostMapper.updateVideoCover(videoId, coverUrl);
|
|
|
String currentCover = videoPost.getCoverUrl();
|
|
|
deleteCoverFile(currentCover);
|
|
|
@@ -234,16 +225,16 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
String videoFileId = videoFileUpdate.getVideoFileId();
|
|
|
try {
|
|
|
int channelCode = 101;
|
|
|
- VideoInfo videoInfo = ossService.getVideoInfo(videoFileId);
|
|
|
- if (videoInfo == null) {
|
|
|
+ VideoMeta videoMeta = ossService.getVideoMeta(videoFileId);
|
|
|
+ if (videoMeta == null) {
|
|
|
log.error("{} not exist", videoFileId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- videoPostMapper.updateVideoFile(videoId, videoInfo);
|
|
|
+ videoPostMapper.updateVideoFile(videoId, videoMeta);
|
|
|
int scope = videoPost.getScope();
|
|
|
if (scope != PostScope.PRIVATE.getCode()) {
|
|
|
- ossService.setObjectScope(videoId, scope);
|
|
|
+ ossService.checkAndSetScope(videoId, scope);
|
|
|
}
|
|
|
|
|
|
ossService.deleteByObjectId(videoFileId);
|