|
|
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -105,7 +106,6 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
VideoFile videoFile = videoFileList.get(0);
|
|
|
String videoFileId = videoFile.getObjectId();
|
|
|
|
|
|
- int channelCode = videoFile.getChannelCode();
|
|
|
int scope = videoPublishSbt.getScope();
|
|
|
ossService.checkAndSetScope(videoFileId, scope);
|
|
|
|
|
|
@@ -156,19 +156,17 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
String videoId = videoScopeUpdate.getVideoId();
|
|
|
VideoPost videoPost = videoRepository.getVideoPost(videoId);
|
|
|
if (videoPost == null) {
|
|
|
+ log.error("{} not exist video post", videoId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<VideoUrlDto> list = videoRepository.getVideoUrls(videoId);
|
|
|
- for (VideoUrlDto videoUrlDto : list) {
|
|
|
- String videoFileId = videoUrlDto.getObjectId();
|
|
|
- try {
|
|
|
- int scope = videoScopeUpdate.getScope();
|
|
|
- ossService.checkAndSetScope(videoFileId, scope);
|
|
|
- videoPostMapper.updateVideoScope(videoScopeUpdate);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("{}", e.getMessage());
|
|
|
- }
|
|
|
+ List<String> objectIds = videoRepository.getVideoFiles(videoId).stream()
|
|
|
+ .map(VideoFile::getObjectId)
|
|
|
+ .toList();
|
|
|
+ for (String objectId : objectIds) {
|
|
|
+ int scope = videoScopeUpdate.getScope();
|
|
|
+ ossService.checkAndSetScope(objectId, scope);
|
|
|
+ videoPostMapper.updateVideoScope(videoScopeUpdate);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -220,27 +218,30 @@ public class VideoPostServiceImpl implements VideoPostService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<VideoUrlDto> list = videoRepository.getVideoUrls(videoId);
|
|
|
- for (VideoUrlDto videoUrlDto : list) {
|
|
|
- String videoFileId = videoFileUpdate.getVideoFileId();
|
|
|
- try {
|
|
|
- int channelCode = 101;
|
|
|
- VideoMeta videoMeta = ossService.getVideoMeta(videoFileId);
|
|
|
- if (videoMeta == null) {
|
|
|
- log.error("{} not exist", videoFileId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- videoPostMapper.updateVideoFile(videoId, videoMeta);
|
|
|
- int scope = videoPost.getScope();
|
|
|
- if (scope != PostScope.PRIVATE.getCode()) {
|
|
|
- ossService.checkAndSetScope(videoId, scope);
|
|
|
- }
|
|
|
+ String videoFileId = videoFileUpdate.getVideoFileId();
|
|
|
+ try {
|
|
|
+ VideoMeta videoMeta = ossService.getVideoMeta(videoFileId);
|
|
|
+ if (videoMeta == null) {
|
|
|
+ log.error("{} not exist", videoFileId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- ossService.deleteByObjectId(videoFileId);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("{}", e.getMessage());;
|
|
|
+ int channelCode = 101;
|
|
|
+ VideoFile videoFile = new VideoFile(videoId, videoMeta, channelCode);
|
|
|
+ videoRepository.saveVideoFile(videoFile);
|
|
|
+ int scope = videoPost.getScope();
|
|
|
+ if (scope != PostScope.PRIVATE.getCode()) {
|
|
|
+ ossService.checkAndSetScope(videoId, scope);
|
|
|
}
|
|
|
+
|
|
|
+ String objectId = videoFile.getObjectId();
|
|
|
+ List<String> objectIds = videoRepository.getVideoFiles(videoId).stream()
|
|
|
+ .filter(videoFile1 -> !videoFile1.getObjectId().equals(objectId))
|
|
|
+ .map(VideoFile::getObjectId)
|
|
|
+ .toList();
|
|
|
+ //ossService.deleteByObjectId(videoFileId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("{}", e.getMessage());;
|
|
|
}
|
|
|
}
|
|
|
|