Sfoglia il codice sorgente

UploadChannel 添加修改 processFile 字段的接口和页面

reghao 2 anni fa
parent
commit
467753065a

+ 11 - 2
oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/UploadChannelController.java

@@ -1,6 +1,8 @@
 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.UploadChannelService;
@@ -29,8 +31,8 @@ public class UploadChannelController {
     @ApiOperation(value = "添加上传通道")
     @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
     public String addUploadChannel(@Validated UploadChannelDto uploadChannelDto) {
-        uploadChannelService.add(uploadChannelDto);
-        return WebResult.success();
+        Result result = uploadChannelService.add(uploadChannelDto);
+        return WebResult.result(result);
     }
 
     @ApiOperation(value = "修改通道可见范围")
@@ -39,4 +41,11 @@ public class UploadChannelController {
         uploadChannelService.updateScope(channelScopeDto);
         return WebResult.success();
     }
+
+    @ApiOperation(value = "修改通道是否处理上传文件")
+    @PostMapping(value = "/update/processfile", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String updateChannelProcess(@Validated ChannelProcessDto channelProcessDto) {
+        uploadChannelService.updateProcessFile(channelProcessDto);
+        return WebResult.success();
+    }
 }

+ 13 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/controller/page/UploadChannelPageController.java

@@ -119,4 +119,17 @@ public class UploadChannelPageController {
         model.addAttribute("objectScopes", objectScopes);
         return "/channel/edit";
     }
+
+    @ApiOperation(value = "通道文件处理")
+    @GetMapping("/update/{id}")
+    public String editChannelScope1Page(@PathVariable("id") Integer id, Model model) {
+        UploadChannel uploadChannel = uploadChannelService.getUploadChannel(id);
+        List<KeyValue> list = new ArrayList<>();
+        list.add(new KeyValue("1", "处理文件"));
+        list.add(new KeyValue("0", "不处理文件"));
+
+        model.addAttribute("id", uploadChannel.getId());
+        model.addAttribute("list", list);
+        return "/channel/edit1";
+    }
 }

+ 21 - 0
oss-console/src/main/java/cn/reghao/oss/console/app/model/dto/ChannelProcessDto.java

@@ -0,0 +1,21 @@
+package cn.reghao.oss.console.app.model.dto;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author reghao
+ * @date 2024-03-07 16:26:52
+ */
+@NoArgsConstructor
+@Setter
+@Getter
+public class ChannelProcessDto {
+    @NotNull
+    private Integer id;
+    @NotNull
+    private Boolean processFile;
+}

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

@@ -3,6 +3,7 @@ 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.model.dto.ChannelProcessDto;
 import cn.reghao.oss.console.app.rpc.RemoteService;
 import cn.reghao.oss.console.util.AuthKeyContext;
 import cn.reghao.oss.store.api.dto.ObjectChannel;
@@ -46,8 +47,8 @@ public class UploadChannelService {
             return Result.fail(String.format("store_node with id %s not exist", nodeId));
         }
 
-        //int createBy = UserContext.getUser().getId();
-        int createBy = 410;
+        int createBy = UserContext.getUser().getId();
+        //int createBy = 410;
         String channelPrefix = uploadChannelDto.getChannelPrefix();
         UploadChannel uploadChannel = uploadChannelRepository.findByPrefixAndCreateByAndNodeId(channelPrefix, createBy, nodeId);
         if (uploadChannel != null) {
@@ -98,6 +99,20 @@ public class UploadChannelService {
         }
     }
 
+    public void updateProcessFile(ChannelProcessDto channelProcessDto) {
+        int id = channelProcessDto.getId();
+        UploadChannel uploadChannel = uploadChannelRepository.findById(id).orElse(null);
+        if (uploadChannel != null) {
+            boolean processFile = channelProcessDto.getProcessFile();
+            boolean current = uploadChannel.getProcessFile();
+            if (processFile != current) {
+                uploadChannel.setProcessFile(processFile);
+                uploadChannelRepository.save(uploadChannel);
+
+            }
+        }
+    }
+
     public Page<UploadChannelVo> getUploadChannels(PageRequest pageRequest) {
         int loginUser = UserContext.getUser().getId();
         Page<UploadChannel> page = uploadChannelRepository.findByCreateBy(loginUser, pageRequest);

+ 36 - 0
oss-console/src/main/resources/templates/channel/edit1.html

@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org">
+<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
+
+<body>
+<div class="layui-form timo-compile">
+    <form th:action="@{/api/store/channel/update/processfile}">
+        <input class="layui-input" type="hidden" name="id" th:value="${id}" readonly>
+        <table class="layui-table timo-detail-table">
+            <tbody>
+            <tr>
+                <th>
+                    <label class="layui-form-label required">是否处理文件</label>
+                </th>
+                <td>
+                    <div class="layui-form-item">
+                        <div class="layui-input-inline">
+                            <select name="processFile">
+                                <option th:each="item : ${list}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
+                        </div>
+                    </div>
+                </td>
+            </tr>
+            </tbody>
+        </table>
+        <div class="layui-form-item timo-finally">
+            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
+            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
+        </div>
+    </form>
+</div>
+
+<script th:replace="/common/template :: script"></script>
+</body>
+</html>

+ 1 - 1
oss-console/src/main/resources/templates/channel/index.html

@@ -62,7 +62,7 @@
                     </td>
                     <td th:text="${item.bindDomain}">绑定域名</td>
                     <td>
-                        <a class="open-popup" data-title="修改 channel 可见范围" th:attr="data-url=@{'/store/channel/edit/'+${item.id}}"
+                        <a class="open-popup" data-title="channel 文件处理" th:attr="data-url=@{'/store/channel/update/'+${item.id}}"
                            data-size="640,480" href="#">编辑</a>
                     </td>
                 </tr>