|
@@ -64,27 +64,37 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
this.videoCategoryPostMapper = videoCategoryPostMapper;
|
|
this.videoCategoryPostMapper = videoCategoryPostMapper;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String publishVideoFile(VideoFilePublish videoFilePublish) {
|
|
|
|
|
|
|
+ public Result publishVideoFile(VideoFilePublish videoFilePublish) {
|
|
|
String title = videoFilePublish.getFilename();
|
|
String title = videoFilePublish.getFilename();
|
|
|
String videoFileId = videoFilePublish.getVideoFileId();
|
|
String videoFileId = videoFilePublish.getVideoFileId();
|
|
|
int channelCode = videoFilePublish.getChannelCode();
|
|
int channelCode = videoFilePublish.getChannelCode();
|
|
|
|
|
+ Result result;
|
|
|
try {
|
|
try {
|
|
|
VideoInfo videoInfo = ossService.getVideoInfo(channelCode, videoFileId);
|
|
VideoInfo videoInfo = ossService.getVideoInfo(channelCode, videoFileId);
|
|
|
|
|
+ if (!videoInfo.getFormatName().contains("mov,mp4")) {
|
|
|
|
|
+ long jobId = jobService.addConvertVideoJob(videoFileId, channelCode);
|
|
|
|
|
+ /*Result result1 = fileService.convertVideo(videoFileId, channelCode);
|
|
|
|
|
+ if (result1.getCode() == ResultStatus.SUCCESS.getCode()) {
|
|
|
|
|
+ videoPost.setStatus(VideoStatus.converted.getCode());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error(result1.getMsg());
|
|
|
|
|
+ }*/
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String videoId = idGenerator.getUuid();
|
|
String videoId = idGenerator.getUuid();
|
|
|
VideoFile videoFile = new VideoFile(videoId, videoInfo, channelCode);
|
|
VideoFile videoFile = new VideoFile(videoId, videoInfo, channelCode);
|
|
|
VideoPost videoPost = new VideoPost(videoId, title, videoFile);
|
|
VideoPost videoPost = new VideoPost(videoId, title, videoFile);
|
|
|
videoRepository.saveVideo(videoFile, videoPost);
|
|
videoRepository.saveVideo(videoFile, videoPost);
|
|
|
- return videoId;
|
|
|
|
|
|
|
+ result = Result.success(videoId);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
String errMsg = String.format("视频文件 %s 在 oss 中不存在", videoFileId);
|
|
String errMsg = String.format("视频文件 %s 在 oss 中不存在", videoFileId);
|
|
|
- log.error("{}", e.getMessage());
|
|
|
|
|
|
|
+ result = Result.fail(errMsg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Result publishVideo(VideoPublishSbt videoPublishSbt) {
|
|
|
|
|
|
|
+ public Result publishVideoPost(VideoPublishSbt videoPublishSbt) {
|
|
|
Result result;
|
|
Result result;
|
|
|
try {
|
|
try {
|
|
|
int coverChannelId = videoPublishSbt.getCoverChannelId();
|
|
int coverChannelId = videoPublishSbt.getCoverChannelId();
|
|
@@ -94,19 +104,24 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
String errMsg = String.format("封面文件 %s 在 oss 中不存在", coverFileId);
|
|
String errMsg = String.format("封面文件 %s 在 oss 中不存在", coverFileId);
|
|
|
return Result.fail(errMsg);
|
|
return Result.fail(errMsg);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
String coverUrl = imageInfo.getUrl();
|
|
String coverUrl = imageInfo.getUrl();
|
|
|
- String videoFileId = videoPublishSbt.getVideoFileId();
|
|
|
|
|
- int channelCode = videoPublishSbt.getChannelCode();
|
|
|
|
|
- VideoInfo videoInfo = ossService.getVideoInfo(channelCode, videoFileId);
|
|
|
|
|
- if (videoInfo == null) {
|
|
|
|
|
- String errMsg = String.format("视频文件 %s 在 oss 中不存在", videoFileId);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String videoId = videoPublishSbt.getVideoId();
|
|
|
|
|
+ VideoPost videoPost = videoPostMapper.findByVideoId(videoId);
|
|
|
|
|
+ if (videoPost == null) {
|
|
|
|
|
+ String errMsg = String.format("VideoId %s 不存在", videoId);
|
|
|
return Result.fail(errMsg);
|
|
return Result.fail(errMsg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String videoId = idGenerator.getUuid();
|
|
|
|
|
- VideoFile videoFile = new VideoFile(videoId, videoInfo, channelCode);
|
|
|
|
|
|
|
+ List<VideoFile> videoFileList = videoFileMapper.findByVideoId(videoId);
|
|
|
|
|
+ if (videoFileList.isEmpty()) {
|
|
|
|
|
+ String errMsg = String.format("VideoId %s 关联的视频文件不存在", videoId);
|
|
|
|
|
+ return Result.fail(errMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+ VideoFile videoFile = videoFileList.get(0);
|
|
|
|
|
+ String videoFileId = videoFile.getObjectId();
|
|
|
|
|
|
|
|
|
|
+ int channelCode = videoFile.getChannelCode();
|
|
|
Integer channelScope = ossService.getChannelScope(channelCode);
|
|
Integer channelScope = ossService.getChannelScope(channelCode);
|
|
|
if (channelScope == null ) {
|
|
if (channelScope == null ) {
|
|
|
String errMsg = String.format("channelCode %s 的 scope 在 oss 中不存在", channelCode);
|
|
String errMsg = String.format("channelCode %s 的 scope 在 oss 中不存在", channelCode);
|
|
@@ -121,34 +136,20 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
Set<String> tags = videoPublishSbt.getTags();
|
|
Set<String> tags = videoPublishSbt.getTags();
|
|
|
String tags1 = tags.toString().replace("[", "").replace("]", "");
|
|
String tags1 = tags.toString().replace("[", "").replace("]", "");
|
|
|
|
|
|
|
|
- VideoPost videoPost;
|
|
|
|
|
- Long publishAt = videoPublishSbt.getScheduledTime();
|
|
|
|
|
- if (publishAt == null) {
|
|
|
|
|
- int postStatus = VideoStatus.publish.getValue();
|
|
|
|
|
- long publishAt1 = System.currentTimeMillis();
|
|
|
|
|
- videoPost = new VideoPost(videoId, videoPublishSbt, coverUrl, videoFile, postStatus, publishAt1);
|
|
|
|
|
|
|
+ Long scheduledTime = videoPublishSbt.getScheduledTime();
|
|
|
|
|
+ if (scheduledTime == null) {
|
|
|
|
|
+ long publishAt = System.currentTimeMillis();
|
|
|
|
|
+ videoPost.update(videoPublishSbt, coverUrl, publishAt);
|
|
|
} else {
|
|
} else {
|
|
|
- int postStatus = VideoStatus.censor.getValue();
|
|
|
|
|
- videoPost = new VideoPost(videoId, videoPublishSbt, coverUrl, videoFile, postStatus, publishAt);
|
|
|
|
|
-
|
|
|
|
|
/*long duration = publishAt-System.currentTimeMillis();
|
|
/*long duration = publishAt-System.currentTimeMillis();
|
|
|
if (duration < 600_000) {
|
|
if (duration < 600_000) {
|
|
|
return Result.fail("定时发布的时间至少应在 10 分钟后");
|
|
return Result.fail("定时发布的时间至少应在 10 分钟后");
|
|
|
}*/
|
|
}*/
|
|
|
|
|
+ videoPost.update(videoPublishSbt, coverUrl, scheduledTime);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!videoInfo.getFormatName().contains("mov,mp4")) {
|
|
|
|
|
- long jobId = jobService.addConvertVideoJob(videoFileId, channelCode);
|
|
|
|
|
- /*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);
|
|
|
|
|
- if (publishAt != null) {
|
|
|
|
|
|
|
+ saveVideo(videoPost, tags1);
|
|
|
|
|
+ if (scheduledTime != null) {
|
|
|
long jobId = jobService.addPublishVideoJob(videoId, videoPublishSbt.getScheduledTime());
|
|
long jobId = jobService.addPublishVideoJob(videoId, videoPublishSbt.getScheduledTime());
|
|
|
}
|
|
}
|
|
|
result = Result.success();
|
|
result = Result.success();
|
|
@@ -159,11 +160,11 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void saveVideo(VideoFile videoFile, VideoPost videoPost, String tags) {
|
|
|
|
|
|
|
+ public void saveVideo(VideoPost videoPost, String tags) {
|
|
|
String videoId = videoPost.getVideoId();
|
|
String videoId = videoPost.getVideoId();
|
|
|
VideoStatistic videoStatistic = new VideoStatistic(videoId);
|
|
VideoStatistic videoStatistic = new VideoStatistic(videoId);
|
|
|
setVideoCategoryPost(videoPost);
|
|
setVideoCategoryPost(videoPost);
|
|
|
- videoRepository.savePostVideo(videoFile, videoPost, videoStatistic);
|
|
|
|
|
|
|
+ videoRepository.savePostVideo(videoPost, videoStatistic);
|
|
|
setVideoTags(videoId, videoPost.getScope(), tags);
|
|
setVideoTags(videoId, videoPost.getScope(), tags);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -232,15 +233,6 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void updateVideoStatus(VideoScopeUpdate videoScopeUpdate) {
|
|
|
|
|
- VideoPost videoPost = videoPostMapper.findByVideoId(videoScopeUpdate.getVideoId());
|
|
|
|
|
- if (videoPost == null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- videoPostMapper.updateVideoScope(videoScopeUpdate);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public void updateVideoScope(VideoScopeUpdate videoScopeUpdate) {
|
|
public void updateVideoScope(VideoScopeUpdate videoScopeUpdate) {
|
|
|
String videoId = videoScopeUpdate.getVideoId();
|
|
String videoId = videoScopeUpdate.getVideoId();
|
|
|
VideoPost videoPost = videoPostMapper.findByVideoId(videoId);
|
|
VideoPost videoPost = videoPostMapper.findByVideoId(videoId);
|