Преглед изворни кода

部署日志页面数据的返回

reghao пре 4 година
родитељ
комит
99cb1fe187

+ 7 - 12
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/page/BuildDeployLogPageController.java

@@ -3,11 +3,7 @@ package cn.reghao.autodop.dmaster.app.controller.page;
 import cn.reghao.autodop.dmaster.app.model.constant.EnvList;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildTime;
-import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
-import cn.reghao.autodop.dmaster.app.model.vo.AppBuildingVO;
-import cn.reghao.autodop.dmaster.app.model.vo.BuildConfig;
-import cn.reghao.autodop.dmaster.app.model.vo.BuildLogVO;
-import cn.reghao.autodop.dmaster.app.model.vo.CommitInfoVO;
+import cn.reghao.autodop.dmaster.app.model.vo.*;
 import cn.reghao.autodop.dmaster.app.util.buildtool.repo.CommitInfo;
 import cn.reghao.autodop.dmaster.app.service.page.BuildDeployLogPage;
 import cn.reghao.autodop.dmaster.app.service.page.BuildDeployPage;
@@ -25,6 +21,8 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.List;
+
 /**
  * @author reghao
  * @date 2019-08-30 18:49:15
@@ -130,14 +128,11 @@ public class BuildDeployLogPageController {
     }
 
     @ApiOperation(value = "部署日志页面")
-    @GetMapping("/deploy/{appId}")
-    public String deployLogPage(@PathVariable("appId") String appId, Model model) {
-        PageRequest pageRequest = PageSort.pageRequest();
-        Page<DeployLog> deployLogs = buildDeployLogPage.deployLogs(appId, pageRequest);
-        PageList<DeployLog> pageList = PageList.pageList(deployLogs);
-
+    @GetMapping("/deploy/{buildLogId}")
+    public String deployLogPage(@PathVariable("buildLogId") String buildLogId, Model model) {
+        List<DeployLogVo> deployLogs = buildDeployLogPage.deployLogs(buildLogId);
         model.addAttribute("page", deployLogs);
-        model.addAttribute("list", pageList.getList());
+        model.addAttribute("list", deployLogs);
         return "/app/bd/log/deploylog";
     }
 }

+ 28 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/DeployLogVo.java

@@ -0,0 +1,28 @@
+package cn.reghao.autodop.dmaster.app.model.vo;
+
+import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
+import cn.reghao.jdkutil.converter.DateTimeConverter;
+import lombok.Data;
+
+/**
+ * @author reghao
+ * @date 2021-10-27 15:14:05
+ */
+@Data
+public class DeployLogVo {
+    private String buildLogId;
+    private String machineId;
+    private String machineIpv4;
+    private String deployBy;
+    private String deployTime;
+    private String result;
+
+    public DeployLogVo(DeployLog deployLog) {
+        this.buildLogId = deployLog.getBuildLogId();
+        this.machineId = deployLog.getMachineId();
+        this.machineIpv4 = deployLog.getMachineIpv4();
+        this.deployBy = deployLog.getDeployBy();
+        this.deployTime = DateTimeConverter.format(deployLog.getDeployTime());
+        this.result = deployLog.getResult().getMsg();
+    }
+}

+ 4 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/page/BuildDeployLogPage.java

@@ -3,9 +3,12 @@ package cn.reghao.autodop.dmaster.app.service.page;
 import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 import cn.reghao.autodop.dmaster.app.model.vo.BuildLogVO;
+import cn.reghao.autodop.dmaster.app.model.vo.DeployLogVo;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 
+import java.util.List;
+
 /**
  * @author reghao
  * @date 2021-10-20 18:46:34
@@ -13,5 +16,5 @@ import org.springframework.data.domain.PageRequest;
 public interface BuildDeployLogPage {
     Page<BuildLogVO> buildLogVOs(String appId, PageRequest pageRequest);
     BuildLog findByBuildLogId(String buildLogId);
-    Page<DeployLog> deployLogs(String appId, PageRequest pageRequest);
+    List<DeployLogVo> deployLogs(String buildLogId);
 }

+ 6 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/page/BuildDeployLogPageImpl.java

@@ -6,10 +6,14 @@ import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
 import cn.reghao.autodop.dmaster.app.model.po.log.DeployLog;
 import cn.reghao.autodop.dmaster.app.model.vo.AppBuildingVO;
 import cn.reghao.autodop.dmaster.app.model.vo.BuildLogVO;
+import cn.reghao.autodop.dmaster.app.model.vo.DeployLogVo;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @author reghao
  * @date 2021-10-20 18:46:34
@@ -35,7 +39,7 @@ public class BuildDeployLogPageImpl implements BuildDeployLogPage {
     }
 
     @Override
-    public Page<DeployLog> deployLogs(String appId, PageRequest pageRequest) {
-        return null;
+    public List<DeployLogVo> deployLogs(String buildLogId) {
+        return deployLogQuery.findByBuildLogId(buildLogId).stream().map(DeployLogVo::new).collect(Collectors.toList());
     }
 }

+ 8 - 42
dmaster/src/main/resources/templates/app/bd/log/deploylog.html

@@ -8,56 +8,22 @@
         <table class="layui-table timo-table">
             <thead>
             <tr>
-                <th class="sortable" data-field="appId">应用 ID</th>
-                <th class="sortable" data-field="appType">应用类型</th>
-                <th class="sortable" data-field="env">环境</th>
-                <th class="sortable" data-field="repoBranch">分支</th>
-                <th class="sortable" data-field="buildConfig">构建配置</th>
-                <th class="sortable" data-field="packScript">打包脚本</th>
-                <th class="sortable" data-field="packagePath">包路径</th>
-                <th class="sortable" data-field="commitInfo">版本信息</th>
-                <th class="sortable" data-field="buildTime">构建时间</th>
-                <th class="sortable" data-field="result">构建结果</th>
-                <th class="sortable" data-field="buildBy">构建用户</th>
-                <th>操作</th>
+                <th class="sortable" data-field="machineIpv4">机器地址</th>
+                <th class="sortable" data-field="deployBy">部署用户</th>
+                <th class="sortable" data-field="deployTime">部署时间</th>
+                <th class="sortable" data-field="result">部署结果</th>
             </tr>
             </thead>
             <tbody>
             <tr th:each="item:${list}">
-                <td th:text="${item.appId}">应用 ID</td>
-                <td th:text="${item.appType}">应用类型</td>
-                <td th:text="${item.env}">环境</td>
-                <td th:text="${item.repoBranch}">分支</td>
-                <td>
-                    <a class="open-popup" data-title="构建配置" data-size="1000,500" href="#"
-                       th:attr="data-url=@{'/app/bd/log/build/'+${item.id} + '/buildconfig'}">查看</a>
-                </td>
-                <td>
-                    <a class="open-popup" data-title="打包脚本" data-size="1000,500" href="#"
-                       th:attr="data-url=@{'/app/bd/log/build/'+${item.id} + '/packscript'}">查看</a>
-                </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/log/build/'+${item.id} + '/commitinfo'}">查看</a>
-                </td>
-                <td>
-                    <a class="open-popup" data-title="构建时间" data-size="1000,500" href="#"
-                       th:attr="data-url=@{'/app/bd/log/build/'+${item.id} + '/buildtime'}">查看</a>
-                </td>
-                <td>
-                    <a class="open-popup" data-title="构建结果" data-size="1000,500" href="#"
-                       th:attr="data-url=@{'/app/bd/log/build/'+${item.id} + '/result'}">查看</a>
-                </td>
-                <td th:text="${item.buildBy}">构建用户</td>
-                <td>
-                    <a class="ajax-post" th:href="@{'/api/app/bd/deploy?appId='+${item.id}}">部署</a>
-                </td>
+                <td th:text="${item.machineIpv4}">机器地址</td>
+                <td th:text="${item.deployBy}">部署用户</td>
+                <td th:text="${item.deployTime}">部署时间</td>
+                <td th:text="${item.result}">部署结果</td>
             </tr>
             </tbody>
         </table>
     </div>
-    <div th:replace="/common/fragment :: page"></div>
 </div>
 
 <script th:replace="/common/template :: script"></script>