|
@@ -10,6 +10,7 @@ import cn.reghao.jutil.jdk.web.result.Result;
|
|
|
import cn.reghao.tnb.common.auth.UserContext;
|
|
import cn.reghao.tnb.common.auth.UserContext;
|
|
|
import cn.reghao.tnb.common.util.IdService;
|
|
import cn.reghao.tnb.common.util.IdService;
|
|
|
import cn.reghao.tnb.content.api.constant.PostScope;
|
|
import cn.reghao.tnb.content.api.constant.PostScope;
|
|
|
|
|
+import cn.reghao.tnb.content.api.constant.VideoStatus;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoFilePublish;
|
|
import cn.reghao.tnb.content.api.dto.VideoFilePublish;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoPublishSbt;
|
|
import cn.reghao.tnb.content.api.dto.VideoPublishSbt;
|
|
|
import cn.reghao.tnb.content.api.dto.VideoFileUpdate;
|
|
import cn.reghao.tnb.content.api.dto.VideoFileUpdate;
|
|
@@ -57,10 +58,6 @@ public class VideoPostService {
|
|
|
String title = videoFilePublish.getFilename();
|
|
String title = videoFilePublish.getFilename();
|
|
|
String videoFileId = videoFilePublish.getVideoFileId();
|
|
String videoFileId = videoFilePublish.getVideoFileId();
|
|
|
VideoMeta videoMeta = ossService.getVideoMeta(videoFileId);
|
|
VideoMeta videoMeta = ossService.getVideoMeta(videoFileId);
|
|
|
- if (!videoMeta.getFormatName().contains("mov,mp4")) {
|
|
|
|
|
- log.error("视频格式 {} 不支持 web 播放", videoMeta.getFormatName());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
String videoId = idGenerator.getUuid();
|
|
String videoId = idGenerator.getUuid();
|
|
|
VideoFile videoFile = new VideoFile(videoId, videoMeta);
|
|
VideoFile videoFile = new VideoFile(videoId, videoMeta);
|
|
|
VideoPost videoPost = new VideoPost(videoId, title, videoFile);
|
|
VideoPost videoPost = new VideoPost(videoId, title, videoFile);
|
|
@@ -71,14 +68,6 @@ public class VideoPostService {
|
|
|
public Result publishVideoPost(VideoPublishSbt videoPublishSbt) {
|
|
public Result publishVideoPost(VideoPublishSbt videoPublishSbt) {
|
|
|
Result result;
|
|
Result result;
|
|
|
try {
|
|
try {
|
|
|
- String coverFileId = videoPublishSbt.getCoverFileId();
|
|
|
|
|
- ObjectMeta objectMeta = ossService.getObjectMeta(coverFileId);
|
|
|
|
|
- if (objectMeta == null) {
|
|
|
|
|
- String errMsg = String.format("封面文件 %s 在 oss 中不存在", coverFileId);
|
|
|
|
|
- return Result.fail(errMsg);
|
|
|
|
|
- }
|
|
|
|
|
- String coverUrl = objectMeta.getUrl();
|
|
|
|
|
-
|
|
|
|
|
String videoId = videoPublishSbt.getVideoId();
|
|
String videoId = videoPublishSbt.getVideoId();
|
|
|
VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
|
if (videoPost == null) {
|
|
if (videoPost == null) {
|
|
@@ -97,16 +86,22 @@ public class VideoPostService {
|
|
|
int scope = videoPublishSbt.getScope();
|
|
int scope = videoPublishSbt.getScope();
|
|
|
ossService.checkAndSetScope(videoFileId, scope);
|
|
ossService.checkAndSetScope(videoFileId, scope);
|
|
|
|
|
|
|
|
|
|
+ VideoStatus videoStatus = VideoStatus.DRAFT;
|
|
|
|
|
+ String coverUrl = videoPost.getCoverUrl();
|
|
|
|
|
+ if (coverUrl != null && !coverUrl.isBlank()) {
|
|
|
|
|
+ videoStatus = VideoStatus.PENDING_REVIEW;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Long scheduledTime = videoPublishSbt.getScheduledTime();
|
|
Long scheduledTime = videoPublishSbt.getScheduledTime();
|
|
|
if (scheduledTime == null) {
|
|
if (scheduledTime == null) {
|
|
|
long publishAt = System.currentTimeMillis();
|
|
long publishAt = System.currentTimeMillis();
|
|
|
- videoPost.update(videoPublishSbt, coverUrl, publishAt);
|
|
|
|
|
|
|
+ videoPost.update(videoPublishSbt, publishAt, videoStatus);
|
|
|
} else {
|
|
} else {
|
|
|
/*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);
|
|
|
|
|
|
|
+ videoPost.update(videoPublishSbt, scheduledTime, videoStatus);
|
|
|
long jobId = jobService.addPublishVideoJob(videoId, videoPublishSbt.getScheduledTime());
|
|
long jobId = jobService.addPublishVideoJob(videoId, videoPublishSbt.getScheduledTime());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -163,9 +158,16 @@ public class VideoPostService {
|
|
|
String videoId = videoCoverUpdate.getVideoId();
|
|
String videoId = videoCoverUpdate.getVideoId();
|
|
|
VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
|
if (videoPost == null) {
|
|
if (videoPost == null) {
|
|
|
|
|
+ log.error("VideoPost with videoId {} not exist", videoId);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ VideoStatus videoStatus = VideoStatus.getByCode(videoPost.getStatus());
|
|
|
|
|
+ int categoryPid = videoPost.getCategoryPid();
|
|
|
|
|
+ if (categoryPid != 0) {
|
|
|
|
|
+ videoStatus = VideoStatus.PENDING_REVIEW;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
String coverFileId = videoCoverUpdate.getCoverFileId();
|
|
String coverFileId = videoCoverUpdate.getCoverFileId();
|
|
|
try {
|
|
try {
|
|
|
ObjectMeta objectMeta = ossService.getObjectMeta(coverFileId);
|
|
ObjectMeta objectMeta = ossService.getObjectMeta(coverFileId);
|
|
@@ -176,7 +178,7 @@ public class VideoPostService {
|
|
|
|
|
|
|
|
String currentCover = videoPost.getCoverUrl();
|
|
String currentCover = videoPost.getCoverUrl();
|
|
|
String coverUrl = objectMeta.getUrl();
|
|
String coverUrl = objectMeta.getUrl();
|
|
|
- videoRepository.updateVideoCover(videoId, coverUrl);
|
|
|
|
|
|
|
+ videoRepository.updateVideoCover(videoId, videoStatus, coverUrl);
|
|
|
if (currentCover != null && !currentCover.isBlank()) {
|
|
if (currentCover != null && !currentCover.isBlank()) {
|
|
|
ossService.deleteByObjectUrl(currentCover);
|
|
ossService.deleteByObjectUrl(currentCover);
|
|
|
}
|
|
}
|