Explorar el Código

update ObjectController

reghao hace 2 años
padre
commit
c8de260b27

+ 6 - 12
oss-console/src/main/java/cn/reghao/oss/console/app/controller/ObjectController.java

@@ -2,7 +2,6 @@ package cn.reghao.oss.console.app.controller;
 
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.oss.console.app.model.dto.ObjectsScopeDto;
-import cn.reghao.oss.console.app.model.dto.SetScopeDto;
 import cn.reghao.oss.console.app.rpc.OssObjectService;
 import cn.reghao.oss.store.api.dto.DownloadUrl;
 import cn.reghao.oss.store.api.dto.ObjectInfo;
@@ -27,12 +26,6 @@ public class ObjectController {
         this.ossObjectService = ossObjectService;
     }
 
-    @ApiOperation(value = "设置对象可见范围")
-    @PostMapping(value = "/scope/object", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String setObjectScope(SetScopeDto setScopeDto) {
-        return WebResult.success();
-    }
-
     @ApiOperation(value = "设置对象列表可见范围")
     @PostMapping(value = "/scope/objects", produces = MediaType.APPLICATION_JSON_VALUE)
     public String setObjectsScope(ObjectsScopeDto objectsScopeDto) throws Exception {
@@ -40,17 +33,18 @@ public class ObjectController {
         return WebResult.success();
     }
 
-    @ApiOperation(value = "根据 object_name 删除图片文件")
+    @ApiOperation(value = "根据 object_name 删除对象")
     @PostMapping(value = "/delete/name", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deleteByObjectNames(@RequestParam("objectNames") List<String> objectNames) throws Exception {
-        ossObjectService.deleteByObjectNames(objectNames);
+    public String deleteByObjectNames(@RequestParam("channelId") Integer channelId,
+                                      @RequestParam("objectNames") List<String> objectNames) throws Exception {
+        ossObjectService.deleteByObjectNames(channelId, objectNames);
         return WebResult.success();
     }
 
     @ApiOperation(value = "获取对象 url")
     @GetMapping(value = "/url", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String getObjectUrl(@RequestParam("objectId") String objectId) {
-        DownloadUrl downloadUrl = ossObjectService.getDownloadUrl(objectId);
+    public String getObjectUrl(@RequestParam("channelId") Integer channelId, @RequestParam("objectId") String objectId) throws Exception {
+        DownloadUrl downloadUrl = ossObjectService.getDownloadUrl(channelId, objectId);
         return WebResult.success(downloadUrl);
     }
 

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

@@ -1,16 +0,0 @@
-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;
-}

+ 8 - 18
oss-console/src/main/java/cn/reghao/oss/console/app/rpc/OssObjectService.java

@@ -1,7 +1,6 @@
 package cn.reghao.oss.console.app.rpc;
 
 import cn.reghao.oss.console.app.model.dto.ObjectsScopeDto;
-import cn.reghao.oss.console.app.model.dto.SetScopeDto;
 import cn.reghao.oss.console.app.model.po.StoreNode;
 import cn.reghao.oss.console.app.service.UploadChannelService;
 import cn.reghao.oss.console.util.AuthKeyContext;
@@ -18,16 +17,12 @@ import java.util.List;
  */
 @Service
 public class OssObjectService {
-    private ObjectService objectService;
     private final UploadChannelService uploadChannelService;
 
     public OssObjectService(UploadChannelService uploadChannelService) {
         this.uploadChannelService = uploadChannelService;
     }
 
-    public void setObjectScope(SetScopeDto setScopeDto) {
-    }
-
     public void setObjectsScope(ObjectsScopeDto objectsScopeDto) throws Exception {
         int channelId = objectsScopeDto.getChannelId();
         ObjectService objectService = getObjectService(channelId);
@@ -36,28 +31,23 @@ public class OssObjectService {
         objectService.setObjectsScope(scope, objectNames);
     }
 
-    public void deleteByObjectNames(List<String> objectNames) {
-        RemoteService<ObjectService> remoteService = new RemoteService<>();
-        String host = "";
-        int port = -1;
-        ObjectService objectService = remoteService.getService(host, port, ObjectService.class);
+    public void deleteByObjectNames(int channelId, List<String> objectNames) throws Exception {
+        ObjectService objectService = getObjectService(channelId);
         objectService.deleteByObjectNames(objectNames);
     }
 
-    public ObjectInfo getObjectInfo(int channelId, String objectId) throws Exception {
+    public DownloadUrl getDownloadUrl(int channelId, String objectId) throws Exception {
         ObjectService objectService = getObjectService(channelId);
         int loginUser = AuthKeyContext.getUser();
         int expireSecond = 3600;
-        return objectService.getObjectInfo(loginUser, objectId, expireSecond);
+        return objectService.getDownloadUrl(loginUser, objectId, expireSecond);
     }
 
-    public DownloadUrl getDownloadUrl(String objectId) {
+    public ObjectInfo getObjectInfo(int channelId, String objectId) throws Exception {
+        ObjectService objectService = getObjectService(channelId);
+        int loginUser = AuthKeyContext.getUser();
         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);
+        return objectService.getObjectInfo(loginUser, objectId, expireSecond);
     }
 
     private ObjectService getObjectService(int channelId) throws Exception {