Ver Fonte

oss-api 添加 ObjectChannelService rpc 接口, 专用于处理 UploadChannel 的 CRUD

reghao há 1 ano atrás
pai
commit
3d2f1366bc

+ 5 - 2
oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/ChannelScopeDto.java → oss-api/src/main/java/cn/reghao/oss/api/dto/ChannelScopeDto.java

@@ -1,10 +1,11 @@
-package cn.reghao.oss.console.app.model.dto;
+package cn.reghao.oss.api.dto;
 
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 
 /**
  * @author reghao
@@ -13,7 +14,9 @@ import javax.validation.constraints.NotNull;
 @NoArgsConstructor
 @Setter
 @Getter
-public class ChannelScopeDto {
+public class ChannelScopeDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     @NotNull
     private Integer id;
     @NotNull

+ 1 - 0
oss-api/src/main/java/cn/reghao/oss/api/dto/ObjectChannel.java

@@ -14,6 +14,7 @@ import java.io.Serializable;
 public class ObjectChannel implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Integer id;
     private Integer channelId;
     private String prefix;
     private Long maxSize;

+ 5 - 3
oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/UploadChannelDto.java → oss-api/src/main/java/cn/reghao/oss/api/dto/UploadChannelDto.java

@@ -1,17 +1,19 @@
-package cn.reghao.oss.console.app.model.dto;
+package cn.reghao.oss.api.dto;
 
 import lombok.Data;
-import org.hibernate.validator.constraints.Length;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 
 /**
  * @author reghao
  * @date 2021-06-03 16:15:23
  */
 @Data
-public class UploadChannelDto {
+public class UploadChannelDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     @NotNull
     private Integer nodeId;
     @NotBlank

+ 25 - 0
oss-api/src/main/java/cn/reghao/oss/api/dto/UploadChannelVo.java

@@ -0,0 +1,25 @@
+package cn.reghao.oss.api.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.io.Serializable;
+
+/**
+ * @author reghao
+ * @date 2024-02-28 13:16:02
+ */
+@AllArgsConstructor
+@Getter
+public class UploadChannelVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private int id;
+    private int channelId;
+    private String prefix;
+    private String maxSize;
+    private String fileType;
+    private boolean seturl;
+    private String scope;
+    private String bindDomain;
+}

+ 6 - 2
oss-console/src/main/java/cn/reghao/oss/console/app/model/vo/UserNodeVO.java → oss-api/src/main/java/cn/reghao/oss/api/dto/UserNodeVO.java

@@ -1,15 +1,19 @@
-package cn.reghao.oss.console.app.model.vo;
+package cn.reghao.oss.api.dto;
 
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
+import java.io.Serializable;
+
 /**
  * @author reghao
  * @date 2024-07-02 16:18:14
  */
 @AllArgsConstructor
 @Getter
-public class UserNodeVO {
+public class UserNodeVO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
     private int id;
     private int nodeId;
     private String nodeAddr;

+ 18 - 0
oss-api/src/main/java/cn/reghao/oss/api/iface/ObjectChannelService.java

@@ -0,0 +1,18 @@
+package cn.reghao.oss.api.iface;
+
+import cn.reghao.jutil.jdk.result.Result;
+import cn.reghao.oss.api.dto.*;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2024-07-12 22:16:31
+ */
+public interface ObjectChannelService {
+    Result addObjectChannel(UploadChannelDto uploadChannelDto);
+    void updateScope(ChannelScopeDto channelScopeDto);
+    List<UploadChannelVo> getObjectChannels(int createBy);
+    ObjectChannel getObjectChannel(int id);
+    List<UserNodeVO> getUserStoreNodes(int createBy);
+}

+ 8 - 12
oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/UploadChannelController.java

@@ -2,11 +2,9 @@ package cn.reghao.oss.console.app.controller.page;
 
 import cn.reghao.jutil.jdk.result.Result;
 import cn.reghao.jutil.jdk.result.WebResult;
-import cn.reghao.oss.console.app.model.dto.ChannelProcessDto;
-import cn.reghao.oss.console.app.model.dto.ChannelScopeDto;
-import cn.reghao.oss.console.app.model.dto.UploadChannelDto;
-import cn.reghao.oss.console.app.service.StoreChannelService;
-import cn.reghao.oss.console.app.service.UploadChannelService;
+import cn.reghao.oss.api.dto.ChannelScopeDto;
+import cn.reghao.oss.api.dto.UploadChannelDto;
+import cn.reghao.oss.console.app.service.ObjectChannelServiceImpl;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -23,25 +21,23 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/api/store/channel")
 public class UploadChannelController {
-    private final UploadChannelService uploadChannelService;
-    private final StoreChannelService storeChannelService;
+    private final ObjectChannelServiceImpl objectChannelService;
 
-    public UploadChannelController(UploadChannelService uploadChannelService, StoreChannelService storeChannelService) {
-        this.uploadChannelService = uploadChannelService;
-        this.storeChannelService = storeChannelService;
+    public UploadChannelController(ObjectChannelServiceImpl objectChannelService) {
+        this.objectChannelService = objectChannelService;
     }
 
     @ApiOperation(value = "添加上传通道")
     @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
     public String addUploadChannel(@Validated UploadChannelDto uploadChannelDto) {
-        Result result = storeChannelService.add(uploadChannelDto);
+        Result result = objectChannelService.addObjectChannel(uploadChannelDto);
         return WebResult.result(result);
     }
 
     @ApiOperation(value = "修改通道可见范围")
     @PostMapping(value = "/update/scope", produces = MediaType.APPLICATION_JSON_VALUE)
     public String updateChannelScope(@Validated ChannelScopeDto channelScopeDto) {
-        uploadChannelService.updateScope(channelScopeDto);
+        objectChannelService.updateScope(channelScopeDto);
         return WebResult.success();
     }
 }

+ 11 - 21
oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/UploadChannelPageController.java

@@ -2,13 +2,12 @@ package cn.reghao.oss.console.app.controller.page;
 
 import cn.reghao.oss.api.constant.ObjectScope;
 import cn.reghao.oss.api.constant.ObjectType;
+import cn.reghao.oss.api.dto.ObjectChannel;
+import cn.reghao.oss.api.iface.ObjectChannelService;
 import cn.reghao.oss.console.account.service.UserContext;
-import cn.reghao.oss.console.app.model.po.UploadChannel;
 import cn.reghao.oss.console.app.model.vo.KeyValue;
-import cn.reghao.oss.console.app.model.vo.UploadChannelVo;
-import cn.reghao.oss.console.app.model.vo.UserNodeVO;
-import cn.reghao.oss.console.app.service.UploadChannelService;
-import cn.reghao.oss.console.app.service.UserNodeService;
+import cn.reghao.oss.api.dto.UploadChannelVo;
+import cn.reghao.oss.api.dto.UserNodeVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -27,12 +26,10 @@ import java.util.*;
 @Controller
 @RequestMapping("/store/channel")
 public class UploadChannelPageController {
-    private final UploadChannelService uploadChannelService;
-    private final UserNodeService userNodeService;
+    private final ObjectChannelService objectChannelService;
 
-    public UploadChannelPageController(UploadChannelService uploadChannelService, UserNodeService userNodeService) {
-        this.uploadChannelService = uploadChannelService;
-        this.userNodeService = userNodeService;
+    public UploadChannelPageController(ObjectChannelService objectChannelService) {
+        this.objectChannelService = objectChannelService;
     }
 
     @ApiOperation(value = "上传通道列表页面")
@@ -40,15 +37,8 @@ public class UploadChannelPageController {
     public String index(@RequestParam(value = "env", required = false) String env,
                         @RequestParam(value = "type", required = false) String type,
                         @RequestParam(value = "appName", required = false) String appName, Model model) throws Exception {
-        /*PageRequest pageRequest = PageSort.pageRequest();
-        int pageNumber = pageRequest.getPageNumber();
-        int pageSize = pageRequest.getPageSize();*/
-
-        /*Sort sort = Sort.by(Sort.Direction.ASC, "channelId");
-        PageRequest pageRequest1 = PageRequest.of(pageNumber, pageSize, sort);*/
         int loginUser = UserContext.getUserId();
-        List<UploadChannelVo> list = uploadChannelService.getUploadChannels(loginUser);
-        //model.addAttribute("page", page);
+        List<UploadChannelVo> list = objectChannelService.getObjectChannels(loginUser);
         model.addAttribute("list", list);
         return "/channel/index";
     }
@@ -78,7 +68,7 @@ public class UploadChannelPageController {
         sizeList.add(new KeyValue(1024L*1024*1024*20+"", "20GB"));
 
         int loginUser = UserContext.getUserId();
-        List<UserNodeVO> storeNodes = userNodeService.getUserStoreNodes(loginUser);
+        List<UserNodeVO> storeNodes = objectChannelService.getUserStoreNodes(loginUser);
 
         model.addAttribute("objectTypes", objectTypes);
         model.addAttribute("objectScopes", objectScopes);
@@ -90,8 +80,8 @@ public class UploadChannelPageController {
     @ApiOperation(value = "修改通道可见范围")
     @GetMapping("/edit/{id}")
     public String editChannelScopePage(@PathVariable("id") Integer id, Model model) {
-        UploadChannel uploadChannel = uploadChannelService.getUploadChannel(id);
-        int scope = uploadChannel.getScope();
+        ObjectChannel objectChannel = objectChannelService.getObjectChannel(id);
+        int scope = objectChannel.getScope();
         ObjectScope objectScope0 = ObjectScope.getByCode(scope);
 
         List<KeyValue> objectScopes = new ArrayList<>();

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

@@ -2,7 +2,7 @@ package cn.reghao.oss.console.app.controller.page;
 
 import cn.reghao.oss.console.account.service.UserContext;
 import cn.reghao.oss.console.app.model.vo.KeyValue;
-import cn.reghao.oss.console.app.model.vo.UserNodeVO;
+import cn.reghao.oss.api.dto.UserNodeVO;
 import cn.reghao.oss.console.app.service.StoreNodeService;
 import cn.reghao.oss.console.app.service.UserNodeService;
 import io.swagger.annotations.Api;

+ 1 - 2
oss-console/src/main/java/cn/reghao/oss/console/app/model/po/UploadChannel.java

@@ -1,12 +1,11 @@
 package cn.reghao.oss.console.app.model.po;
 
-import cn.reghao.oss.console.app.model.dto.UploadChannelDto;
+import cn.reghao.oss.api.dto.UploadChannelDto;
 import cn.reghao.oss.console.util.db.BaseEntity;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
-import javax.persistence.Column;
 import javax.persistence.Entity;
 
 /**

+ 0 - 33
oss-console/src/main/java/cn/reghao/oss/console/app/model/vo/UploadChannelVo.java

@@ -1,33 +0,0 @@
-package cn.reghao.oss.console.app.model.vo;
-
-import cn.reghao.oss.api.constant.ObjectScope;
-import cn.reghao.oss.api.constant.ObjectType;
-import cn.reghao.oss.console.app.model.po.UploadChannel;
-import lombok.Getter;
-
-/**
- * @author reghao
- * @date 2024-02-28 13:16:02
- */
-@Getter
-public class UploadChannelVo {
-    private int id;
-    private int channelId;
-    private String prefix;
-    private String maxSize;
-    private String fileType;
-    private boolean seturl;
-    private String scope;
-    private String bindDomain;
-
-    public UploadChannelVo(UploadChannel uploadChannel, String maxSize, String bindDomain) {
-        this.id = uploadChannel.getId();
-        this.channelId = uploadChannel.getChannelId();
-        this.prefix = uploadChannel.getPrefix();
-        this.maxSize = maxSize;
-        this.fileType = ObjectType.getDescByCode(uploadChannel.getFileType());
-        this.seturl = uploadChannel.getSeturl();
-        this.scope = ObjectScope.getByCode(uploadChannel.getScope()).name();
-        this.bindDomain = bindDomain;
-    }
-}

+ 145 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/service/ObjectChannelServiceImpl.java

@@ -0,0 +1,145 @@
+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.api.constant.ObjectScope;
+import cn.reghao.oss.api.constant.ObjectType;
+import cn.reghao.oss.api.dto.ObjectChannel;
+import cn.reghao.oss.api.iface.ObjectChannelService;
+import cn.reghao.oss.api.iface.StoreServiceWrapper;
+import cn.reghao.oss.console.account.service.UserContext;
+import cn.reghao.oss.console.app.db.repository.StoreNodeRepository;
+import cn.reghao.oss.console.app.db.repository.UploadChannelRepository;
+import cn.reghao.oss.api.dto.ChannelScopeDto;
+import cn.reghao.oss.api.dto.UploadChannelDto;
+import cn.reghao.oss.console.app.db.repository.UserNodeRepository;
+import cn.reghao.oss.console.app.model.po.StoreNode;
+import cn.reghao.oss.console.app.model.po.UploadChannel;
+import cn.reghao.oss.console.app.model.po.UserNode;
+import cn.reghao.oss.api.dto.UploadChannelVo;
+import cn.reghao.oss.api.dto.UserNodeVO;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2024-02-23 15:14:53
+ */
+@Service
+public class ObjectChannelServiceImpl implements ObjectChannelService {
+    private final ByteConverter byteConverter = new ByteConverter();
+    private final UploadChannelRepository uploadChannelRepository;
+    private final UserNodeRepository userNodeRepository;
+    private final StoreNodeRepository storeNodeRepository;
+    private final StoreServiceWrapper storeServiceWrapper;
+
+    public ObjectChannelServiceImpl(UploadChannelRepository uploadChannelRepository, UserNodeRepository userNodeRepository,
+                                    StoreNodeRepository storeNodeRepository, StoreServiceWrapper storeServiceWrapper) {
+        this.uploadChannelRepository = uploadChannelRepository;
+        this.userNodeRepository = userNodeRepository;
+        this.storeNodeRepository = storeNodeRepository;
+        this.storeServiceWrapper = storeServiceWrapper;
+    }
+
+    @Override
+    public synchronized Result addObjectChannel(UploadChannelDto uploadChannelDto) {
+        int createBy = UserContext.getUserId();
+        int nodeId = uploadChannelDto.getNodeId();
+        UserNode userNode = userNodeRepository.findByCreateByAndNodeId(createBy, nodeId);
+        if (userNode == null) {
+            return Result.fail(String.format("store_node with id %s not exist", nodeId));
+        }
+
+        String channelPrefix = uploadChannelDto.getChannelPrefix();
+        UploadChannel uploadChannel = uploadChannelRepository.findByCreateByAndPrefix(createBy, channelPrefix);
+        if (uploadChannel != null) {
+            return Result.fail(String.format("channel_prefix %s exist", channelPrefix));
+        }
+
+        int channelId = getNextChannelId(createBy, nodeId);
+        uploadChannel = new UploadChannel(channelId, uploadChannelDto, createBy);
+        uploadChannelRepository.save(uploadChannel);
+        storeServiceWrapper.createChannel(channelId, channelPrefix);
+        return Result.success();
+    }
+
+    private int getNextChannelId(int createBy, int nodeId) {
+        int channelId = 101;
+        int total = uploadChannelRepository.countByCreateBy(createBy);
+        return channelId + total;
+    }
+
+    @Override
+    public void updateScope(ChannelScopeDto channelScopeDto) {
+        int id = channelScopeDto.getId();
+        int newScope = channelScopeDto.getNewScope();
+        UploadChannel uploadChannel = uploadChannelRepository.findById(id);
+        if (uploadChannel != null) {
+            int currentScope = uploadChannel.getScope();
+            if (currentScope != newScope) {
+                uploadChannel.setScope(newScope);
+                uploadChannelRepository.save(uploadChannel);
+            }
+        }
+    }
+
+    @Override
+    public List<UploadChannelVo> getObjectChannels(int createBy) {
+        List<UploadChannel> page = uploadChannelRepository.findByCreateBy(createBy);
+        List<UploadChannelVo> list = page.stream().map(uploadChannel -> {
+            long maxSize = uploadChannel.getMaxSize();
+            String maxSizeStr = byteConverter.convert(ByteType.Bytes, maxSize);
+            int nodeId = uploadChannel.getNodeId();
+            UserNode userNode = userNodeRepository.findByCreateByAndNodeId(createBy, nodeId);
+            String bindDomain = userNode.getDomain();
+            int id = uploadChannel.getId();
+            int channelId = uploadChannel.getChannelId();
+            String prefix = uploadChannel.getPrefix();
+            String fileTypeStr = ObjectType.getDescByCode(uploadChannel.getFileType());
+            boolean seturl = uploadChannel.getSeturl();
+            String scopeStr = ObjectScope.getByCode(uploadChannel.getScope()).name();
+            return new UploadChannelVo(id, channelId, prefix, maxSizeStr, fileTypeStr, seturl, scopeStr, bindDomain);
+        }).collect(Collectors.toList());
+
+        return list;
+    }
+
+    @Override
+    public ObjectChannel getObjectChannel(int id) {
+        UploadChannel uploadChannel = uploadChannelRepository.findById(id);
+        return uploadChannel != null ? getObjectChannel(uploadChannel) : null;
+    }
+
+    private ObjectChannel getObjectChannel(UploadChannel uploadChannel) {
+        int id = uploadChannel.getId();
+        int channelId = uploadChannel.getChannelId();
+        String channelPrefix = uploadChannel.getPrefix();
+        long maxSize = uploadChannel.getMaxSize();
+        int fileType = uploadChannel.getFileType();
+        boolean seturl = uploadChannel.getSeturl();
+        int scope = uploadChannel.getScope();
+        int createBy = uploadChannel.getCreateBy();
+
+        UserNode userNode = userNodeRepository.findByCreateByAndNodeId(createBy, uploadChannel.getNodeId());
+        String domain = userNode.getDomain();
+        return new ObjectChannel(id, channelId, channelPrefix, maxSize, fileType, seturl, scope, domain, createBy);
+    }
+
+    @Override
+    public List<UserNodeVO> getUserStoreNodes(int loginUser) {
+        List<UserNode> list = userNodeRepository.findByCreateBy(loginUser);
+        List<UserNodeVO> storeNodes = list.stream()
+                .map(userNode -> {
+                    int nodeId = userNode.getNodeId();
+                    StoreNode storeNode = storeNodeRepository.findById(nodeId);
+                    String nodeAddr = storeNode.getNodeAddr();
+                    String domain = userNode.getDomain();
+                    return new UserNodeVO(nodeId, nodeId, nodeAddr, domain);
+                })
+                .collect(Collectors.toList());
+        return storeNodes;
+    }
+}

+ 3 - 4
oss-console/src/main/java/cn/reghao/oss/console/app/service/StoreChannelService.java

@@ -9,7 +9,7 @@ import cn.reghao.oss.api.iface.StoreServiceWrapper;
 import cn.reghao.oss.console.account.service.UserContext;
 import cn.reghao.oss.console.app.db.repository.StoreNodeRepository;
 import cn.reghao.oss.console.app.db.repository.UploadChannelRepository;
-import cn.reghao.oss.console.app.model.dto.UploadChannelDto;
+import cn.reghao.oss.api.dto.UploadChannelDto;
 import cn.reghao.oss.console.app.model.po.StoreDisk;
 import cn.reghao.oss.console.app.model.po.StoreNode;
 import cn.reghao.oss.console.app.model.po.UploadChannel;
@@ -17,7 +17,6 @@ import cn.reghao.oss.console.app.model.po.UserNode;
 import cn.reghao.oss.console.app.model.vo.StoreDiskVO;
 import cn.reghao.oss.console.app.model.vo.StoreNodeVO;
 import cn.reghao.oss.console.app.rpc.RpcService;
-import cn.reghao.oss.console.app.rpc.StoreServiceWrapperImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -62,9 +61,9 @@ public class StoreChannelService {
         }
 
         int channelId = getNextChannelId(createBy, nodeId);
-        uploadChannel = new UploadChannel(channelId, uploadChannelDto, createBy);
+        /*uploadChannel = new UploadChannel(channelId, uploadChannelDto, createBy);
         uploadChannelRepository.save(uploadChannel);
-        storeServiceWrapper.createChannel(channelId, channelPrefix);
+        storeServiceWrapper.createChannel(channelId, channelPrefix);*/
         return Result.success();
     }
 

+ 2 - 39
oss-console/src/main/java/cn/reghao/oss/console/app/service/UploadChannelService.java

@@ -1,18 +1,13 @@
 package cn.reghao.oss.console.app.service;
 
-import cn.reghao.jutil.jdk.converter.ByteConverter;
-import cn.reghao.jutil.jdk.converter.ByteType;
 import cn.reghao.oss.api.dto.ObjectChannel;
 import cn.reghao.oss.console.app.db.repository.UploadChannelRepository;
-import cn.reghao.oss.console.app.model.dto.ChannelScopeDto;
 import cn.reghao.oss.console.app.model.po.StoreNode;
 import cn.reghao.oss.console.app.model.po.UploadChannel;
 import cn.reghao.oss.console.app.model.po.UserNode;
-import cn.reghao.oss.console.app.model.vo.UploadChannelVo;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * @author reghao
@@ -20,7 +15,6 @@ import java.util.stream.Collectors;
  */
 @Service
 public class UploadChannelService {
-    private final ByteConverter byteConverter = new ByteConverter();
     private final UploadChannelRepository uploadChannelRepository;
     private final UserNodeService userNodeService;
 
@@ -29,41 +23,10 @@ public class UploadChannelService {
         this.userNodeService = userNodeService;
     }
 
-    public void updateScope(ChannelScopeDto channelScopeDto) {
-        int id = channelScopeDto.getId();
-        int newScope = channelScopeDto.getNewScope();
-        UploadChannel uploadChannel = uploadChannelRepository.findById(id);
-        if (uploadChannel != null) {
-            int currentScope = uploadChannel.getScope();
-            if (currentScope != newScope) {
-                uploadChannel.setScope(newScope);
-                uploadChannelRepository.save(uploadChannel);
-            }
-        }
-    }
-
-    public List<UploadChannelVo> getUploadChannels(int createBy) {
-        List<UploadChannel> page = uploadChannelRepository.findByCreateBy(createBy);
-        List<UploadChannelVo> list = page.stream().map(uploadChannel -> {
-            long maxSize = uploadChannel.getMaxSize();
-            String maxSizeStr = byteConverter.convert(ByteType.Bytes, maxSize);
-            int nodeId = uploadChannel.getNodeId();
-            UserNode userNode = userNodeService.getUserNode(nodeId, createBy);
-            String bindDomain = userNode.getDomain();
-            return new UploadChannelVo(uploadChannel, maxSizeStr, bindDomain);
-        }).collect(Collectors.toList());
-
-        return list;
-    }
-
     public List<UploadChannel> getUploadChannelsByCreateBy(int createBy) {
         return uploadChannelRepository.findByCreateBy(createBy);
     }
 
-    public UploadChannel getUploadChannel(int id) {
-        return uploadChannelRepository.findById(id);
-    }
-
     public UploadChannel getByChannelIdAndCreateBy(int channelId, int createBy) {
         return uploadChannelRepository.findByCreateByAndChannelId(createBy, channelId);
     }
@@ -74,8 +37,8 @@ public class UploadChannelService {
     }
 
     private ObjectChannel getObjectChannel(UploadChannel uploadChannel) {
+        int id = uploadChannel.getId();
         int channelId = uploadChannel.getChannelId();
-        //String name = uploadChannel.getName();
         String channelPrefix = uploadChannel.getPrefix();
         long maxSize = uploadChannel.getMaxSize();
         int fileType = uploadChannel.getFileType();
@@ -85,7 +48,7 @@ public class UploadChannelService {
 
         UserNode userNode = userNodeService.getUserNode(uploadChannel.getNodeId(), createBy);
         String domain = userNode.getDomain();
-        return new ObjectChannel(channelId, channelPrefix, maxSize, fileType, seturl, scope, domain, createBy);
+        return new ObjectChannel(id, channelId, channelPrefix, maxSize, fileType, seturl, scope, domain, createBy);
     }
 
     public StoreNode getStoreNodeByChannelId(int loginUser, int channelId) throws Exception {

+ 1 - 6
oss-console/src/main/java/cn/reghao/oss/console/app/service/UserNodeService.java

@@ -9,10 +9,9 @@ import cn.reghao.oss.console.app.model.dto.UserNodeDto;
 import cn.reghao.oss.console.app.model.po.StoreNode;
 import cn.reghao.oss.console.app.model.po.UploadChannel;
 import cn.reghao.oss.console.app.model.po.UserNode;
-import cn.reghao.oss.console.app.model.vo.UserNodeVO;
+import cn.reghao.oss.api.dto.UserNodeVO;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -76,10 +75,6 @@ public class UserNodeService {
 
     public List<UserNodeVO> getUserStoreNodes(int loginUser) {
         List<UserNode> list = userNodeRepository.findByCreateBy(loginUser);
-        if (list.isEmpty()) {
-            return Collections.emptyList();
-        }
-
         return list.stream()
                 .map(userNode -> {
                     int nodeId = userNode.getNodeId();

+ 0 - 3
oss-sdk/src/main/java/cn/reghao/oss/sdk/OssConsoleClient.java

@@ -3,10 +3,8 @@ package cn.reghao.oss.sdk;
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.jutil.jdk.serializer.JsonConverter;
 import cn.reghao.oss.sdk.model.OssConsoleConfig;
-import cn.reghao.oss.api.dto.ObjectChannel;
 import cn.reghao.oss.api.dto.ObjectInfo;
 import cn.reghao.oss.api.dto.ServerInfo;
-import cn.reghao.oss.api.dto.StoreProperties;
 import cn.reghao.oss.api.dto.media.*;
 import cn.reghao.oss.api.rest.UploadFileRet;
 import com.google.gson.reflect.TypeToken;
@@ -20,7 +18,6 @@ import java.net.http.HttpRequest;
 import java.net.http.HttpResponse;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 /**