|
|
@@ -1,12 +1,15 @@
|
|
|
package cn.reghao.tnb.content.app.vod.service.impl;
|
|
|
|
|
|
+import cn.reghao.file.api.iface.FileService;
|
|
|
import cn.reghao.file.api.iface.OssService;
|
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
|
+import cn.reghao.jutil.jdk.result.ResultStatus;
|
|
|
import cn.reghao.jutil.tool.id.IdGenerator;
|
|
|
import cn.reghao.oss.sdk.model.dto.media.ImageInfo;
|
|
|
import cn.reghao.oss.sdk.model.dto.media.VideoInfo;
|
|
|
import cn.reghao.tnb.common.auth.UserContext;
|
|
|
import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
+import cn.reghao.tnb.content.api.constant.VideoStatus;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoFileUpdate;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoPublishSbt;
|
|
|
import cn.reghao.tnb.content.app.vod.db.mapper.*;
|
|
|
@@ -33,6 +36,8 @@ import java.util.*;
|
|
|
public class VideoPostServiceImpl implements VideoPostService {
|
|
|
@DubboReference(check = false)
|
|
|
private OssService ossService;
|
|
|
+ @DubboReference(check = false)
|
|
|
+ private FileService fileService;
|
|
|
|
|
|
private int pageSize = 12;
|
|
|
private final VideoPostMapper videoPostMapper;
|
|
|
@@ -66,8 +71,8 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
|
|
|
String coverUrl = imageInfo.getUrl();
|
|
|
String videoFileId = videoPublishSbt.getVideoFileId();
|
|
|
- int channelId = videoPublishSbt.getChannelCode();
|
|
|
- VideoInfo videoInfo = ossService.getVideoInfo(channelId, videoFileId);
|
|
|
+ int channelCode = videoPublishSbt.getChannelCode();
|
|
|
+ VideoInfo videoInfo = ossService.getVideoInfo(channelCode, videoFileId);
|
|
|
if (videoInfo == null) {
|
|
|
String errMsg = String.format("视频文件 %s 在 oss 中不存在", videoFileId);
|
|
|
return Result.fail(errMsg);
|
|
|
@@ -81,21 +86,31 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
}
|
|
|
String codec = String.format("%s&%s", videoCodec, audioCodec);
|
|
|
|
|
|
- Integer channelScope = ossService.getChannelScope(channelId);
|
|
|
+ Integer channelScope = ossService.getChannelScope(channelCode);
|
|
|
if (channelScope == null ) {
|
|
|
- String errMsg = String.format("channelId %s 的 scope 在 oss 中不存在", channelId);
|
|
|
+ String errMsg = String.format("channelCode %s 的 scope 在 oss 中不存在", channelCode);
|
|
|
return Result.fail(errMsg);
|
|
|
}
|
|
|
|
|
|
int scope = videoPublishSbt.getScope();
|
|
|
if (channelScope != scope) {
|
|
|
- ossService.setObjectScope(channelId, videoFileId, scope);
|
|
|
+ ossService.setObjectScope(channelCode, videoFileId, scope);
|
|
|
}
|
|
|
|
|
|
String videoId = idGenerator.getUuid();
|
|
|
Set<String> tags = videoPublishSbt.getTags();
|
|
|
String tags1 = tags.toString().replace("[", "").replace("]", "");
|
|
|
VideoPost videoPost = new VideoPost(videoId, videoPublishSbt, coverUrl, videoFile, codec);
|
|
|
+
|
|
|
+ if (!videoInfo.getFormatName().contains("mov,mp4")) {
|
|
|
+ Result result1 = fileService.convertVideo(videoFileId, channelCode);
|
|
|
+ if (result1.getCode() == ResultStatus.SUCCESS.getCode()) {
|
|
|
+ videoPost.setStatus(VideoStatus.converted.getValue());
|
|
|
+ } else {
|
|
|
+ log.error(result1.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
saveVideo(videoFile, videoPost, tags1);
|
|
|
result = Result.success();
|
|
|
} catch (Exception e) {
|