reghao пре 1 година
родитељ
комит
8ca8e02ef9

+ 0 - 120
oss-console/src/main/java/cn/reghao/oss/console/app/controller/MediaController.java

@@ -1,120 +0,0 @@
-package cn.reghao.oss.console.app.controller;
-
-import cn.reghao.jutil.jdk.result.WebResult;
-import cn.reghao.oss.api.dto.ObjectInfo;
-import cn.reghao.oss.api.dto.ServerInfo;
-import cn.reghao.oss.api.iface.ConsoleService;
-import cn.reghao.oss.api.iface.StoreServiceWrapper;
-import cn.reghao.oss.api.util.AuthContext;
-import cn.reghao.oss.console.app.model.dto.GetImageUrls;
-import cn.reghao.oss.api.dto.media.*;
-import cn.reghao.oss.console.app.model.dto.ObjectsScopeDto;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2024-02-23 09:05:58
- */
-@Api(tags = "视频文件接口")
-@RestController
-@RequestMapping
-public class MediaController {
-    private final ConsoleService consoleService;
-    private final StoreServiceWrapper storeServiceWrapper;
-
-    public MediaController(ConsoleService consoleService, StoreServiceWrapper storeServiceWrapper) {
-        this.consoleService = consoleService;
-        this.storeServiceWrapper = storeServiceWrapper;
-    }
-
-    @ApiOperation(value = "获取 oss-store 节点")
-    @GetMapping(value = "/api/oss/server/info", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getServerInfo(@RequestParam("channelId") int channelId) throws Exception {
-        int loginUser = AuthContext.getUserId();
-        ServerInfo serverInfo = consoleService.getUploadStore(channelId, loginUser);
-        return WebResult.success(serverInfo);
-    }
-
-    @ApiOperation(value = "设置对象列表可见范围")
-    @PostMapping(value = "/api/oss/object/scope/objects", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String setObjectsScope(ObjectsScopeDto objectsScopeDto) throws Exception {
-        //storeServiceWrapper.setObjectsScope(objectsScopeDto);
-        return WebResult.success();
-    }
-
-    @ApiOperation(value = "根据 object_id 删除对象")
-    @PostMapping(value = "/api/oss/object/delete/ids", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deleteByObjects(@RequestParam("channelId") Integer channelId,
-                                  @RequestParam("objectIds") List<String> objectIds) throws Exception {
-        //storeServiceWrapper.deleteByObjectIds(channelId, objectIds);
-        return WebResult.success();
-    }
-
-    @ApiOperation(value = "根据 object_url 删除对象")
-    @PostMapping(value = "/api/oss/object/delete/url", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deleteByObjectUrl(@RequestParam("objectUrl") String objectUrl) throws Exception {
-        storeServiceWrapper.deleteByObjectUrl(objectUrl);
-        return WebResult.success();
-    }
-
-    // TODO 接口作废
-    @ApiOperation(value = "获取对象签名 url")
-    @GetMapping(value = "/api/oss/object/url", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getObjectUrl(@RequestParam("channelId") Integer channelId,
-                               @RequestParam("objectId") String objectId) throws Exception {
-        //String signedUrl = storeServiceWrapper.getSignedUrl(channelId, objectId);
-        return WebResult.success();
-    }
-
-    @ApiOperation(value = "获取对象信息")
-    @GetMapping(value = "/api/oss/object/info", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getObjectInfo(@RequestParam("channelId") int channelId,
-                                @RequestParam("objectId") String objectId) throws Exception {
-        ObjectInfo objectInfo = storeServiceWrapper.getObjectInfo(channelId, objectId);
-        return WebResult.success(objectInfo);
-    }
-
-    @ApiOperation(value = "获取视频文件信息")
-    @GetMapping(value = "/api/oss/media/video/info", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getVideoInfo(@RequestParam("channelId") Integer channelId,
-                               @RequestParam("videoFileId") String videoFileId) throws Exception {
-        VideoInfo videoInfo = storeServiceWrapper.getVideoInfo(channelId, videoFileId);
-        return WebResult.success(videoInfo);
-    }
-
-    @ApiOperation(value = "获取图片文件信息")
-    @PostMapping(value = "/api/oss/media/image/info", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getImagesInfo(GetImageUrls getImageUrls) throws Exception {
-        //ImageInfo imageInfo = storeServiceWrapper.getImageInfo(getImageUrls.getChannelId(), getImageUrls.getImageFileIds());
-        return WebResult.success();
-    }
-
-    @ApiOperation(value = "获取 webp 图片文件信息")
-    @PostMapping(value = "/api/oss/media/image/webp", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getWebpInfo(GetImageUrls getImageUrls) throws Exception {
-        //List<ConvertedImageInfo> list = storeServiceWrapper.getWebpInfo(getImageUrls.getChannelId(), getImageUrls.getImageFileIds());
-        return WebResult.success();
-    }
-
-    @ApiOperation(value = "获取音频文件信息")
-    @GetMapping(value = "/api/oss/media/auduio/info", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getAudioInfo(@RequestParam("channelId") Integer channelId,
-                               @RequestParam("audioFileId") String audioFileId) throws Exception {
-        AudioInfo audioInfo = storeServiceWrapper.getAudioInfo(channelId, audioFileId);
-        return WebResult.success(audioInfo);
-    }
-
-    @ApiOperation(value = "获取对象签名 url")
-    @GetMapping(value = "/api/oss/media/url", produces = MediaType.APPLICATION_JSON_VALUE)
-    @Deprecated
-    public String getObjectUrl1(@RequestParam("channelId") Integer channelId,
-                               @RequestParam("objectId") String objectId) throws Exception {
-        String signedUrl = storeServiceWrapper.getSignedUrl(channelId, objectId);
-        return WebResult.success(signedUrl);
-    }
-}

+ 115 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/controller/OssController.java

@@ -0,0 +1,115 @@
+package cn.reghao.oss.console.app.controller;
+
+import cn.reghao.jutil.jdk.result.WebResult;
+import cn.reghao.oss.api.dto.ObjectInfo;
+import cn.reghao.oss.api.dto.ServerInfo;
+import cn.reghao.oss.api.iface.ConsoleService;
+import cn.reghao.oss.api.iface.StoreServiceWrapper;
+import cn.reghao.oss.api.util.AuthContext;
+import cn.reghao.oss.api.dto.media.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author reghao
+ * @date 2024-02-23 09:05:58
+ */
+@Api(tags = "视频文件接口")
+@RestController
+@RequestMapping("/api/oss")
+public class OssController {
+    private final ConsoleService consoleService;
+    private final StoreServiceWrapper storeServiceWrapper;
+
+    public OssController(ConsoleService consoleService, StoreServiceWrapper storeServiceWrapper) {
+        this.consoleService = consoleService;
+        this.storeServiceWrapper = storeServiceWrapper;
+    }
+
+    @ApiOperation(value = "获取 oss-store 节点")
+    @GetMapping(value = "/upload/store", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getUploadStore(@RequestParam("channelId") int channelId) {
+        int loginUser = AuthContext.getUserId();
+        ServerInfo serverInfo = consoleService.getUploadStore(channelId, loginUser);
+        return WebResult.success(serverInfo);
+    }
+
+    @ApiOperation(value = "获取 channel 可见范围")
+    @PostMapping(value = "/channel/scope", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getChannelScope(int channelId) throws Exception {
+        int scope = storeServiceWrapper.getChannelScope(channelId);
+        return WebResult.success(scope);
+    }
+
+    @ApiOperation(value = "设置对象可见范围")
+    @PostMapping(value = "/object/scope", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String setObjectScope(int channelId, String objectId, int scope) {
+        storeServiceWrapper.setObjectScope(channelId, objectId, scope);
+        return WebResult.success();
+    }
+
+    @ApiOperation(value = "根据 object_id 删除对象")
+    @PostMapping(value = "/object/delete/id", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String deleteByObjectId(@RequestParam("channelId") int channelId,
+                                   @RequestParam("objectId") String objectId) {
+        storeServiceWrapper.deleteByObjectId(channelId, objectId);
+        return WebResult.success();
+    }
+
+    @ApiOperation(value = "根据 object_url 删除对象")
+    @PostMapping(value = "/object/delete/url", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String deleteByObjectUrl(@RequestParam("objectUrl") String objectUrl) {
+        storeServiceWrapper.deleteByObjectUrl(objectUrl);
+        return WebResult.success();
+    }
+
+    @ApiOperation(value = "获取对象信息")
+    @GetMapping(value = "/object/info", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getObjectInfo(@RequestParam("channelId") int channelId,
+                                @RequestParam("objectId") String objectId) throws Exception {
+        ObjectInfo objectInfo = storeServiceWrapper.getObjectInfo(channelId, objectId);
+        return WebResult.success(objectInfo);
+    }
+
+    @ApiOperation(value = "获取对象签名 url")
+    @GetMapping(value = "/object/url", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getSignedUrl(@RequestParam("channelId") Integer channelId,
+                               @RequestParam("objectId") String objectId) throws Exception {
+        String signedUrl = storeServiceWrapper.getSignedUrl(channelId, objectId);
+        return WebResult.success(signedUrl);
+    }
+
+    @ApiOperation(value = "获取视频文件信息")
+    @GetMapping(value = "/object/video/info", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getVideoInfo(@RequestParam("channelId") Integer channelId,
+                               @RequestParam("objectId") String objectId) throws Exception {
+        VideoInfo videoInfo = storeServiceWrapper.getVideoInfo(channelId, objectId);
+        return WebResult.success(videoInfo);
+    }
+
+    @ApiOperation(value = "获取图片文件信息")
+    @GetMapping(value = "/object/image/info", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getImagesInfo(@RequestParam("channelId") Integer channelId,
+                                @RequestParam("objectId") String objectId) throws Exception {
+        ImageInfo imageInfo = storeServiceWrapper.getImageInfo(channelId, objectId);
+        return WebResult.success(imageInfo);
+    }
+
+    @ApiOperation(value = "获取 webp 图片文件信息")
+    @PostMapping(value = "/object/image/webp", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getWebpInfo(@RequestParam("channelId") Integer channelId,
+                              @RequestParam("objectId") String objectId) throws Exception {
+        ConvertedImageInfo convertedImageInfo = storeServiceWrapper.getWebpInfo(channelId, objectId);
+        return WebResult.success(convertedImageInfo);
+    }
+
+    @ApiOperation(value = "获取音频文件信息")
+    @GetMapping(value = "/media/audio/info", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String getAudioInfo(@RequestParam("channelId") Integer channelId,
+                               @RequestParam("objectId") String objectId) throws Exception {
+        AudioInfo audioInfo = storeServiceWrapper.getAudioInfo(channelId, objectId);
+        return WebResult.success(audioInfo);
+    }
+}

+ 0 - 17
oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/GetImageUrls.java

@@ -1,17 +0,0 @@
-package cn.reghao.oss.console.app.model.dto;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2024-03-01 16:02:57
- */
-@Setter
-@Getter
-public class GetImageUrls {
-    private Integer channelId;
-    private List<String> imageFileIds;
-}

+ 0 - 19
oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/ObjectsScopeDto.java

@@ -1,19 +0,0 @@
-package cn.reghao.oss.console.app.model.dto;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2024-03-01 13:32:25
- */
-@Setter
-@Getter
-@Deprecated
-public class ObjectsScopeDto {
-    private Integer channelId;
-    private Integer scope;
-    private List<String> objectIds;
-}

+ 1 - 1
oss-console/src/main/java/cn/reghao/oss/console/config/web/ConsoleAuthInterceptor.java

@@ -32,7 +32,7 @@ public class ConsoleAuthInterceptor implements HandlerInterceptor {
         String uri = request.getRequestURI();
         String method = request.getMethod();
         if (uri.startsWith("/api/oss/") && !method.equalsIgnoreCase("options")) {
-            if (uri.startsWith("/api/oss/store") || uri.equals("/api/oss/key/auth")) {
+            if (uri.equals("/api/oss/key/auth")) {
                 return true;
             }