ソースを参照

调整 VideoStatus 和 VideoErrorType 之间的关联

reghao 1 年間 前
コミット
c4c9a6b11c

+ 8 - 8
content/content-api/src/main/java/cn/reghao/tnb/content/api/constant/VideoErrorType.java

@@ -10,19 +10,19 @@ import java.util.Map;
  * @date 2024-11-07 21:49:19
  */
 public enum VideoErrorType {
-    censor(1, "视频无封面"),
-    publish(2, "视频无声音"),
-    censorFailed(3, "视频无画面"),
-    revoke(4, "视频无资源"),
-    cache(5, "视频有广告");
+    noCover(1, "视频无封面"),
+    noAudio(2, "视频无声音"),
+    noVideo(3, "视频无画面"),
+    noResource(4, "视频无资源"),
+    hasAd(5, "视频有广告");
 
     private final Integer code;
     private final String desc;
 
-    private static Map<Integer, String> descMap = new HashMap<>();
+    private static Map<Integer, VideoErrorType> descMap = new HashMap<>();
     static {
         for (VideoErrorType status : VideoErrorType.values()) {
-            descMap.put(status.code, status.desc);
+            descMap.put(status.code, status);
         }
     }
 
@@ -45,7 +45,7 @@ public enum VideoErrorType {
     }
 
     // TODO 第一次调用时会初始化 descMap
-    public static String getDescByCode(int code) {
+    public static VideoErrorType getDescByCode(int code) {
         return descMap.get(code);
     }
 }

+ 3 - 4
content/content-api/src/main/java/cn/reghao/tnb/content/api/constant/VideoStatus.java

@@ -15,10 +15,9 @@ public enum VideoStatus {
     publish(2, "审核通过"),
     censorFailed(3, "审核未通过"),
     revoke(4, "下架"),
-    cache(5, "待缓存"),
-    converted(6, "待转码"),
-    coverNotFound(8, "无封面"),
-    resourceNotFound(9, "无资源");
+    noVideoFile(5, "无视频资源"),
+    hasAd(6, "视频有广告"),
+    needRepair(7, "视频待修正");
 
     private final Integer code;
     private final String desc;

+ 1 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/model/dto/SearchCriteria.java

@@ -31,7 +31,7 @@ public class SearchCriteria {
         private Integer nextId;
 
         public Builder() {
-            this.status = List.of(VideoStatus.publish.getCode(), VideoStatus.cache.getCode());
+            this.status = List.of(VideoStatus.publish.getCode(), VideoStatus.noVideoFile.getCode());
             this.scope = List.of(PostScope.PUBLIC.getCode());
         }
 

+ 1 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/model/po/VideoPost.java

@@ -71,7 +71,7 @@ public class VideoPost extends BaseObject<Integer> {
         this.categoryPid = categoryPid;
         this.categoryId = categoryId;
         this.scope = PostScope.PUBLIC.getCode();
-        this.status = VideoStatus.cache.getCode();
+        this.status = VideoStatus.noVideoFile.getCode();
         this.horizontal = video.getHorizontal();
         this.duration = video.getDuration();
         this.coverUrl = video.getCoverUrl();

+ 1 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/model/query/VideoQuery.java

@@ -51,7 +51,7 @@ public class VideoQuery {
         private String order;
 
         public Builder() {
-            this.status = List.of(VideoStatus.publish.getCode(), VideoStatus.cache.getCode());
+            this.status = List.of(VideoStatus.publish.getCode(), VideoStatus.noVideoFile.getCode());
             //this.scope = List.of(PostScope.PUBLIC.getCode());
         }
 

+ 18 - 2
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/VideoService.java

@@ -38,9 +38,25 @@ public class VideoService {
 
         String videoId = videoErrorReport.getVideoId();
         int errCode = videoErrorReport.getErrorCode();
-        VideoErrorType.getDescByCode(errCode);
-        videoPostMapper.updateVideoStatus(videoId, errCode);
+        VideoErrorType errorType = VideoErrorType.getDescByCode(errCode);
+        int videoStatus;
+        switch (errorType) {
+            case noCover:
+            case noAudio:
+            case noVideo:
+                videoStatus = VideoStatus.needRepair.getValue();
+                break;
+            case noResource:
+                videoStatus = VideoStatus.revoke.getValue();
+                break;
+            case hasAd:
+                videoStatus = VideoStatus.hasAd.getValue();
+                break;
+            default:
+                return;
+        }
 
+        videoPostMapper.updateVideoStatus(videoId, videoStatus);
         VideoError videoError = new VideoError(videoErrorReport);
         videoErrorMapper.save(videoError);
     }