Преглед на файлове

添加删除 UploadChannel 的方法

reghao преди 2 години
родител
ревизия
428c493dd8

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

@@ -43,6 +43,7 @@ public class StoreChannelController {
     @ApiOperation(value = "删除上传通道")
     @DeleteMapping(value = "/delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
     public String deleteUploadChannel(@PathVariable("id") Integer id) {
+        uploadChannelService.deleteChannel(id);
         return WebResult.success("not implement");
     }
 }

+ 8 - 4
oss-console/src/main/java/cn/reghao/oss/console/app/service/UploadChannelService.java

@@ -73,6 +73,12 @@ public class UploadChannelService {
         return Result.success();
     }
 
+    private int getNextChannelId(int userId) {
+        int channelId = 101;
+        int total = uploadChannelRepository.countByCreateBy(userId);
+        return channelId + total;
+    }
+
     public void updateScope(ChannelScopeDto channelScopeDto) {
         int id = channelScopeDto.getId();
         int newScope = channelScopeDto.getNewScope();
@@ -86,10 +92,8 @@ public class UploadChannelService {
         }
     }
 
-    private int getNextChannelId(int userId) {
-        int channelId = 101;
-        int total = uploadChannelRepository.countByCreateBy(userId);
-        return channelId + total;
+    public void deleteChannel(int id) {
+        uploadChannelRepository.findById(id).ifPresent(uploadChannelRepository::delete);
     }
 
     public Page<UploadChannelVo> getUploadChannels(PageRequest pageRequest) {