Prechádzať zdrojové kódy

更新 VideoFile 和 VideoUrl 字段

reghao 2 rokov pred
rodič
commit
c1f93ef4a6

+ 2 - 4
dfs-store/src/main/java/cn/reghao/dfs/store/model/po/VideoFile.java

@@ -16,7 +16,7 @@ import lombok.Setter;
 @Setter
 @Getter
 public class VideoFile extends BaseObject<Integer> {
-    private String videoId;
+    private String videoFileId;
     private String objectName;
     private Boolean horizontal;
     // 单位秒
@@ -24,8 +24,6 @@ public class VideoFile extends BaseObject<Integer> {
     private Boolean activate;
     private Boolean auth;
     @Deprecated
-    private String videoFileId;
-    @Deprecated
     private String coverUrl;
 
     public VideoFile(String videoFileId) {
@@ -35,7 +33,7 @@ public class VideoFile extends BaseObject<Integer> {
     }
 
     public VideoFile(VideoInfo videoInfo) {
-        this.videoId = videoInfo.getVideoId();
+        this.videoFileId = videoInfo.getVideoId();
         this.objectName = videoInfo.getVideoObjectName();
         this.horizontal = videoInfo.getHorizontal();
         this.duration = videoInfo.getDuration();

+ 3 - 7
dfs-store/src/main/java/cn/reghao/dfs/store/model/po/VideoUrl.java

@@ -14,20 +14,16 @@ import lombok.NoArgsConstructor;
 @NoArgsConstructor
 @Getter
 public class VideoUrl extends BaseObject<Integer> {
-    private String videoId;
+    private String videoFileId;
     private String objectName;
     private String urlType;
     private String url;
     private String quality;
     private Integer width;
     private Integer height;
-    @Deprecated
-    private String videoFileId;
-    @Deprecated
-    private String videoUrlId;
 
-    public VideoUrl(String videoId, String objectName, String urlType, String url, MediaResolution mediaResolution) {
-        this.videoId = videoId;
+    public VideoUrl(String videoFileId, String objectName, String urlType, String url, MediaResolution mediaResolution) {
+        this.videoFileId = videoFileId;
         this.objectName = objectName;
         this.urlType = urlType;
         this.url = url;

+ 5 - 5
dfs-store/src/main/java/cn/reghao/dfs/store/task/ConvertTask.java

@@ -17,13 +17,13 @@ import java.util.UUID;
  * @date 2023-05-11 09:46:28
  */
 public class ConvertTask implements Runnable {
-    private final String videoId;
+    private final String videoFileId;
     private final String absolutePath;
     private final String endpoint;
     private final VideoUrlMapper videoUrlMapper;
 
-    public ConvertTask(String videoId, String absolutePath, String endpoint, VideoUrlMapper videoUrlMapper) {
-        this.videoId = videoId;
+    public ConvertTask(String videoFileId, String absolutePath, String endpoint, VideoUrlMapper videoUrlMapper) {
+        this.videoFileId = videoFileId;
         this.absolutePath = absolutePath;
         this.endpoint = endpoint;
         this.videoUrlMapper = videoUrlMapper;
@@ -34,7 +34,7 @@ public class ConvertTask implements Runnable {
         String filename = String.format("%s.mp4", UUID.randomUUID().toString().replace("-", ""));
         String destPath = String.format("/opt/tmp/tomcat/%s", filename);
         FFmpegWrapper.formatCovert(absolutePath, destPath);
-        String objectName = String.format("video/playback/%s/%s", videoId, filename);
+        String objectName = String.format("video/playback/%s/%s", videoFileId, filename);
         try {
             String url = String.format("%s/%s", endpoint, objectName);
             File destFile = new File(destPath);
@@ -46,7 +46,7 @@ public class ConvertTask implements Runnable {
             int height = (int) videoProps.getCodedHeight();
 
             MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
-            VideoUrl videoUrl = new VideoUrl(videoId, objectName, VideoUrlType.mp4.name(), url, mediaResolution);
+            VideoUrl videoUrl = new VideoUrl(videoFileId, objectName, VideoUrlType.mp4.name(), url, mediaResolution);
             videoUrlMapper.save(videoUrl);
             destFile.delete();
         } catch (Exception e) {

+ 4 - 4
dfs-store/src/main/java/cn/reghao/dfs/store/task/VideoFileProcessor.java

@@ -37,7 +37,7 @@ public class VideoFileProcessor {
     }
 
     public void setVideoInfo(VideoInfo videoInfo) {
-        String videoId = videoInfo.getVideoId();
+        String videoFileId = videoInfo.getVideoId();
         String videoObjectName = videoInfo.getVideoObjectName();
         int width = videoInfo.getWidth();
         int height = videoInfo.getHeight();
@@ -53,14 +53,14 @@ public class VideoFileProcessor {
                 String videoCodec = mediaProps.getVideoProps().getCodecName();
                 if ("aac".equals(audioCodec) && "h264".equals(videoCodec)) {
                     MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
-                    VideoUrl videoUrl = new VideoUrl(videoId, videoObjectName, VideoUrlType.mp4.name(), url, mediaResolution);
+                    VideoUrl videoUrl = new VideoUrl(videoFileId, videoObjectName, VideoUrlType.mp4.name(), url, mediaResolution);
                     videoUrlMapper.save(videoUrl);
                 } else {
-                    ConvertTask convertTask = new ConvertTask(videoId, destPath, endpoint, videoUrlMapper);
+                    ConvertTask convertTask = new ConvertTask(videoFileId, destPath, endpoint, videoUrlMapper);
                     threadPool.submit(convertTask);
                 }
             } else {
-                ConvertTask convertTask = new ConvertTask(videoId, destPath, endpoint, videoUrlMapper);
+                ConvertTask convertTask = new ConvertTask(videoFileId, destPath, endpoint, videoUrlMapper);
                 threadPool.submit(convertTask);
             }
         } catch (Exception e) {

+ 2 - 2
dfs-store/src/main/resources/mapper/VideoFileMapper.xml

@@ -4,9 +4,9 @@
 <mapper namespace="cn.reghao.dfs.store.db.mapper.VideoFileMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into video_file
-        (`id`,`deleted`,`create_time`,`update_time`,`video_id`,`object_name`,`horizontal`,`duration`,`activate`,`auth`)
+        (`id`,`deleted`,`create_time`,`update_time`,`video_file_id`,`object_name`,`horizontal`,`duration`,`activate`,`auth`)
         values 
-        (#{id},#{deleted},#{createTime},#{updateTime},#{videoId},#{objectName},#{horizontal},#{duration},#{activate},#{auth})
+        (#{id},#{deleted},#{createTime},#{updateTime},#{videoFileId},#{objectName},#{horizontal},#{duration},#{activate},#{auth})
     </insert>
 
     <select id="findAll" resultType="cn.reghao.dfs.store.model.po.VideoFile">

+ 2 - 2
dfs-store/src/main/resources/mapper/VideoUrlMapper.xml

@@ -4,9 +4,9 @@
 <mapper namespace="cn.reghao.dfs.store.db.mapper.VideoUrlMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into video_url
-        (`video_id`,`object_name`,`url_type`,`width`,`height`,`quality`,`url`)
+        (`video_file_id`,`object_name`,`url_type`,`width`,`height`,`quality`,`url`)
         values
-        (#{videoId},#{objectName},#{urlType},#{width},#{height},#{quality},#{url})
+        (#{videoFileId},#{objectName},#{urlType},#{width},#{height},#{quality},#{url})
     </insert>
 
     <select id="findVideoUrls" resultType="cn.reghao.dfs.api.dto.VideoUrlDto">