Sfoglia il codice sorgente

修改视频文件的访问权限设置

reghao 3 anni fa
parent
commit
4e339a743c

+ 43 - 135
src/main/java/cn/reghao/dfs/store/controller/VideoFileController.java

@@ -1,19 +1,14 @@
 package cn.reghao.dfs.store.controller;
 
 import cn.reghao.dfs.store.config.DfsProperties;
-import cn.reghao.dfs.store.db.mapper.FileUserMapper;
-import cn.reghao.dfs.store.model.dto.PathUrl;
-import cn.reghao.dfs.api.dto.FileAccess;
-import cn.reghao.dfs.store.service.FileUrlService;
+import cn.reghao.dfs.store.db.mapper.VideoFileMapper;
+import cn.reghao.dfs.store.model.vo.VideoFileInfo;
 import cn.reghao.jutil.jdk.security.crypto.AesEncrypt;
 import cn.reghao.jutil.web.ServletUtil;
 import io.swagger.annotations.Api;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
@@ -26,15 +21,16 @@ import java.util.Arrays;
 @RestController
 @RequestMapping("/video")
 public class VideoFileController {
-    private final FileUrlService fileUrlService;
-    private final FileUserMapper fileUserMapper;
+    private final VideoFileMapper videoFileMapper;
     private final String encryptKey;
+    private final int group;
+    private final int node;
 
-    public VideoFileController(FileUrlService fileUrlService, FileUserMapper fileUserMapper,
-                               DfsProperties dfsProperties) {
-        this.fileUrlService = fileUrlService;
-        this.fileUserMapper = fileUserMapper;
+    public VideoFileController(VideoFileMapper videoFileMapper, DfsProperties dfsProperties) {
+        this.videoFileMapper = videoFileMapper;
         this.encryptKey = dfsProperties.getEncryptKey();
+        this.group = dfsProperties.getGroup();
+        this.node = dfsProperties.getNode();
     }
 
     @GetMapping("/playback/{filename}")
@@ -43,56 +39,52 @@ public class VideoFileController {
                             @RequestParam(value = "sign", required = false) String sign,
                             HttpServletResponse response) throws Exception {
         String uploadId = filename.split("\\.")[0];
-        FileAccess fileAccess = fileUserMapper.findFileAccessByUploadId(uploadId);
-        if (fileAccess == null) {
+        VideoFileInfo videoFileInfo = videoFileMapper.findVideoFileInfoByUploadId(uploadId, group, node);
+        if (videoFileInfo == null) {
             response.setStatus(HttpServletResponse.SC_NOT_FOUND);
             response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
             return;
         }
 
-        if (!fileAccess.isActivate()) {
-            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
-            response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
-            return;
-        }
-
-        if (fileAccess.isAuth()) {
-            if (sign == null) {
-                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+        long accessUserId = Long.parseLong(ServletUtil.getUserId());
+        long uploadBy = Long.parseLong(videoFileInfo.getUploadBy());
+        if (accessUserId != -1) {
+            if (!videoFileInfo.isActivate()) {
+                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
                 response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
                 return;
             }
 
-            String decryptSign = AesEncrypt.decrypt(sign, encryptKey);
-            String[] arr = decryptSign.split("_");
-            String key = arr[0];
-            long userId = Long.parseLong(arr[1]);
-            long timestamp = Long.parseLong(arr[2]);
-
-            long accessUserId = Long.parseLong(ServletUtil.getUserId());
-            if (userId != accessUserId) {
-                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
-                String errMsg = "url 不是为当前用户生成";
-                response.getOutputStream().write(errMsg.getBytes(StandardCharsets.UTF_8));
-                return;
-            }
-
-            if (timestamp < System.currentTimeMillis()) {
-                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
-                String errMsg = "url 过期";
-                response.getOutputStream().write(errMsg.getBytes(StandardCharsets.UTF_8));
-                return;
+            if (videoFileInfo.isAuth()) {
+                if (sign == null) {
+                    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+                    response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
+                    return;
+                }
+
+                String decryptSign = AesEncrypt.decrypt(sign, encryptKey);
+                String[] arr = decryptSign.split("_");
+                String key = arr[0];
+                long userId = Long.parseLong(arr[1]);
+                long timestamp = Long.parseLong(arr[2]);
+
+                if (userId != accessUserId) {
+                    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+                    String errMsg = "url 不是为当前用户生成";
+                    response.getOutputStream().write(errMsg.getBytes(StandardCharsets.UTF_8));
+                    return;
+                }
+
+                if (timestamp < System.currentTimeMillis()) {
+                    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+                    String errMsg = "url 过期";
+                    response.getOutputStream().write(errMsg.getBytes(StandardCharsets.UTF_8));
+                    return;
+                }
             }
         }
 
-        PathUrl pathUrl = fileUrlService.getPathUrl(uploadId);
-        if (pathUrl == null) {
-            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
-            response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
-            return;
-        }
-
-        String absolutePath = pathUrl.getAbsolutePath();
+        String absolutePath = videoFileInfo.getAbsolutePath();
         RandomAccessFile raf = new RandomAccessFile(absolutePath, "r");
         long fileLength = raf.length();
         long partLength = 1024*1024*2;
@@ -121,88 +113,4 @@ public class VideoFileController {
         response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
         response.getOutputStream().write(Arrays.copyOf(bytes, readBytes));
     }
-
-    @GetMapping("/hls/{uploadId}/{filename:.+}")
-    public void hlsVideoPlayer(@PathVariable("uploadId") String uploadId,
-                               @PathVariable("filename") String filename,
-                               HttpServletResponse response) throws IOException {
-        if (filename.contains("m3u8")) {
-            String localFilePath = "/opt/file/disk/spider/twitter/vid/hls/0/" + filename;
-            FileInputStream fis = new FileInputStream(localFilePath);
-            response.setStatus(HttpServletResponse.SC_OK);
-            response.setContentType("application/x-mpegURL");
-            response.getOutputStream().write(fis.readAllBytes());
-            return;
-        }
-
-        PathUrl pathUrl = fileUrlService.getPathUrl(uploadId);
-        if (pathUrl == null) {
-            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
-            response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
-            return;
-        }
-
-        String absolutePath = pathUrl.getAbsolutePath();
-        File file = new File(absolutePath);
-        long len = file.length();
-        FileInputStream fis = new FileInputStream(absolutePath);
-        response.setContentType("video/mp4");
-        response.setHeader("Content-Length", ""+len);
-        response.setStatus(HttpServletResponse.SC_OK);
-        response.getOutputStream().write(fis.readAllBytes());
-    }
-
-    @GetMapping("/dash/{uploadId}/{filename:.+}")
-    public void dashVideoPlayer(@PathVariable("uploadId") String uploadId,
-                                @PathVariable("filename") String filename,
-                                @RequestHeader(required = false) String range,
-                                HttpServletResponse response) throws IOException {
-        if (filename.contains("mpd")) {
-            PathUrl pathUrl = fileUrlService.getPathUrl(uploadId);
-            if (pathUrl == null) {
-                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
-                response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
-                return;
-            }
-
-            String absolutePath = pathUrl.getAbsolutePath();
-            FileInputStream fis = new FileInputStream(absolutePath);
-            response.setStatus(HttpServletResponse.SC_OK);
-            response.setContentType("application/dash+xml; charset=utf-8");
-            response.getOutputStream().write(fis.readAllBytes());
-            return;
-        }
-
-        PathUrl pathUrl = fileUrlService.getPathUrl(uploadId);
-        if (pathUrl == null) {
-            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
-            response.getOutputStream().write("".getBytes(StandardCharsets.UTF_8));
-            return;
-        }
-
-        String absolutePath = pathUrl.getAbsolutePath();
-        String parentDir = new File(absolutePath).getParent();
-        String localFilePath1 = parentDir + File.separator + filename;
-        RandomAccessFile raf = new RandomAccessFile(localFilePath1, "r");
-        long fileLength = raf.length();
-
-        String[] ranges = range.replace("bytes=", "").split(",");
-        String[] firstRange = ranges[0].split("-");
-        long start = Long.parseLong(firstRange[0]);
-        long end = Long.parseLong(firstRange[1]);
-        long expectRead = end-start+1;
-        byte[] bytes = new byte[(int) (expectRead)];
-
-        raf.seek(start);
-        int actualRead = raf.read(bytes);
-        //long end1 = start + actualRead-1;
-        long end1 = Math.min(start+end-1, start+actualRead-1);
-
-        response.setContentType("video/mp4");
-        response.setHeader("Content-Length", ""+actualRead);
-        response.setHeader("Content-Range", "bytes "+start+"-"+end1+"/"+fileLength);
-        response.setHeader("Accept-Ranges", "bytes");
-        response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
-        response.getOutputStream().write(Arrays.copyOf(bytes, actualRead));
-    }
 }

+ 1 - 1
src/main/java/cn/reghao/dfs/store/controller/VideoUploadController.java

@@ -72,7 +72,7 @@ public class VideoUploadController {
         }
 
         PathUrl pathUrl = filePartRet.getPathUrl();
-        VideoFile videoFile = videoService.process(filePartRet.getFileId(), pathUrl);
+        VideoFile videoFile = videoService.process(uploadId, filePartRet.getFileId(), pathUrl);
         return WebBody.success(new VideoFileRet(uploadId, videoFile));
     }
 

+ 0 - 6
src/main/java/cn/reghao/dfs/store/db/mapper/FileUserMapper.java

@@ -1,6 +1,5 @@
 package cn.reghao.dfs.store.db.mapper;
 
-import cn.reghao.dfs.api.dto.FileAccess;
 import cn.reghao.jutil.jdk.db.BaseMapper;
 import cn.reghao.dfs.store.model.po.FileInfo;
 import cn.reghao.dfs.store.model.po.FileUser;
@@ -13,11 +12,6 @@ import org.apache.ibatis.annotations.Param;
  */
 @Mapper
 public interface FileUserMapper extends BaseMapper<FileUser> {
-    void updateSetFileAccess(FileAccess fileAccess);
-    void updateSetNeedAuth(String uploadId);
-    void updateSetNotNeedAuth(String uploadId);
-
-    FileAccess findFileAccessByUploadId(String uploadId);
     FileUser findByFileAndUserId(@Param("fileId") String fileId, @Param("userId") String userId);
     FileUser findByUploadAndUserId(@Param("uploadId") String uploadId, @Param("userId") String userId);
     FileInfo findFileInfoByUploadId(String uploadId);

+ 6 - 0
src/main/java/cn/reghao/dfs/store/db/mapper/VideoFileMapper.java

@@ -1,5 +1,6 @@
 package cn.reghao.dfs.store.db.mapper;
 
+import cn.reghao.dfs.store.model.vo.VideoFileInfo;
 import cn.reghao.jutil.jdk.db.BaseMapper;
 import cn.reghao.dfs.store.model.po.VideoFile;
 import org.apache.ibatis.annotations.Mapper;
@@ -14,6 +15,11 @@ public interface VideoFileMapper extends BaseMapper<VideoFile> {
     void updateSetCover(@Param("videoFileId") String videoFileId,
                         @Param("coverUrl") String coverUrl,
                         @Param("coverUrlOriginal") String coverUrlOriginal);
+    void updateSetVideoActivate(@Param("videoFileId") String videoFileId, @Param("activate") boolean activate);
+    void updateSetVideoAuth(@Param("videoFileId") String videoFileId, @Param("auth") boolean auth);
 
     VideoFile findByVideoFileId(String videoFileId);
+    VideoFileInfo findVideoFileInfoByUploadId(@Param("uploadId") String uploadId,
+                                              @Param("group") int group,
+                                              @Param("node") int node);
 }

+ 2 - 0
src/main/java/cn/reghao/dfs/store/model/dto/VideoCover.java

@@ -1,6 +1,7 @@
 package cn.reghao.dfs.store.model.dto;
 
 import lombok.Getter;
+import lombok.Setter;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.constraints.NotBlank;
@@ -10,6 +11,7 @@ import javax.validation.constraints.NotNull;
  * @author reghao
  * @date 2022-08-15 12:45:21
  */
+@Setter
 @Getter
 public class VideoCover {
     @NotBlank

+ 7 - 1
src/main/java/cn/reghao/dfs/store/model/po/VideoFile.java

@@ -16,15 +16,21 @@ import lombok.Setter;
 @Setter
 @Getter
 public class VideoFile extends BaseObject<Integer> {
+    private String uploadId;
     private String videoFileId;
     private Boolean horizontal;
     // 单位秒
     private Integer duration;
     private String coverUrl;
     private String coverUrlOriginal;
+    private Boolean activate;
+    private Boolean auth;
 
-    public VideoFile(String videoFileId) {
+    public VideoFile(String uploadId, String videoFileId) {
+        this.uploadId = uploadId;
         this.videoFileId = videoFileId;
+        this.activate = false;
+        this.auth = true;
     }
 
     @Deprecated

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

@@ -1,6 +1,7 @@
 package cn.reghao.dfs.store.model.po;
 
 import cn.reghao.jutil.jdk.db.BaseObject;
+import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 
@@ -8,6 +9,7 @@ import lombok.NoArgsConstructor;
  * @author reghao
  * @date 2022-08-04 09:19:16
  */
+@AllArgsConstructor
 @NoArgsConstructor
 @Getter
 public class VideoUrl extends BaseObject<Integer> {
@@ -17,15 +19,5 @@ public class VideoUrl extends BaseObject<Integer> {
     private Integer width;
     private Integer height;
     private String quality;
-    private Integer bandwidth;
-    private Double frameRate;
-
-    public VideoUrl(String videoFileId, String fileId, String urlType, int width, int height, String quality) {
-        this.videoFileId = videoFileId;
-        this.fileId = fileId;
-        this.urlType = urlType;
-        this.width = width;
-        this.height = height;
-        this.quality = quality;
-    }
+    private String url;
 }

+ 1 - 0
src/main/java/cn/reghao/dfs/store/model/vo/ImageFileRet.java

@@ -11,6 +11,7 @@ import lombok.Getter;
 @Getter
 public class ImageFileRet {
     private String uploadId;
+    @Deprecated
     private String imageFileId;
     private String thumbnailUrl;
     private String originalUrl;

+ 17 - 0
src/main/java/cn/reghao/dfs/store/model/vo/VideoFileInfo.java

@@ -0,0 +1,17 @@
+package cn.reghao.dfs.store.model.vo;
+
+import lombok.Getter;
+
+/**
+ * @author reghao
+ * @date 2022-09-02 08:58:54
+ */
+@Getter
+public class VideoFileInfo {
+    private String videoFileId;
+    private String fileId;
+    private String uploadBy;
+    private boolean activate;
+    private boolean auth;
+    private String absolutePath;
+}

+ 11 - 8
src/main/java/cn/reghao/dfs/store/rpc/MediaUrlServiceImpl.java

@@ -1,10 +1,9 @@
 package cn.reghao.dfs.store.rpc;
 
 import cn.reghao.dfs.api.dto.EncryptParam;
-import cn.reghao.dfs.api.dto.FileAccess;
 import cn.reghao.dfs.api.iface.MediaUrlService;
 import cn.reghao.dfs.store.config.DfsProperties;
-import cn.reghao.dfs.store.db.mapper.FileUserMapper;
+import cn.reghao.dfs.store.db.mapper.VideoFileMapper;
 import cn.reghao.dfs.store.db.mapper.VideoUrlMapper;
 import cn.reghao.dfs.api.dto.VideoUrlDto;
 import cn.reghao.jutil.jdk.security.crypto.AesEncrypt;
@@ -23,14 +22,13 @@ import java.util.stream.Collectors;
 @Service
 public class MediaUrlServiceImpl implements MediaUrlService {
     private final String encryptKey;
+    private final VideoFileMapper videoFileMapper;
     private final VideoUrlMapper videoUrlMapper;
-    private final FileUserMapper fileUserMapper;
 
-    public MediaUrlServiceImpl(DfsProperties dfsProperties, VideoUrlMapper videoUrlMapper,
-                               FileUserMapper fileUserMapper) {
+    public MediaUrlServiceImpl(DfsProperties dfsProperties, VideoFileMapper videoFileMapper, VideoUrlMapper videoUrlMapper) {
         this.encryptKey = dfsProperties.getEncryptKey();
+        this.videoFileMapper = videoFileMapper;
         this.videoUrlMapper = videoUrlMapper;
-        this.fileUserMapper = fileUserMapper;
     }
 
     @Override
@@ -69,7 +67,12 @@ public class MediaUrlServiceImpl implements MediaUrlService {
     }
 
     @Override
-    public void activateFileAccess(FileAccess fileAccess) {
-        fileUserMapper.updateSetFileAccess(fileAccess);
+    public void setVideoFileAuth(String videoFileId, boolean auth) {
+        videoFileMapper.updateSetVideoAuth(videoFileId, auth);
+    }
+
+    @Override
+    public void setVideoFileActivate(String videoFileId, boolean activate) {
+        videoFileMapper.updateSetVideoActivate(videoFileId, activate);
     }
 }

+ 10 - 7
src/main/java/cn/reghao/dfs/store/service/media/VideoFileService.java

@@ -50,11 +50,10 @@ public class VideoFileService {
      * @date 2021-12-09 下午8:45
      */
     @Transactional(rollbackFor = Exception.class)
-    public VideoFile process(String fileId, PathUrl pathUrl) throws Exception {
-        VideoFile videoFile = new VideoFile(idGenerator.getUuid());
-        File videoLocalFile = new File(pathUrl.getAbsolutePath());
+    public VideoFile process(String uploadId, String fileId, PathUrl pathUrl) throws Exception {
+        VideoFile videoFile = new VideoFile(uploadId, idGenerator.getUuid());
         log.info("process video {} with FFmpeg...", videoFile.getVideoFileId());
-        setVideoProps(videoFile, fileId, videoLocalFile);
+        setVideoProps(videoFile, fileId, pathUrl);
         log.info("video {} processed...", videoFile.getVideoFileId());
 
         videoFileMapper.save(videoFile);
@@ -76,7 +75,10 @@ public class VideoFileService {
      * @return
      * @date 2021-08-18 上午10:08
      */
-    private void setVideoProps(VideoFile videoFile, String fileId, File file) throws IOException {
+    private void setVideoProps(VideoFile videoFile, String fileId, PathUrl pathUrl) throws IOException {
+        File file = new File(pathUrl.getAbsolutePath());
+        String url = pathUrl.getUrl();
+
         Map<String, Object> map = VideoOps.videoProps(file);
         int width = (Integer) map.get("width");
         int height = (Integer) map.get("height");
@@ -91,8 +93,9 @@ public class VideoFileService {
         videoFile.setHorizontal(horizontal);
         String videoFileId = videoFile.getVideoFileId();
         MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
-        VideoUrl videoUrl = new VideoUrl(videoFileId, fileId, VideoUrlType.mp4.getName(),
-                width, height, mediaResolution.getQuality());
+
+        VideoUrl videoUrl = new VideoUrl(videoFileId, fileId, VideoUrlType.mp4.getName(), width, height,
+                mediaResolution.getQuality(), url);
         videoUrlMapper.save(videoUrl);
     }
 

+ 2 - 21
src/main/resources/mapper/FileUserMapper.xml

@@ -4,30 +4,11 @@
 <mapper namespace="cn.reghao.dfs.store.db.mapper.FileUserMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into file_user
-        (`id`,`deleted`,`create_time`,`update_time`,`upload_id`,`upload_by`,`file_id`,`activate`,`auth`)
+        (`id`,`deleted`,`create_time`,`update_time`,`upload_id`,`upload_by`,`file_id`)
         values 
-        (#{id},#{deleted},#{createTime},#{updateTime},#{uploadId},#{uploadBy},#{fileId},#{activate},#{auth})
+        (#{id},#{deleted},#{createTime},#{updateTime},#{uploadId},#{uploadBy},#{fileId})
     </insert>
 
-    <update id="updateSetFileAccess">
-        update file_user
-        set update_time=now(),activate=#{activate},auth=#{auth}
-        where upload_id=#{uploadId}
-    </update>
-    <update id="updateSetNeedAuth">
-        update file_user
-        set update_time=now(),auth=1
-        where upload_id=#{uploadId}
-    </update>
-    <update id="updateSetNotNeedAuth">
-        update file_user
-        set update_time=now(),auth=0
-        where upload_id=#{uploadId}
-    </update>
-
-    <select id="findFileAccessByUploadId" resultType="cn.reghao.dfs.api.dto.FileAccess">
-        select upload_id,activate,auth from file_user where upload_id=#{uploadId}
-    </select>
     <select id="findByFileAndUserId" resultType="cn.reghao.dfs.store.model.po.FileUser">
         select * from file_user
         where file_id=#{fileId} and upload_by=#{userId}

+ 22 - 2
src/main/resources/mapper/VideoFileMapper.xml

@@ -4,15 +4,25 @@
 <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_file_id`,`horizontal`,`duration`,`cover_url`,`cover_url_original`)
+        (`id`,`deleted`,`create_time`,`update_time`,`video_file_id`,`horizontal`,`duration`,`cover_url`,`cover_url_original`,`activate`,`auth`)
         values 
-        (#{id},#{deleted},#{createTime},#{updateTime},#{videoFileId},#{horizontal},#{duration},#{coverUrl},#{coverUrlOriginal})
+        (#{id},#{deleted},#{createTime},#{updateTime},#{videoFileId},#{horizontal},#{duration},#{coverUrl},#{coverUrlOriginal},#{activate},#{auth})
     </insert>
 
     <update id="updateSetCover">
         update video_file set update_time=now(),cover_url=#{coverUrl},cover_url_original=#{coverUrlOriginal}
         where video_file_id=#{videoFileId}
     </update>
+    <update id="updateSetVideoActivate">
+        update video_file
+        set update_time=now(),activate=#{activate}
+        where video_file_id=#{videoFileId}
+    </update>
+    <update id="updateSetVideoAuth">
+        update video_file
+        set update_time=now(),auth=#{auth}
+        where video_file_id=#{videoFileId}
+    </update>
 
     <select id="findAll" resultType="cn.reghao.dfs.store.model.po.VideoFile">
         select * from video_file
@@ -20,4 +30,14 @@
     <select id="findByVideoFileId" resultType="cn.reghao.dfs.store.model.po.VideoFile">
         select * from video_file where video_file_id=#{videoFileId}
     </select>
+    <select id="findVideoFileInfoByUploadId" resultType="cn.reghao.dfs.store.model.vo.VideoFileInfo">
+        select videoFile.video_file_id,videoFile.activate,videoFile.auth,videoUrl.file_id,filePath.absolute_path,fileUser.upload_by
+        from video_file videoFile
+        inner join video_url videoUrl
+        inner join file_user fileUser
+        inner join file_path filePath
+        on videoFile.video_file_id=videoUrl.video_file_id and videoUrl.file_id=fileUser.file_id
+        and videoUrl.file_id=filePath.file_id and filePath.`group`=#{group} and filePath.`node`=#{node}
+        and fileUser.upload_id=#{uploadId}
+    </select>
 </mapper>

+ 2 - 2
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_file_id`,`file_id`,`url_type`,`width`,`height`,`quality`,`bandwidth`,`frame_rate`)
+        (`video_file_id`,`file_id`,`url_type`,`width`,`height`,`quality`,`url`)
         values
-        (#{videoFileId},#{fileId},#{urlType},#{width},#{height},#{quality},#{bandwidth},#{frameRate})
+        (#{videoFileId},#{fileId},#{urlType},#{width},#{height},#{quality},#{url})
     </insert>
 
     <update id="updateSetUrl">

+ 3 - 3
src/test/java/VideoFileTest.java

@@ -60,8 +60,8 @@ public class VideoFileTest {
         int width = 1280;
         int height = 720;
         MediaResolution mediaResolution = MediaQuality.getQuality(width, height);
-        VideoUrl videoUrl = new VideoUrl(videoFileId, fileId, VideoUrlType.mp4.getName(),
-                width, height, mediaResolution.getQuality());
-        videoUrlMapper.save(videoUrl);
+        VideoUrl videoUrl = new VideoUrl(videoFileId, fileId, VideoUrlType.mp4.getName(), width, height,
+                mediaResolution.getQuality(), "");
+        //videoUrlMapper.save(videoUrl);
     }
 }