Ver Fonte

oss-web 中添加修改 UploadChannel 可见范围的接口和页面

reghao há 2 anos atrás
pai
commit
c0fc907e6d

+ 11 - 4
oss-web/src/main/java/cn/reghao/oss/web/app/controller/page/StoreChannelController.java

@@ -1,6 +1,7 @@
 package cn.reghao.oss.web.app.controller.page;
 
 import cn.reghao.jutil.jdk.result.WebResult;
+import cn.reghao.oss.web.app.model.dto.ChannelScopeDto;
 import cn.reghao.oss.web.app.model.dto.UploadChannelDto;
 import cn.reghao.oss.web.app.service.UploadChannelService;
 import io.swagger.annotations.Api;
@@ -32,10 +33,16 @@ public class StoreChannelController {
         return WebResult.success();
     }
 
-    @ApiOperation(value = "删除上传通道")
-    @DeleteMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String deleteUploadChannel(@Validated UploadChannelDto uploadChannelDto) {
-        uploadChannelService.add(uploadChannelDto);
+    @ApiOperation(value = "修改通道可见范围")
+    @PostMapping(value = "/update/scope", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String updateChannelScope(@Validated ChannelScopeDto channelScopeDto) {
+        uploadChannelService.updateScope(channelScopeDto);
         return WebResult.success();
     }
+
+    @ApiOperation(value = "删除上传通道")
+    @DeleteMapping(value = "/delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String deleteUploadChannel(@PathVariable("id") Integer id) {
+        return WebResult.success("not implement");
+    }
 }

+ 18 - 1
oss-web/src/main/java/cn/reghao/oss/web/app/controller/page/StoreChannelPageController.java

@@ -65,7 +65,7 @@ public class StoreChannelPageController {
 
     @ApiOperation(value = "新增上传通道页面")
     @GetMapping("/add")
-    public String deployPage(Model model) {
+    public String addChannelPage(Model model) {
         List<KeyValue> objectTypes = new ArrayList<>();
         for (ObjectType objectType : ObjectType.values()) {
             if (objectType.getCode() == 1000) {
@@ -99,4 +99,21 @@ public class StoreChannelPageController {
         model.addAttribute("storeNodes", storeNodes);
         return "/channel/add";
     }
+
+    @ApiOperation(value = "修改通道可见范围")
+    @GetMapping("/edit/{id}")
+    public String editChannelScopePage(@PathVariable("id") Integer id, Model model) {
+        UploadChannel uploadChannel = uploadChannelService.getUploadChannel(id);
+        int scope = uploadChannel.getScope();
+        ObjectScope objectScope0 = ObjectScope.getByCode(scope);
+
+        List<KeyValue> objectScopes = new ArrayList<>();
+        for (ObjectScope objectScope : ObjectScope.values()) {
+            objectScopes.add(new KeyValue(objectScope.getCode()+"", objectScope.name()));
+        }
+
+        model.addAttribute("objectScope", objectScope0.getName());
+        model.addAttribute("objectScopes", objectScopes);
+        return "/channel/edit";
+    }
 }

+ 21 - 0
oss-web/src/main/java/cn/reghao/oss/web/app/model/dto/ChannelScopeDto.java

@@ -0,0 +1,21 @@
+package cn.reghao.oss.web.app.model.dto;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author reghao
+ * @date 2024-02-28 18:07:39
+ */
+@NoArgsConstructor
+@Setter
+@Getter
+public class ChannelScopeDto {
+    @NotNull
+    private Integer id;
+    @NotNull
+    private Integer newScope;
+}

+ 18 - 0
oss-web/src/main/java/cn/reghao/oss/web/app/service/UploadChannelService.java

@@ -8,6 +8,7 @@ import cn.reghao.oss.api.iface.OssServerService;
 import cn.reghao.oss.web.account.service.UserContext;
 import cn.reghao.oss.web.app.db.repository.StoreNodeRepository;
 import cn.reghao.oss.web.app.db.repository.UploadChannelRepository;
+import cn.reghao.oss.web.app.model.dto.ChannelScopeDto;
 import cn.reghao.oss.web.app.model.dto.UploadChannelDto;
 import cn.reghao.oss.web.app.model.po.StoreNode;
 import cn.reghao.oss.web.app.model.po.UploadChannel;
@@ -67,6 +68,19 @@ public class UploadChannelService {
         return Result.success();
     }
 
+    public void updateScope(ChannelScopeDto channelScopeDto) {
+        int id = channelScopeDto.getId();
+        int newScope = channelScopeDto.getNewScope();
+        UploadChannel uploadChannel = uploadChannelRepository.findById(id).orElse(null);
+        if (uploadChannel != null) {
+            int currentScope = uploadChannel.getScope();
+            if (currentScope != newScope) {
+                uploadChannel.setScope(newScope);
+                uploadChannelRepository.save(uploadChannel);
+            }
+        }
+    }
+
     private int getNextChannelId(int userId) {
         int channelId = 101;
         int total = uploadChannelRepository.countByCreateBy(userId);
@@ -84,4 +98,8 @@ public class UploadChannelService {
 
         return new PageImpl<>(list, pageRequest, page.getTotalElements());
     }
+
+    public UploadChannel getUploadChannel(int id) {
+        return uploadChannelRepository.findById(id).orElse(null);
+    }
 }

+ 0 - 67
oss-web/src/main/resources/templates/channel/deploy.html

@@ -1,67 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-<body class="timo-layout-page">
-<div class="layui-card">
-    <div class="layui-card-body">
-        <div class="timo-table-wrap">
-            <table class="layui-table timo-table">
-                <thead>
-                <tr>
-                    <th class="sortable" data-field="machineIpv4">机器地址</th>
-                    <th class="sortable" data-field="machineStatus">机器状态</th>
-                    <th class="sortable" data-field="commitId">当前版本</th>
-                    <th class="sortable" data-field="packagePath">包路径</th>
-                    <th class="sortable" data-field="deployBy">部署用户</th>
-                    <th class="sortable" data-field="deployTime">部署时间</th>
-                    <th class="sortable" data-field="deployResult">部署结果</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr th:each="item:${list}">
-                    <td th:text="${item.machineIpv4}">机器地址</td>
-                    <td class="machine-status" th:text="${item.machineStatus}">机器状态</td>
-                    <td th:text="${item?.commitId}">当前版本</td>
-                    <td th:text="${item?.packagePath}">包路径</td>
-                    <td th:text="${item?.deployBy}">部署用户</td>
-                    <td th:text="${item?.deployTime}">部署时间</td>
-                    <td class="deploy-result" th:text="${item?.deployResult}">部署结果</td>
-                    <td>
-                        <a class="ajax-post"
-                           th:href="@{'/api/app/bd/deploy/'+${buildLogId}+'/'+${item.machineId}}">部署</a>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-    </div>
-</div>
-
-<script th:replace="/common/template :: script"></script>
-<script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
-<script type="text/javascript">
-    $(".deploy-result").each(function () {
-        var text = $(this).text().trim()
-        if (text === '尚未部署') {
-            $(this).css("color", "#4169e1")
-        } else if (text === '正在部署') {
-            $(this).css("color", "#e3cf57")
-        } else if (text === '部署成功') {
-            $(this).css("color", "#009688")
-        } else if (text === '部署失败') {
-            $(this).css("color", "#ff0000")
-        }
-    })
-
-    $(".machine-status").each(function () {
-        var text = $(this).text().trim()
-        if (text === 'Online') {
-            $(this).css("color", "#009688")
-        } else {
-            $(this).css("color", "#ff0000")
-        }
-    })
-</script>
-</body>
-</html>

+ 48 - 0
oss-web/src/main/resources/templates/channel/edit.html

@@ -0,0 +1,48 @@
+<!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/scope}">
+        <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">
+                            <input class="layui-input" type="text" name="objectScope" th:value="${objectScope}" readonly>
+                        </div>
+                    </div>
+                </td>
+            </tr>
+            <tr>
+                <th>
+                    <label class="layui-form-label required">选择新范围</label>
+                </th>
+                <td>
+                    <div class="layui-form-item">
+                        <div class="layui-input-inline">
+                            <select name="newScope">
+                                <option th:each="item : ${objectScopes}" 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>

+ 4 - 6
oss-web/src/main/resources/templates/channel/index.html

@@ -69,12 +69,10 @@
                     <td th:text="${item.scope}">可见范围</td>
                     <td th:text="${item.bindDomain}">绑定域名</td>
                     <td>
-                        <a class="open-popup" data-title="应用详细信息" th:attr="data-url=@{'/app/config/app/detail/'+${item.id}}"
-                           data-size="1200,500" href="#">详细</a>
-                        <a class="open-popup" data-title="编辑" th:attr="data-url=@{'/app/config/app/edit/'+${item.id}}"
-                           data-size="1200,500" href="#">编辑</a>
-                        <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.id}"
-                           th:href="@{'/api/app/config/app/' + ${item.id}}">删除</a>
+                        <a class="open-popup" data-title="修改 channel 可见范围" th:attr="data-url=@{'/store/channel/edit/'+${item.id}}"
+                           data-size="640,480" href="#">编辑</a>
+                        <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.name}"
+                           th:href="@{'/api/store/channel/delete/' + ${item.id}}">删除</a>
                     </td>
                 </tr>
                 </tbody>

+ 0 - 65
oss-web/src/main/resources/templates/channel/log/buildconfig.html

@@ -1,65 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-<body>
-<div class="timo-detail-page">
-    <div class="timo-detail-title">仓库认证</div>
-    <table class="layui-table timo-detail-table">
-        <thead>
-        <tr>
-            <th data-field="type">仓库类型</th>
-            <th data-field="name">认证名字</th>
-            <th data-field="authType">认证类型</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr>
-            <td th:text="${buildConfigSnapshot.repoType}"></td>
-            <td th:text="${buildConfigSnapshot.repoName}"></td>
-            <td th:text="${buildConfigSnapshot.repoAuthType}"></td>
-        </tr>
-        </tbody>
-    </table>
-    <div class="timo-detail-title">编译配置</div>
-    <table class="layui-table timo-detail-table">
-        <thead>
-        <tr>
-            <th data-field="type">编译器类型</th>
-            <th data-field="name">编译器名字</th>
-            <th data-field="compileScript">编译命令</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr>
-            <td th:text="${buildConfigSnapshot.compileType}"></td>
-            <td th:text="${buildConfigSnapshot.compileName}"></td>
-            <td th:text="${buildConfigSnapshot.compileScript}"></td>
-        </tr>
-        </tbody>
-    </table>
-    <div class="timo-detail-title">打包配置</div>
-    <table class="layui-table timo-detail-table">
-        <thead>
-        <tr>
-            <th data-field="type">打包类型</th>
-            <th data-field="name">打包名字</th>
-            <th data-field="targetPath">打包路径</th>
-            <th data-field="dockerfile">Dockerfile</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr>
-            <td th:text="${buildConfigSnapshot.packType}"></td>
-            <td th:text="${buildConfigSnapshot.packName}"></td>
-            <td th:text="${buildConfigSnapshot.targetPath}"></td>
-            <td>
-                <textarea class="layui-textarea" readonly="readonly" th:text="${buildConfigSnapshot.dockerfile}"></textarea>
-            </td>
-
-        </tr>
-        </tbody>
-    </table>
-</div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 0 - 56
oss-web/src/main/resources/templates/channel/log/buildlog.html

@@ -1,56 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body class="timo-layout-page">
-<div class="layui-card">
-    <div class="timo-table-wrap">
-        <table class="layui-table timo-table">
-            <thead>
-            <tr>
-                <th class="sortable" data-field="repoBranch">分支</th>
-                <th class="sortable" data-field="commitId">版本 ID</th>
-                <th class="sortable" data-field="buildTime">构建时间</th>
-                <th class="sortable">构建结果</th>
-                <th class="sortable" data-field="buildBy">构建用户</th>
-                <th class="sortable" data-field="packagePath">包路径</th>
-                <th class="sortable">构建配置</th>
-                <th class="sortable">构建耗时</th>
-                <th>操作</th>
-            </tr>
-            </thead>
-            <tbody>
-            <tr th:each="item:${list}">
-                <td th:text="${item.branch}">分支</td>
-                <td th:text="${item.commitId}">版本 ID</td>
-                <td th:text="${item.buildTime}">构建时间</td>
-                <td>
-                    <a class="open-popup" data-title="构建结果" data-size="1000,500" href="#"
-                       th:attr="data-url=@{'/app/bd/build/result?buildLogId='+${item.buildLogId}}">查看</a>
-                </td>
-                <td th:text="${item.buildBy}">构建用户</td>
-                <td th:text="${item.packagePath}">包路径</td>
-                <td>
-                    <a class="open-popup" data-title="构建配置" data-size="1000,500" href="#"
-                       th:attr="data-url=@{'/app/bd/build/config?buildLogId='+${item.buildLogId}}">查看</a>
-                </td>
-                <td>
-                    <a class="open-popup" data-title="构建耗时" data-size="500,200" href="#"
-                       th:attr="data-url=@{'/app/bd/build/consumed?buildLogId='+${item.buildLogId}}">查看</a>
-                </td>
-                <td>
-                    <a class="open-popup" th:attr="data-title=@{${item.appId} + ' 部署列表'}, data-url=@{'/app/bd/deploy?appId=' + ${item.appId} + '&buildLogId=' + ${item.buildLogId}}"
-                       data-size="1000,500" href="#">部署</a>
-                    <a class="ajax-redirect" th:href="@{'/api/app/bd/packageurl/'+${item.buildLogId}}">下载</a>
-                </td>
-            </tr>
-            </tbody>
-        </table>
-    </div>
-    <div th:replace="/common/fragment :: page"></div>
-</div>
-
-<script th:replace="/common/template :: script"></script>
-<script type="text/javascript"></script>
-</body>
-</html>

+ 0 - 28
oss-web/src/main/resources/templates/channel/log/buildresult.html

@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
-</head>
-<body class="timo-layout-page">
-<div class="layui-card">
-    <div class="layui-bg-gray" style="padding: 30px;">
-        <div class="layui-card-body">
-            <table class="layui-table timo-detail-table">
-                <thead>
-                <tr>
-                    <th class="sortable" data-field="changeType">行号</th>
-                    <th class="sortable" data-field="oldFilePath">内容</th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr th:each="item,stat:${list}">
-                    <td th:text="${stat.index}">行号</td>
-                    <td th:text="${item}">内容</td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-    </div>
-</div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 0 - 27
oss-web/src/main/resources/templates/channel/log/buildtime.html

@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-<body>
-<div class="timo-detail-page">
-    <table class="layui-table timo-detail-table">
-        <thead>
-        <tr>
-            <th class="sortable" data-field="pullConsumed">更新耗时(ms)</th>
-            <th class="sortable" data-field="compileConsumed">编译耗时(ms)</th>
-            <th class="sortable" data-field="packConsumed">打包耗时(ms)</th>
-            <th class="sortable" data-field="pushConsumed">推送耗时(ms)</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr>
-            <td th:text="${buildConsumed.pullConsumed}">更新耗时</td>
-            <td th:text="${buildConsumed.compileConsumed}">编译耗时</td>
-            <td th:text="${buildConsumed.packConsumed}">打包耗时</td>
-            <td th:text="${buildConsumed.pushConsumed}">推送耗时</td>
-        </tr>
-        </tbody>
-    </table>
-</div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>