Browse Source

更新 oss-console 的接口参数

reghao 2 years ago
parent
commit
48c667e88e
26 changed files with 370 additions and 201 deletions
  1. 1 1
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/AudioFileController.java
  2. 4 3
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/ImageFileController.java
  3. 3 4
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssObjectController.java
  4. 7 4
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssServerController.java
  5. 10 9
      oss-console/src/main/java/cn/reghao/oss/console/app/controller/VideoFileController.java
  6. 16 0
      oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/SetScopeDto.java
  7. 11 1
      oss-console/src/main/java/cn/reghao/oss/console/app/rpc/AudioService.java
  8. 50 0
      oss-console/src/main/java/cn/reghao/oss/console/app/rpc/ImageService.java
  9. 42 0
      oss-console/src/main/java/cn/reghao/oss/console/app/rpc/OssObjectService.java
  10. 8 21
      oss-console/src/main/java/cn/reghao/oss/console/app/rpc/OssService.java
  11. 1 1
      oss-console/src/main/java/cn/reghao/oss/console/app/rpc/RemoteService.java
  12. 68 0
      oss-console/src/main/java/cn/reghao/oss/console/app/rpc/VideoService.java
  13. 0 19
      oss-console/src/main/java/cn/reghao/oss/console/app/service/OssObjectService.java
  14. 23 0
      oss-console/src/main/java/cn/reghao/oss/console/app/service/UploadChannelService.java
  15. 0 25
      oss-console/src/main/java/cn/reghao/oss/console/app/service/media/ImageService.java
  16. 0 36
      oss-console/src/main/java/cn/reghao/oss/console/app/service/media/VideoService.java
  17. 100 61
      oss-sdk/src/main/java/cn/reghao/oss/sdk/OssConsoleClient.java
  18. 7 2
      oss-sdk/src/test/java/ObjectTest.java
  19. 2 1
      oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectGetController.java
  20. 2 1
      oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectUploadController.java
  21. 2 1
      oss-store/src/main/java/cn/reghao/oss/store/rpc/ObjectServiceImpl.java
  22. 3 3
      oss-store/src/main/java/cn/reghao/oss/store/rpc/SignService.java
  23. 2 1
      oss-store/src/main/java/cn/reghao/oss/store/rpc/media/AudioFileServiceImpl.java
  24. 2 2
      oss-store/src/main/java/cn/reghao/oss/store/rpc/media/VideoFileServiceImpl.java
  25. 5 4
      oss-store/src/main/java/cn/reghao/oss/store/service/ObjectChannelService.java
  26. 1 1
      store-api/src/main/java/cn/reghao/oss/store/api/iface/media/VideoFileService.java

+ 1 - 1
oss-console/src/main/java/cn/reghao/oss/console/app/controller/AudioFileController.java

@@ -3,7 +3,7 @@ package cn.reghao.oss.console.app.controller;
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.oss.store.api.dto.media.AudioInfo;
 import cn.reghao.oss.store.api.dto.media.AudioUrl;
-import cn.reghao.oss.console.app.service.media.AudioService;
+import cn.reghao.oss.console.app.rpc.AudioService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.http.MediaType;

+ 4 - 3
oss-console/src/main/java/cn/reghao/oss/console/app/controller/ImageFileController.java

@@ -2,7 +2,7 @@ package cn.reghao.oss.console.app.controller;
 
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.oss.store.api.dto.media.ImageUrlDto;
-import cn.reghao.oss.console.app.service.media.ImageService;
+import cn.reghao.oss.console.app.rpc.ImageService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.http.MediaType;
@@ -34,8 +34,9 @@ public class ImageFileController {
 
     @ApiOperation(value = "获取图片文件 url")
     @GetMapping(value = "/urls", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getImageUrls(@RequestParam("imageFileIds") Set<String> imageFileIds) {
-        List<ImageUrlDto> list = imageService.getImageUrls(imageFileIds);
+    public String getImageUrls(@RequestParam("channelId") Integer channelId,
+                               @RequestParam("imageFileIds") Set<String> imageFileIds) throws Exception {
+        List<ImageUrlDto> list = imageService.getImageUrls(channelId, imageFileIds);
         return WebResult.success(list);
     }
 }

+ 3 - 4
oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssObjectController.java

@@ -1,7 +1,8 @@
 package cn.reghao.oss.console.app.controller;
 
 import cn.reghao.jutil.jdk.result.WebResult;
-import cn.reghao.oss.console.app.service.OssObjectService;
+import cn.reghao.oss.console.app.model.dto.SetScopeDto;
+import cn.reghao.oss.console.app.rpc.OssObjectService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.http.MediaType;
@@ -25,9 +26,7 @@ public class OssObjectController {
 
     @ApiOperation(value = "设置对象可见范围")
     @PostMapping(value = "/scope/object", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String setObjectScope(@RequestParam("scope") Integer scope,
-                                @RequestParam("objectId") String objectId,
-                                @RequestParam("contentType") Integer contentType) {
+    public String setObjectScope(SetScopeDto setScopeDto) {
         return WebResult.success();
     }
 

+ 7 - 4
oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssServerController.java

@@ -1,10 +1,11 @@
 package cn.reghao.oss.console.app.controller;
 
 import cn.reghao.jutil.jdk.result.WebResult;
+import cn.reghao.oss.console.app.rpc.OssObjectService;
 import cn.reghao.oss.store.api.dto.DownloadUrl;
 import cn.reghao.oss.store.api.dto.ObjectInfo;
 import cn.reghao.oss.store.api.dto.ServerInfo;
-import cn.reghao.oss.console.app.service.OssService;
+import cn.reghao.oss.console.app.rpc.OssService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.http.MediaType;
@@ -22,9 +23,11 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/api/oss")
 public class OssServerController {
     private final OssService ossService;
+    private final OssObjectService ossObjectService;
 
-    public OssServerController(OssService ossService) {
+    public OssServerController(OssService ossService, OssObjectService ossObjectService) {
         this.ossService = ossService;
+        this.ossObjectService = ossObjectService;
     }
 
     @ApiOperation(value = "获取 oss-store 节点")
@@ -37,14 +40,14 @@ public class OssServerController {
     @ApiOperation(value = "获取对象信息")
     @GetMapping(value = "/object/info", produces = MediaType.APPLICATION_JSON_VALUE)
     public String getObjectInfo(@RequestParam("objectId") String objectId) {
-        ObjectInfo objectInfo = ossService.getObjectInfo(objectId);
+        ObjectInfo objectInfo = ossObjectService.getObjectInfo(objectId);
         return WebResult.success(objectInfo);
     }
 
     @ApiOperation(value = "获取对象 url")
     @GetMapping(value = "/object/url", produces = MediaType.APPLICATION_JSON_VALUE)
     public String getObjectUrl(@RequestParam("objectId") String objectId) {
-        DownloadUrl downloadUrl = ossService.getDownloadUrl(objectId);
+        DownloadUrl downloadUrl = ossObjectService.getDownloadUrl(objectId);
         return WebResult.success(downloadUrl);
     }
 }

+ 10 - 9
oss-console/src/main/java/cn/reghao/oss/console/app/controller/VideoFileController.java

@@ -3,7 +3,7 @@ package cn.reghao.oss.console.app.controller;
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.oss.store.api.dto.media.VideoInfo;
 import cn.reghao.oss.store.api.dto.media.VideoUrlDto;
-import cn.reghao.oss.console.app.service.media.VideoService;
+import cn.reghao.oss.console.app.rpc.VideoService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.http.MediaType;
@@ -34,23 +34,24 @@ public class VideoFileController {
     }
 
     @ApiOperation(value = "获取视频文件信息")
-    @GetMapping(value = "/info/{videoFileId}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getVideoInfo(@PathVariable("videoFileId") String videoFileId) {
-        VideoInfo videoInfo = videoService.getVideoInfo(videoFileId);
+    @GetMapping(value = "/info", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getVideoInfo(@RequestParam("channelId") Integer channelId,
+                               @RequestParam("videoFileId") String videoFileId) throws Exception {
+        VideoInfo videoInfo = videoService.getVideoInfo(channelId, videoFileId);
         return WebResult.success(videoInfo);
     }
 
     @ApiOperation(value = "获取视频文件URL")
     @GetMapping(value = "/url", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getVideoUrl(@RequestParam("videoFileId") String videoFileId) {
-        List<VideoUrlDto> list = videoService.getVideoUrls(videoFileId);
+    public String getVideoUrl(@RequestParam("channelId") Integer channelId, @RequestParam("videoFileId") String videoFileId) throws Exception {
+        List<VideoUrlDto> list = videoService.getVideoUrls(channelId, videoFileId);
         return WebResult.success(list);
     }
 
     @ApiOperation(value = "获取视频文件创建时间")
-    @GetMapping(value = "/time/{videoFileId}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getVideoCreateTime(@PathVariable("videoFileId") String videoFileId) {
-        LocalDateTime localDateTime = videoService.getCreateTime(videoFileId);
+    @GetMapping(value = "/time", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getVideoCreateTime(@RequestParam("channelId") Integer channelId, @RequestParam("videoFileId") String videoFileId) throws Exception {
+        LocalDateTime localDateTime = videoService.getCreateTime(channelId, videoFileId);
         return WebResult.success(localDateTime);
     }
 }

+ 16 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/SetScopeDto.java

@@ -0,0 +1,16 @@
+package cn.reghao.oss.console.app.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author reghao
+ * @date 2024-03-01 13:32:25
+ */
+@Setter
+@Getter
+public class SetScopeDto {
+    private Integer scope;
+    private String objectId;
+    private Integer contentType;
+}

+ 11 - 1
oss-console/src/main/java/cn/reghao/oss/console/app/service/media/AudioService.java → oss-console/src/main/java/cn/reghao/oss/console/app/rpc/AudioService.java

@@ -1,4 +1,4 @@
-package cn.reghao.oss.console.app.service.media;
+package cn.reghao.oss.console.app.rpc;
 
 import cn.reghao.oss.store.api.dto.media.AudioInfo;
 import cn.reghao.oss.store.api.dto.media.AudioUrl;
@@ -16,10 +16,20 @@ public class AudioService {
     private AudioFileService audioFileService;
 
     public AudioInfo getAudioInfo(String audioFileId) {
+        RemoteService<AudioFileService> remoteService = new RemoteService<>();
+        String host = "";
+        int port = -1;
+        AudioFileService audioFileService = remoteService.getService(host, port, AudioFileService.class);
+
         return audioFileService.getAudioInfo(audioFileId);
     }
 
     public List<AudioUrl> getAudioUrls(String audioFileId) {
+        RemoteService<AudioFileService> remoteService = new RemoteService<>();
+        String host = "";
+        int port = -1;
+        AudioFileService audioFileService = remoteService.getService(host, port, AudioFileService.class);
+
         int expireSecond = 3600;
         return audioFileService.getAudioUrls(audioFileId, expireSecond);
     }

+ 50 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/rpc/ImageService.java

@@ -0,0 +1,50 @@
+package cn.reghao.oss.console.app.rpc;
+
+import cn.reghao.oss.console.app.model.po.StoreNode;
+import cn.reghao.oss.console.app.service.UploadChannelService;
+import cn.reghao.oss.store.api.dto.media.ImageUrlDto;
+import cn.reghao.oss.store.api.iface.media.ImageFileService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author reghao
+ * @date 2024-02-23 09:10:44
+ */
+@Service
+public class ImageService {
+    private ImageFileService imageFileService;
+    private final UploadChannelService uploadChannelService;
+
+    public ImageService(UploadChannelService uploadChannelService) {
+        this.uploadChannelService = uploadChannelService;
+    }
+
+    public void deleteByImageFileIds(List<String> imageFileIds) throws Exception {
+        int channelId = 1;
+        ImageFileService imageFileService = getImageFileService(channelId);
+
+        imageFileService.deleteByImageFileIds(imageFileIds);
+    }
+
+    public List<ImageUrlDto> getImageUrls(int channelId, Set<String> imageFileIds) throws Exception {
+        ImageFileService imageFileService = getImageFileService(channelId);
+
+        return imageFileService.getImageUrls(imageFileIds);
+    }
+
+    private ImageFileService getImageFileService(int channelId) throws Exception {
+        StoreNode storeNode = uploadChannelService.getStoreNode(channelId);
+        if (storeNode == null) {
+            String errMsg = String.format("channel_id %s not associate with any store_node", channelId);
+            throw new Exception(errMsg);
+        }
+
+        RemoteService<ImageFileService> remoteService = new RemoteService<>();
+        String host = storeNode.getIpv4Addr();
+        int port = storeNode.getRpcPort();
+        return remoteService.getService(host, port, ImageFileService.class);
+    }
+}

+ 42 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/rpc/OssObjectService.java

@@ -0,0 +1,42 @@
+package cn.reghao.oss.console.app.rpc;
+
+import cn.reghao.oss.store.api.dto.DownloadUrl;
+import cn.reghao.oss.store.api.dto.ObjectInfo;
+import cn.reghao.oss.store.api.iface.ObjectService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2024-02-29 14:27:03
+ */
+@Service
+public class OssObjectService {
+    private ObjectService objectService;
+
+    public void deleteByObjectNames(List<String> objectNames) {
+        RemoteService<ObjectService> remoteService = new RemoteService<>();
+        String host = "";
+        int port = -1;
+        ObjectService objectService = remoteService.getService(host, port, ObjectService.class);
+        objectService.deleteByObjectNames(objectNames);
+    }
+
+    public ObjectInfo getObjectInfo(String objectId) {
+        RemoteService<ObjectService> remoteService = new RemoteService<>();
+        String host = "";
+        int port = -1;
+        ObjectService objectService = remoteService.getService(host, port, ObjectService.class);
+        return objectService.getObjectInfo(objectId);
+    }
+
+    public DownloadUrl getDownloadUrl(String objectId) {
+        int expireSecond = 3600;
+        RemoteService<ObjectService> remoteService = new RemoteService<>();
+        String host = "";
+        int port = -1;
+        ObjectService objectService = remoteService.getService(host, port, ObjectService.class);
+        return objectService.getDownloadUrl(objectId, expireSecond);
+    }
+}

+ 8 - 21
oss-console/src/main/java/cn/reghao/oss/console/app/service/OssService.java → oss-console/src/main/java/cn/reghao/oss/console/app/rpc/OssService.java

@@ -1,5 +1,7 @@
-package cn.reghao.oss.console.app.service;
+package cn.reghao.oss.console.app.rpc;
 
+import cn.reghao.oss.console.app.rpc.RemoteService;
+import cn.reghao.oss.console.app.service.UploadChannelService;
 import cn.reghao.oss.store.api.dto.*;
 import cn.reghao.oss.store.api.iface.ObjectService;
 import cn.reghao.oss.store.api.iface.OssServerService;
@@ -18,10 +20,12 @@ import org.springframework.stereotype.Service;
 public class OssService {
     private final UploadChannelRepository uploadChannelRepository;
     private final StoreNodeRepository storeNodeRepository;
+    private UploadChannelService uploadChannelService;
 
-    public OssService(UploadChannelRepository uploadChannelRepository, StoreNodeRepository storeNodeRepository) {
+    public OssService(UploadChannelRepository uploadChannelRepository, StoreNodeRepository storeNodeRepository, UploadChannelService uploadChannelService) {
         this.uploadChannelRepository = uploadChannelRepository;
         this.storeNodeRepository = storeNodeRepository;
+        this.uploadChannelService = uploadChannelService;
     }
 
     public ServerInfo getServerInfo(int channelId) throws Exception {
@@ -36,9 +40,9 @@ public class OssService {
         String ossUrl = String.format("https://%s", domain);
         long maxSize = uploadChannel.getMaxSize();
 
-        StoreNode storeNode = storeNodeRepository.findByDomain(domain);
+        StoreNode storeNode = uploadChannelService.getStoreNode(channelId);
         if (storeNode == null) {
-            String errMsg = String.format("store_node %s not exist", domain);
+            String errMsg = String.format("channel_id %s not associate with any store_node", channelId);
             throw new Exception(errMsg);
         }
 
@@ -49,21 +53,4 @@ public class OssService {
         String token = ossServerService.getUploadToken(userId, channelId);
         return new ServerInfo(ossUrl, channelId, maxSize, token);
     }
-
-    public ObjectInfo getObjectInfo(String objectId) {
-        RemoteService<ObjectService> remoteService = new RemoteService<>();
-        String host = "";
-        int port = -1;
-        ObjectService objectService = remoteService.getService(host, port, ObjectService.class);
-        return objectService.getObjectInfo(objectId);
-    }
-
-    public DownloadUrl getDownloadUrl(String objectId) {
-        int expireSecond = 3600;
-        RemoteService<ObjectService> remoteService = new RemoteService<>();
-        String host = "";
-        int port = -1;
-        ObjectService objectService = remoteService.getService(host, port, ObjectService.class);
-        return objectService.getDownloadUrl(objectId, expireSecond);
-    }
 }

+ 1 - 1
oss-console/src/main/java/cn/reghao/oss/console/app/service/RemoteService.java → oss-console/src/main/java/cn/reghao/oss/console/app/rpc/RemoteService.java

@@ -1,4 +1,4 @@
-package cn.reghao.oss.console.app.service;
+package cn.reghao.oss.console.app.rpc;
 
 import cn.reghao.oss.store.api.iface.media.VideoFileService;
 import org.apache.dubbo.config.ApplicationConfig;

+ 68 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/rpc/VideoService.java

@@ -0,0 +1,68 @@
+package cn.reghao.oss.console.app.rpc;
+
+import cn.reghao.oss.console.account.service.UserContext;
+import cn.reghao.oss.console.app.model.po.StoreNode;
+import cn.reghao.oss.console.app.service.UploadChannelService;
+import cn.reghao.oss.console.util.AuthKeyContext;
+import cn.reghao.oss.store.api.dto.media.VideoInfo;
+import cn.reghao.oss.store.api.dto.media.VideoUrlDto;
+import cn.reghao.oss.store.api.iface.media.ImageFileService;
+import cn.reghao.oss.store.api.iface.media.VideoFileService;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2024-02-23 08:55:03
+ */
+@Service
+public class VideoService {
+    private VideoFileService videoFileService;
+    private final UploadChannelService uploadChannelService;
+
+    public VideoService(UploadChannelService uploadChannelService) {
+        this.uploadChannelService = uploadChannelService;
+    }
+
+    public void deleteVideoFile(String videoFileId) {
+        RemoteService<VideoFileService> remoteService = new RemoteService<>();
+        String host = "";
+        int port = -1;
+        VideoFileService videoFileService = remoteService.getService(host, port, VideoFileService.class);
+
+        videoFileService.deleteVideoFile(videoFileId);
+    }
+
+    public VideoInfo getVideoInfo(int channelId, String videoFileId) throws Exception {
+        VideoFileService videoFileService = getVideoFileService(channelId);
+        return videoFileService.getVideoInfo(videoFileId);
+    }
+
+    public List<VideoUrlDto> getVideoUrls(int channelId, String videoFileId) throws Exception {
+        int loginUser = AuthKeyContext.getUser();
+        VideoFileService videoFileService = getVideoFileService(channelId);
+
+        int expireSecond = 3600;
+        return videoFileService.getVideoUrls(loginUser, videoFileId, expireSecond);
+    }
+
+    public LocalDateTime getCreateTime(int channelId, String videoFileId) throws Exception {
+        VideoFileService videoFileService = getVideoFileService(channelId);
+        return videoFileService.getCreateTime(videoFileId);
+    }
+
+    private VideoFileService getVideoFileService(int channelId) throws Exception {
+        StoreNode storeNode = uploadChannelService.getStoreNode(channelId);
+        if (storeNode == null) {
+            String errMsg = String.format("channel_id %s not associate with any store_node", channelId);
+            throw new Exception(errMsg);
+        }
+
+        RemoteService<VideoFileService> remoteService = new RemoteService<>();
+        String host = storeNode.getIpv4Addr();
+        int port = storeNode.getRpcPort();
+        return remoteService.getService(host, port, VideoFileService.class);
+    }
+}

+ 0 - 19
oss-console/src/main/java/cn/reghao/oss/console/app/service/OssObjectService.java

@@ -1,19 +0,0 @@
-package cn.reghao.oss.console.app.service;
-
-import cn.reghao.oss.store.api.iface.ObjectService;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2024-02-29 14:27:03
- */
-@Service
-public class OssObjectService {
-    private ObjectService objectService;
-
-    public void deleteByObjectNames(List<String> objectNames) {
-        objectService.deleteByObjectNames(objectNames);
-    }
-}

+ 23 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/service/UploadChannelService.java

@@ -3,6 +3,8 @@ package cn.reghao.oss.console.app.service;
 import cn.reghao.jutil.jdk.converter.ByteConverter;
 import cn.reghao.jutil.jdk.converter.ByteType;
 import cn.reghao.jutil.jdk.result.Result;
+import cn.reghao.oss.console.app.rpc.RemoteService;
+import cn.reghao.oss.console.util.AuthKeyContext;
 import cn.reghao.oss.store.api.dto.ObjectChannel;
 import cn.reghao.oss.store.api.iface.OssServerService;
 import cn.reghao.oss.console.account.service.UserContext;
@@ -112,4 +114,25 @@ public class UploadChannelService {
     public UploadChannel getUploadChannel(int id) {
         return uploadChannelRepository.findById(id).orElse(null);
     }
+
+    public StoreNode getStoreNode(int channelId) throws Exception {
+        int userId = AuthKeyContext.getUser();
+        UploadChannel uploadChannel = uploadChannelRepository.findByChannelIdAndCreateBy(channelId, userId);
+        if (uploadChannel == null) {
+            String errMsg = String.format("channel_id %s not exist", channelId);
+            throw new Exception(errMsg);
+        }
+
+        String domain = uploadChannel.getBindDomain();
+        String ossUrl = String.format("https://%s", domain);
+        long maxSize = uploadChannel.getMaxSize();
+
+        StoreNode storeNode = storeNodeRepository.findByDomain(domain);
+        if (storeNode == null) {
+            String errMsg = String.format("store_node %s not exist", domain);
+            throw new Exception(errMsg);
+        }
+
+        return storeNode;
+    }
 }

+ 0 - 25
oss-console/src/main/java/cn/reghao/oss/console/app/service/media/ImageService.java

@@ -1,25 +0,0 @@
-package cn.reghao.oss.console.app.service.media;
-
-import cn.reghao.oss.store.api.dto.media.ImageUrlDto;
-import cn.reghao.oss.store.api.iface.media.ImageFileService;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author reghao
- * @date 2024-02-23 09:10:44
- */
-@Service
-public class ImageService {
-    private ImageFileService imageFileService;
-
-    public void deleteByImageFileIds(List<String> imageFileIds) {
-        imageFileService.deleteByImageFileIds(imageFileIds);
-    }
-
-    public List<ImageUrlDto> getImageUrls(Set<String> imageFileIds) {
-        return imageFileService.getImageUrls(imageFileIds);
-    }
-}

+ 0 - 36
oss-console/src/main/java/cn/reghao/oss/console/app/service/media/VideoService.java

@@ -1,36 +0,0 @@
-package cn.reghao.oss.console.app.service.media;
-
-import cn.reghao.oss.console.util.AuthKeyContext;
-import cn.reghao.oss.store.api.dto.media.VideoInfo;
-import cn.reghao.oss.store.api.dto.media.VideoUrlDto;
-import cn.reghao.oss.store.api.iface.media.VideoFileService;
-import org.springframework.stereotype.Service;
-
-import java.time.LocalDateTime;
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2024-02-23 08:55:03
- */
-@Service
-public class VideoService {
-    private VideoFileService videoFileService;
-
-    public void deleteVideoFile(String videoFileId) {
-        videoFileService.deleteVideoFile(videoFileId);
-    }
-
-    public VideoInfo getVideoInfo(String videoFileId) {
-        return videoFileService.getVideoInfo(videoFileId);
-    }
-
-    public List<VideoUrlDto> getVideoUrls(String videoFileId) {
-        int expireSecond = 3600;
-        return videoFileService.getVideoUrls(videoFileId, expireSecond);
-    }
-
-    public LocalDateTime getCreateTime(String videoFileId) {
-        return videoFileService.getCreateTime(videoFileId);
-    }
-}

+ 100 - 61
oss-sdk/src/main/java/cn/reghao/oss/sdk/OssConsoleClient.java

@@ -8,11 +8,15 @@ import com.google.gson.reflect.TypeToken;
 
 import java.lang.reflect.Type;
 import java.net.URI;
+import java.net.URLEncoder;
 import java.net.http.HttpClient;
 import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
+import java.nio.charset.StandardCharsets;
 import java.time.LocalDateTime;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -239,22 +243,23 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public void convertVideo(String videoFileId) throws Exception {
-        String api = String.format("%s/api/oss/media/convert/video/%s", endpoint, videoFileId);
-        convert(api);
-    }
+    public void setObjectScope(int scope, String objectId, int contentType) throws Exception {
+        String api = String.format("%s/api/oss/media/scope/object", endpoint);
+        /*MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
+        publisher.addPart("scope", scope+"");
+        publisher.addPart("objectId", objectId);
+        publisher.addPart("contentType", contentType+"");*/
 
-    public void convertAudio(String audioFileId) throws Exception {
-        String api = String.format("%s/api/oss/media/convert/audio/%s", endpoint, audioFileId);
-        convert(api);
-    }
+        Map<String, String> formData = new HashMap<>();
+        formData.put("scope", scope+"");
+        formData.put("objectId", objectId);
+        formData.put("contentType", contentType+"");
 
-    private void convert(String api) throws Exception {
-        MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
+                .headers("content-type", "application/x-www-form-urlencoded")
                 .version(HttpClient.Version.HTTP_1_1)
-                .POST(publisher.build())
+                .POST(HttpRequest.BodyPublishers.ofString(getFormDataAsString(formData)))
                 .build();
         HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
         int statusCode = httpResponse.statusCode();
@@ -272,11 +277,12 @@ public class OssConsoleClient {
         }
     }
 
-    public void setObjectScope(int scope, String objectId, int contentType) throws Exception {
-        String api = String.format("%s/api/oss/media/scope/object", endpoint);
+    public void setObjectsScope(int scope, List<String> objectIds, int contentType) throws Exception {
+        String objectIdsStr = objectIds.toString().replace("[", "").replace("]", "");
+        String api = String.format("%s/api/oss/media/scope/objects", endpoint);
         MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
         publisher.addPart("scope", scope+"");
-        publisher.addPart("objectId", objectId);
+        publisher.addPart("objectIds", objectIdsStr);
         publisher.addPart("contentType", contentType+"");
 
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
@@ -300,18 +306,28 @@ public class OssConsoleClient {
         }
     }
 
-    public void setObjectsScope(int scope, List<String> objectIds, int contentType) throws Exception {
-        String api = String.format("%s/api/oss/media/scope/objects", endpoint);
+    private String getFormDataAsString(Map<String, String> formData) {
+        StringBuilder formBodyBuilder = new StringBuilder();
+        for (Map.Entry<String, String> singleEntry : formData.entrySet()) {
+            if (formBodyBuilder.length() > 0) {
+                formBodyBuilder.append("&");
+            }
+            formBodyBuilder.append(URLEncoder.encode(singleEntry.getKey(), StandardCharsets.UTF_8));
+            formBodyBuilder.append("=");
+            formBodyBuilder.append(URLEncoder.encode(singleEntry.getValue(), StandardCharsets.UTF_8));
+        }
+        return formBodyBuilder.toString();
+    }
+
+    public void deleteByObjectNames(List<String> objectNames) throws Exception {
+        String api = String.format("%s/api/oss/media/image/delete/name", endpoint);
+        HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
+
+        String objectNamesStr = objectNames.toString().replace("[", "").replace("]", "");
         MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
-        publisher.addPart("scope", scope+"");
-        publisher.addPart("objectIds", objectIds.toString());
-        publisher.addPart("contentType", contentType+"");
+        publisher.addPart("objectNames", objectNamesStr);
 
-        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
-                .header("authorization", "Bearer " + token)
-                .version(HttpClient.Version.HTTP_1_1)
-                .POST(publisher.build())
-                .build();
+        HttpRequest httpRequest = builder.POST(publisher.build()).build();
         HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
         int statusCode = httpResponse.statusCode();
         String body = httpResponse.body();
@@ -328,8 +344,11 @@ public class OssConsoleClient {
         }
     }
 
-    public AudioInfo getAudioInfo(String audioFileId) throws Exception {
-        String api = String.format("%s/api/oss/media/audio/info/%s", endpoint, audioFileId);
+    // ****************************************************************************************************************
+    // 视频文件相关接口
+    // ****************************************************************************************************************
+    public VideoInfo getVideoInfo(int channelId, String videoFileId) throws Exception {
+        String api = String.format("%s/api/oss/media/video/info?channelId=%s&videoFileId=%s", endpoint, channelId, videoFileId);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
@@ -343,8 +362,8 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<AudioInfo>>(){}.getType();
-        WebResult<AudioInfo> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<VideoInfo>>(){}.getType();
+        WebResult<VideoInfo> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
@@ -353,8 +372,8 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public List<AudioUrl> getAudioUrls(String audioFileId, int loginUser) throws Exception {
-        String api = String.format("%s/api/oss/media/audio/url?audioFileId=%s&userId=%s", endpoint, audioFileId, loginUser);
+    public List<VideoUrlDto> getVideoUrls(int channelId, String videoFileId) throws Exception {
+        String api = String.format("%s/api/oss/media/video/url?channelId=%s&videoFileId=%s", endpoint, channelId, videoFileId);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
@@ -368,8 +387,8 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<List<AudioUrl>>>(){}.getType();
-        WebResult<List<AudioUrl>> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<List<VideoUrlDto>>>(){}.getType();
+        WebResult<List<VideoUrlDto>> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
@@ -378,14 +397,14 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public void deleteByObjectNames(List<String> objectNames) throws Exception {
-        String api = String.format("%s/api/oss/media/image/delete/name", endpoint);
-        HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
-
-        MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
-        publisher.addPart("objectNames", objectNames.toString());
-
-        HttpRequest httpRequest = builder.POST(publisher.build()).build();
+    @Deprecated
+    public LocalDateTime getCreateTime(int channelId, String videoFileId) throws Exception {
+        String api = String.format("%s/api/oss/media/video/time?channelId=%s&videoFileId=%s", endpoint, channelId, videoFileId);
+        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
+                .header("authorization", "Bearer " + token)
+                .version(HttpClient.Version.HTTP_1_1)
+                .GET()
+                .build();
         HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
         int statusCode = httpResponse.statusCode();
         String body = httpResponse.body();
@@ -394,20 +413,26 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<String>>(){}.getType();
-        WebResult<String> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<LocalDateTime>>(){}.getType();
+        WebResult<LocalDateTime> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
         }
+
+        return webResult.getData();
     }
 
+    // ****************************************************************************************************************
+    // 图片文件相关接口
+    // ****************************************************************************************************************
     public void deleteByImageFileIds(List<String> imageFileIds) throws Exception {
         String api = String.format("%s/api/oss/media/image/delete/id", endpoint);
         HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(api)).version(HttpClient.Version.HTTP_1_1);
 
+        String imageFileIdsStr = imageFileIds.toString().replace("[", "").replace("]", "");
         MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
-        publisher.addPart("imageFileIds", imageFileIds.toString());
+        publisher.addPart("imageFileIds", imageFileIdsStr);
 
         HttpRequest httpRequest = builder.POST(publisher.build()).build();
         HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
@@ -426,8 +451,9 @@ public class OssConsoleClient {
         }
     }
 
-    public List<ImageUrlDto> getImageUrls(Set<String> imageFileIds) throws Exception {
-        String api = String.format("%s/api/oss/media/image/urls?imageFileIds=%s", endpoint, imageFileIds.toString());
+    public List<ImageUrlDto> getImageUrls(int channelId, Set<String> imageFileIds) throws Exception {
+        String imageFileIdsStr = imageFileIds.toString().replace("[", "").replace("]", "");
+        String api = String.format("%s/api/oss/media/image/urls?channelId=%s&imageFileIds=%s", endpoint, channelId, imageFileIdsStr);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
@@ -471,8 +497,11 @@ public class OssConsoleClient {
         }
     }
 
-    public VideoInfo getVideoInfo(String videoFileId) throws Exception {
-        String api = String.format("%s/api/oss/media/video/info/%s", endpoint, videoFileId);
+    // ****************************************************************************************************************
+    // 音频文件相关接口
+    // ****************************************************************************************************************
+    public AudioInfo getAudioInfo(String audioFileId) throws Exception {
+        String api = String.format("%s/api/oss/media/audio/info/%s", endpoint, audioFileId);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
@@ -486,8 +515,8 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<VideoInfo>>(){}.getType();
-        WebResult<VideoInfo> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<AudioInfo>>(){}.getType();
+        WebResult<AudioInfo> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
@@ -496,8 +525,8 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public List<VideoUrlDto> getVideoUrls(String videoFileId) throws Exception {
-        String api = String.format("%s/api/oss/media/video/url?videoFileId=%s", endpoint, videoFileId);
+    public List<AudioUrl> getAudioUrls(String audioFileId, int loginUser) throws Exception {
+        String api = String.format("%s/api/oss/media/audio/url?audioFileId=%s&userId=%s", endpoint, audioFileId, loginUser);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
@@ -511,8 +540,8 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<List<VideoUrlDto>>>(){}.getType();
-        WebResult<List<VideoUrlDto>> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<List<AudioUrl>>>(){}.getType();
+        WebResult<List<AudioUrl>> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
@@ -521,13 +550,25 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    @Deprecated
-    public LocalDateTime getCreateTime(String videoFileId) throws Exception {
-        String api = String.format("%s/api/oss/media/video/time/%s", endpoint, videoFileId);
+    // ****************************************************************************************************************
+    // 音视频转码相关接口
+    // ****************************************************************************************************************
+    public void convertAudio(String audioFileId) throws Exception {
+        String api = String.format("%s/api/oss/media/convert/audio/%s", endpoint, audioFileId);
+        convert(api);
+    }
+
+    public void convertVideo(String videoFileId) throws Exception {
+        String api = String.format("%s/api/oss/media/convert/video/%s", endpoint, videoFileId);
+        convert(api);
+    }
+
+    private void convert(String api) throws Exception {
+        MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)
-                .GET()
+                .POST(publisher.build())
                 .build();
         HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
         int statusCode = httpResponse.statusCode();
@@ -537,13 +578,11 @@ public class OssConsoleClient {
             throw new Exception(errMsg);
         }
 
-        Type type = new TypeToken<WebResult<LocalDateTime>>(){}.getType();
-        WebResult<LocalDateTime> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<String>>(){}.getType();
+        WebResult<String> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
             throw new Exception(errMsg);
         }
-
-        return webResult.getData();
     }
 }

+ 7 - 2
oss-sdk/src/test/java/ObjectTest.java

@@ -38,7 +38,12 @@ public class ObjectTest {
         String ossUrl = serverInfo.getOssUrl();
         String token = serverInfo.getToken();
 
-        OssStoreClient ossStoreClient = new OssStoreClient(ossUrl);
+        int scope = 1;
+        String objectId = "dafafafa";
+        int contentType = 1001;
+        ossConsoleClient.setObjectScope(scope, objectId, contentType);
+
+        /*OssStoreClient ossStoreClient = new OssStoreClient(ossUrl);
         String filePath = "/home/reghao/data/image/12.jpg";
         File file = new File(filePath);
         UploadFileRet uploadFileRet = ossStoreClient.postObjectWithJdkHttp(file, channelId, token);
@@ -46,7 +51,7 @@ public class ObjectTest {
             log.info("文件上传失败");
         } else {
             log.info("{} -> {}", uploadFileRet.getUploadId(), uploadFileRet.getUrl());
-        }
+        }*/
 
         /*String objectName = "video/playback/28d0fd95e224499c9f2cf1d98b4551a5.flv";
         ossStoreClient.getObject(objectName);*/

+ 2 - 1
oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectGetController.java

@@ -97,8 +97,9 @@ public class ObjectGetController {
         }*/
 
         OssPayload ossPayload = JwtUtil.getOssPayload(token, storeService.getSecretKey());
+        int loginUser = ossPayload.getUserId();
         int channelId = ossPayload.getChannelId();
-        ObjectChannel objectChannel = objectChannelService.getObjectChannel(channelId);
+        ObjectChannel objectChannel = objectChannelService.getObjectChannel(loginUser, channelId);
         if (objectChannel == null) {
             String payload = String.format("channel_id %s not exist", channelId);
             getObjectService.writeResponse(HttpServletResponse.SC_FORBIDDEN, payload);

+ 2 - 1
oss-store/src/main/java/cn/reghao/oss/store/controller/ObjectUploadController.java

@@ -78,7 +78,8 @@ public class ObjectUploadController {
                     .body(WebResult.failWithMsg("channel not match in token"));
         }
 
-        ObjectChannel objectChannel = objectChannelService.getObjectChannel(channelId);
+        int loginUser = ossPayload.getUserId();
+        ObjectChannel objectChannel = objectChannelService.getObjectChannel(loginUser, channelId);
         if (objectChannel == null) {
             String errMsg = String.format("channel validate failed, channel %s not exist", channelId);
             return ResponseEntity.status(HttpStatus.FORBIDDEN)

+ 2 - 1
oss-store/src/main/java/cn/reghao/oss/store/rpc/ObjectServiceImpl.java

@@ -51,10 +51,11 @@ public class ObjectServiceImpl implements ObjectService {
 
     @Override
     public DownloadUrl getDownloadUrl(String objectId, int expireSecond) {
+        int loginUser = 10001;
         FileMeta fileMeta = objectRepository.getByObjectId(objectId);
         String objectName = fileMeta.getObjectName();
         String url = objectNameService.getObjectUrl(objectName);
-        String signedUrl = signService.getSignedUrl(url, expireSecond);
+        String signedUrl = signService.getSignedUrl(loginUser, url, expireSecond);
         return new DownloadUrl(signedUrl, "");
     }
 

+ 3 - 3
oss-store/src/main/java/cn/reghao/oss/store/rpc/SignService.java

@@ -27,12 +27,12 @@ public class SignService {
         this.objectChannelService = objectChannelService;
     }
 
-    public String getSignedUrl(String url, int expire) {
-        int loginUser = UserContext.getUser();
+    public String getSignedUrl(int loginUser, String url, int expire) {
         long timestamp = System.currentTimeMillis() + expire*1000L;
         int channelId = objectChannelService.getChannelId(url);
 
-        String action = ChannelAction.download.getName();
+        String action1 = ChannelAction.download.getName();
+        String action = ChannelAction.access.getName();
         OssPayload ossPayload = new OssPayload(action, channelId, loginUser);
 
         String token = JwtUtil.createToken(ossPayload, timestamp, secretKey);

+ 2 - 1
oss-store/src/main/java/cn/reghao/oss/store/rpc/media/AudioFileServiceImpl.java

@@ -54,10 +54,11 @@ public class AudioFileServiceImpl implements AudioFileService {
 
     @Override
     public List<AudioUrl> getAudioUrls(String audioFileId, int expireSecond) {
+        int loginUser = 10001;
         List<AudioUrl> audioUrls = audioRepository.getAudioUrls(audioFileId);
         audioUrls.forEach(audioUrl -> {
             String url = audioUrl.getUrl();
-            String signedUrl = signService.getSignedUrl(url, expireSecond);
+            String signedUrl = signService.getSignedUrl(loginUser, url, expireSecond);
             audioUrl.setUrl(signedUrl);
         });
         return audioUrls;

+ 2 - 2
oss-store/src/main/java/cn/reghao/oss/store/rpc/media/VideoFileServiceImpl.java

@@ -68,11 +68,11 @@ public class VideoFileServiceImpl implements VideoFileService {
     }
 
     @Override
-    public List<VideoUrlDto> getVideoUrls(String videoFileId, int expireSecond) {
+    public List<VideoUrlDto> getVideoUrls(int loginUser, String videoFileId, int expireSecond) {
         List<VideoUrlDto> list = videoRepository.findVideoUrls(videoFileId);
         list.forEach(videoUrlDto -> {
             String url = videoUrlDto.getUrl();
-            String signedUrl = signService.getSignedUrl(url, expireSecond);
+            String signedUrl = signService.getSignedUrl(loginUser, url, expireSecond);
             videoUrlDto.setUrl(signedUrl);
         });
         return list;

+ 5 - 4
oss-store/src/main/java/cn/reghao/oss/store/service/ObjectChannelService.java

@@ -17,14 +17,15 @@ import java.util.stream.Collectors;
 public class ObjectChannelService {
     private final MachineId machineId;
     private final OssConsoleClient ossConsoleClient;
+    private final StoreService storeService;
 
-    public ObjectChannelService(MachineId machineId, OssConsoleClient ossConsoleClient) {
+    public ObjectChannelService(MachineId machineId, OssConsoleClient ossConsoleClient, StoreService storeService) {
         this.machineId = machineId;
         this.ossConsoleClient = ossConsoleClient;
+        this.storeService = storeService;
     }
 
-    public ObjectChannel getObjectChannel(int channelId) {
-        int loginUser = UserContext.getUser();
+    public ObjectChannel getObjectChannel(int loginUser, int channelId) {
         String nodeAddr = machineId.ipv4();
         try {
             return ossConsoleClient.getObjectChannel(loginUser, nodeAddr, channelId);
@@ -59,7 +60,7 @@ public class ObjectChannelService {
     }
 
     public ObjectChannel getObjectChannel(String url) {
-        String domain = "";
+        String domain = storeService.getDomain();
         String objectName = url.replace("//" + domain + "/", "");
         String nodeAddr = machineId.ipv4();
         try {

+ 1 - 1
store-api/src/main/java/cn/reghao/oss/store/api/iface/media/VideoFileService.java

@@ -14,6 +14,6 @@ public interface VideoFileService {
     void setVideoScope(int scope, String videoFileId);
     void deleteVideoFile(String videoFileId);
     VideoInfo getVideoInfo(String videoFileId);
-    List<VideoUrlDto> getVideoUrls(String videoFileId, int expireSecond);
+    List<VideoUrlDto> getVideoUrls(int loginUser, String videoFileId, int expireSecond);
     LocalDateTime getCreateTime(String videoFileId);
 }