Просмотр исходного кода

update AppDeployConfigPageController

reghao 6 месяцев назад
Родитель
Сommit
a0dfa5eb3d

+ 0 - 49
mgr/src/main/java/cn/reghao/devops/mgr/app/controller/AppDeployConfigController.java

@@ -1,49 +0,0 @@
-package cn.reghao.devops.mgr.app.controller;
-
-import cn.reghao.devops.mgr.app.model.dto.DeployConfigDto;
-import cn.reghao.devops.mgr.app.service.AppDeployService;
-import cn.reghao.jutil.jdk.result.Result;
-import cn.reghao.jutil.jdk.result.WebResult;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.MediaType;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-/**
- * @author reghao
- * @date 2019-11-27 11:29:43
- */
-@Slf4j
-@Api(tags = "应用部署配置 CRUD 接口")
-@RestController
-@RequestMapping("/api/app/config/app/deploy")
-public class AppDeployConfigController {
-    private final AppDeployService appDeployService;
-
-    public AppDeployConfigController(AppDeployService appDeployService) {
-        this.appDeployService = appDeployService;
-    }
-
-    @ApiOperation(value = "添加应用部署配置", notes = "N")
-    @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
-    public String add(@Validated DeployConfigDto deployConfigDto) {
-        Result result = appDeployService.addDeployConfig(deployConfigDto);
-        return WebResult.result(result);
-    }
-
-    @ApiOperation(value = "修改应用部署配置", notes = "N")
-    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String update(@Validated DeployConfigDto deployConfigDto) {
-        Result result = appDeployService.updateStartScript(deployConfigDto);
-        return WebResult.result(result);
-    }
-
-    @ApiOperation(value = "删除应用部署配置", notes = "N")
-    @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String delete(@PathVariable("id") Integer appDeployConfigId) {
-        Result result = appDeployService.deleteDeployConfig(appDeployConfigId);
-        return WebResult.result(result);
-    }
-}

+ 32 - 11
mgr/src/main/java/cn/reghao/devops/mgr/app/controller/page/AppDeployConfigPageController.java

@@ -2,19 +2,23 @@ package cn.reghao.devops.mgr.app.controller.page;
 
 import cn.reghao.devops.mgr.app.db.query.AppBuildQuery;
 import cn.reghao.devops.mgr.app.db.query.AppDeployQuery;
+import cn.reghao.devops.mgr.app.model.dto.DeployConfigDto;
 import cn.reghao.devops.mgr.app.model.po.config.AppConfig;
 import cn.reghao.devops.mgr.app.model.po.config.AppDeployConfig;
 import cn.reghao.devops.mgr.app.model.vo.AppDeployConfigVO;
 import cn.reghao.devops.common.util.KeyValue;
+import cn.reghao.devops.mgr.app.service.AppDeployService;
 import cn.reghao.devops.mgr.machine.service.MachineQuery;
+import cn.reghao.jutil.jdk.result.Result;
+import cn.reghao.jutil.web.WebResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.stream.Collectors;
@@ -31,12 +35,14 @@ public class AppDeployConfigPageController {
     private final AppDeployQuery appDeployQuery;
     private final AppBuildQuery appBuildQuery;
     private final MachineQuery machineQuery;
+    private final AppDeployService appDeployService;
 
     public AppDeployConfigPageController(AppDeployQuery appDeployQuery, AppBuildQuery appBuildQuery,
-                                         MachineQuery machineQuery) {
+                                         MachineQuery machineQuery, AppDeployService appDeployService) {
         this.appDeployQuery = appDeployQuery;
         this.appBuildQuery = appBuildQuery;
         this.machineQuery = machineQuery;
+        this.appDeployService = appDeployService;
     }
 
     @ApiOperation(value = "部署配置列表页面", notes = "N")
@@ -73,12 +79,27 @@ public class AppDeployConfigPageController {
         return "/devops/app/deploy/edit";
     }
 
-    @ApiOperation(value = "部署配置详情页面", notes = "N")
-    @GetMapping("/detail/{appId}/{machineId}")
-    public String appConfigPage(@PathVariable("appId") String appId, @PathVariable("machineId") String machineId,
-                                Model model) {
-        AppDeployConfig appDeployConfig = appDeployQuery.getByAppIdAndMachineId(appId, machineId);
-        model.addAttribute("deployConfigVO", new AppDeployConfigVO(appDeployConfig));
-        return "/devops/app/deploy/detail";
+    @ApiOperation(value = "添加应用部署配置", notes = "N")
+    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
+    @ResponseBody
+    public String add(@Validated DeployConfigDto deployConfigDto) {
+        Result result = appDeployService.addDeployConfig(deployConfigDto);
+        return WebResult.result(result);
+    }
+
+    @ApiOperation(value = "修改应用部署配置", notes = "N")
+    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
+    @ResponseBody
+    public String update(@Validated DeployConfigDto deployConfigDto) {
+        Result result = appDeployService.updateStartScript(deployConfigDto);
+        return WebResult.result(result);
+    }
+
+    @ApiOperation(value = "删除应用部署配置", notes = "N")
+    @DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+    @ResponseBody
+    public String delete(@PathVariable("id") Integer appDeployConfigId) {
+        Result result = appDeployService.deleteDeployConfig(appDeployConfigId);
+        return WebResult.result(result);
     }
 }

+ 1 - 1
mgr/src/main/resources/templates/devops/app/deploy/add.html

@@ -4,7 +4,7 @@
 
 <body>
 <div class="layui-form timo-compile">
-    <form th:action="@{/api/app/config/app/deploy}">
+    <form th:action="@{/app/config/app/deploy}">
         <table class="layui-table timo-detail-table">
             <tbody>
             <tr>

+ 0 - 39
mgr/src/main/resources/templates/devops/app/deploy/detail.html

@@ -1,39 +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">
-            <tbody>
-            <tr>
-                <th>应用 ID</th>
-                <td th:text="${deployConfigVO.appId}"></td>
-                <th>机器地址</th>
-                <td th:text="${deployConfigVO.machineIpv4}"></td>
-            </tr>
-            <tr>
-                <th>打包类型</th>
-                <td th:text="${deployConfigVO.packType}"></td>
-                <span th:if="${deployConfigVO.packType} ne 'docker' ">
-                    <th>启动目录</th>
-                    <td th:text="${deployConfigVO.startHome}"></td>
-                </span>
-            </tr>
-            <tr>
-                <th>启动脚本</th>
-                <td>
-                    <textarea class="layui-textarea" readonly="readonly" th:text="${deployConfigVO.startScript}"></textarea>
-                </td>
-                <span th:if="${deployConfigVO.packType} ne 'docker' ">
-                <th>解包脚本</th>
-                <td>
-                    <textarea class="layui-textarea" readonly="readonly" th:text="${deployConfigVO.unpackScript}"></textarea>
-                </td>
-                </span>
-            </tr>
-            </tbody>
-        </table>
-    </div>
-<script th:replace="/common/template :: script"></script>
-</body>
-</html>

+ 1 - 1
mgr/src/main/resources/templates/devops/app/deploy/edit.html

@@ -4,7 +4,7 @@
 
 <body>
 <div class="layui-form timo-compile">
-    <form th:action="@{/api/app/config/app/deploy/update}">
+    <form th:action="@{/app/config/app/deploy/update}">
         <input type="hidden" name="machineId" th:value="${appDeployConfig.machineHost.machineId}"/>
         <table class="layui-table timo-detail-table">
             <tbody>

+ 2 - 3
mgr/src/main/resources/templates/devops/app/deploy/index.html

@@ -33,11 +33,10 @@
                     <td th:text="${item.packType}">打包类型</td>
                     <td th:text="${item.startScript}">启动脚本</td>
                     <td>
-                        <a class="open-popup" data-title="部署配置详情" th:attr="data-url=@{'/app/config/app/deploy/detail/'+${appId}+'/'+${item.machineId}}"
-                           data-size="1000,500" href="#">详情</a>
                         <a class="open-popup" data-title="修改部署配置" th:attr="data-url=@{'/app/config/app/deploy/edit/'+${appId}+'/'+${item.machineId}}"
                            data-size="1000,500" href="#">编辑</a>
-                        <a class="ajax-delete" th:href="@{'/api/app/config/app/deploy/'+${item.appDeployConfigId}}">删除</a>
+                        <a class="ajax-delete" th:attr="data-msg='确定要删除?'"
+                           th:href="@{'/app/config/app/deploy/'+${item.appDeployConfigId}}">删除</a>
                     </td>
                 </tr>
                 </tbody>