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

调整构建部署日志页面的接口和返回的数据

reghao 4 лет назад
Родитель
Сommit
3b856959a5

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

@@ -6,7 +6,7 @@ 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.BuildTimeVo;
+import cn.reghao.autodop.dmaster.app.model.vo.BuildLogVO;
 import cn.reghao.autodop.dmaster.app.model.vo.CommitInfoVO;
 import cn.reghao.autodop.dmaster.app.service.bd.tools.repo.CommitInfo;
 import cn.reghao.autodop.dmaster.app.service.page.BuildDeployLogPage;
@@ -69,8 +69,8 @@ public class BuildDeployLogPageController {
     @GetMapping("/build/{appId}")
     public String buildLogPage(@PathVariable("appId") String appId, Model model) {
         PageRequest pageRequest = PageSort.pageRequest();
-        Page<BuildLog> buildLogs = buildDeployLogPage.buildLogs(appId, pageRequest);
-        PageList<BuildLog> pageList = PageList.pageList(buildLogs);
+        Page<BuildLogVO> buildLogs = buildDeployLogPage.buildLogVOs(appId, pageRequest);
+        PageList<BuildLogVO> pageList = PageList.pageList(buildLogs);
 
         model.addAttribute("page", buildLogs);
         model.addAttribute("list", pageList.getList());
@@ -101,8 +101,14 @@ public class BuildDeployLogPageController {
     public String commitInfoPage(@PathVariable("buildLogId") String buildLogId, Model model) {
         BuildLog buildLog = buildDeployLogPage.findByBuildLogId(buildLogId);
         CommitInfo commitInfo = buildLog.getCommitInfo();
-        model.addAttribute("commitInfo", new CommitInfoVO(commitInfo));
-        return "/app/bd/log/commitinfo";
+        if (commitInfo != null) {
+            model.addAttribute("commitInfo", new CommitInfoVO(commitInfo));
+            return "/app/bd/log/commitinfo";
+        } else {
+            String errMsg = "构建失败,请修正错误后重新构建";
+            model.addAttribute("errMsg", errMsg);
+            return "/error";
+        }
     }
 
     @ApiOperation(value = "构建时间页面")
@@ -110,7 +116,7 @@ public class BuildDeployLogPageController {
     public String buildTimePage(@PathVariable("buildLogId") String buildLogId, Model model) {
         BuildLog buildLog = buildDeployLogPage.findByBuildLogId(buildLogId);
         BuildTime buildTime = buildLog.getBuildTime();
-        model.addAttribute("buildTime", new BuildTimeVo(buildTime));
+        model.addAttribute("buildTime", buildTime);
         return "/app/bd/log/buildtime";
     }
 

+ 35 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/BuildLogVO.java

@@ -0,0 +1,35 @@
+package cn.reghao.autodop.dmaster.app.model.vo;
+
+import cn.reghao.autodop.dmaster.app.model.po.log.BuildLog;
+import cn.reghao.jdkutil.converter.DateTimeConverter;
+import lombok.Data;
+
+/**
+ * @author reghao
+ * @date 2021-10-20 21:26:02
+ */
+@Data
+public class BuildLogVO {
+    private String buildLogId;
+    private String appId;
+    private String appType;
+    private String env;
+    private String branch;
+    private String commitId;
+    private String buildTime;
+    private String packagePath;
+    private String buildBy;
+
+    public BuildLogVO(BuildLog buildLog) {
+        this.buildLogId = buildLog.getId();
+        this.appId = buildLog.getAppId();
+        this.appType = buildLog.getAppType();
+        this.env = buildLog.getEnv();
+        this.branch = buildLog.getRepoBranch();
+        this.commitId = buildLog.getCommitInfo() != null ? buildLog.getCommitInfo().getCommitId() : "";
+        this.buildTime = buildLog.getBuildTime() != null ?
+                DateTimeConverter.format(buildLog.getBuildTime().getBuildTime()) : "";
+        this.packagePath = buildLog.getPackagePath();
+        this.buildBy = buildLog.getBuildBy();
+    }
+}

+ 0 - 26
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/BuildTimeVo.java

@@ -1,26 +0,0 @@
-package cn.reghao.autodop.dmaster.app.model.vo;
-
-import cn.reghao.autodop.dmaster.app.model.po.log.BuildTime;
-import cn.reghao.jdkutil.converter.DateTimeConverter;
-import lombok.Data;
-
-import java.time.LocalDateTime;
-
-/**
- * @author reghao
- * @date 2021-10-20 20:40:29
- */
-@Data
-public class BuildTimeVo {
-    private Long updateTotalTime;
-    private Long compileTotalTime;
-    private Long packTotalTime;
-    private String buildTime;
-
-    public BuildTimeVo(BuildTime buildTime) {
-        this.updateTotalTime = buildTime.getUpdateTotalTime();
-        this.compileTotalTime = buildTime.getCompileTotalTime();
-        this.packTotalTime = buildTime.getPackTotalTime();
-        this.buildTime = DateTimeConverter.format(buildTime.getBuildTime());
-    }
-}

+ 0 - 11
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/model/vo/CommitInfoVO.java

@@ -13,23 +13,12 @@ import java.util.List;
  */
 @Data
 public class CommitInfoVO {
-    private String remote;
-    private String branch;
-    private String local;
-    // 代码是否更新
-    private boolean isUpdate;
-    private String commitId;
     private String commitAuthor;
     private String commitMsg;
     private String commitTime;
     private List<ChangedFile> changedFiles;
 
     public CommitInfoVO(CommitInfo commitInfo) {
-        this.remote = commitInfo.getRemote();
-        this.branch = commitInfo.getBranch();
-        this.local = commitInfo.getLocal();
-        this.isUpdate = commitInfo.isUpdate();
-        this.commitId = commitInfo.getCommitId();
         this.commitAuthor = commitInfo.getCommitAuthor();
         this.commitMsg = commitInfo.getCommitMsg();
         this.commitTime = DateTimeConverter.format(commitInfo.getMsCommitTime());

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

@@ -2,6 +2,7 @@ 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 org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 
@@ -10,7 +11,7 @@ import org.springframework.data.domain.PageRequest;
  * @date 2021-10-20 18:46:34
  */
 public interface BuildDeployLogPage {
-    Page<BuildLog> buildLogs(String appId, PageRequest pageRequest);
+    Page<BuildLogVO> buildLogVOs(String appId, PageRequest pageRequest);
     BuildLog findByBuildLogId(String buildLogId);
     Page<DeployLog> deployLogs(String appId, PageRequest pageRequest);
 }

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

@@ -5,6 +5,7 @@ import cn.reghao.autodop.dmaster.app.db.query.log.DeployLogQuery;
 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 org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -24,8 +25,8 @@ public class BuildDeployLogPageImpl implements BuildDeployLogPage {
     }
 
     @Override
-    public Page<BuildLog> buildLogs(String appId, PageRequest pageRequest) {
-        return buildLogQuery.findByAppId(appId, pageRequest);
+    public Page<BuildLogVO> buildLogVOs(String appId, PageRequest pageRequest) {
+        return buildLogQuery.findByAppId(appId, pageRequest).map(BuildLogVO::new);
     }
 
     @Override

+ 19 - 13
dmaster/src/main/resources/templates/app/bd/log/buildlog.html

@@ -12,12 +12,14 @@
                 <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="commitId">版本 ID</th>
                 <th class="sortable" data-field="buildTime">构建时间</th>
-                <th class="sortable" data-field="result">构建结果</th>
+                <th class="sortable">构建配置</th>
+                <th class="sortable">打包脚本</th>
+                <th class="sortable" data-field="packagePath">包路径</th>
+                <th class="sortable">版本信息</th>
+                <th class="sortable">构建耗时</th>
+                <th class="sortable">构建结果</th>
                 <th class="sortable" data-field="buildBy">构建用户</th>
                 <th>操作</th>
             </tr>
@@ -27,31 +29,35 @@
                 <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 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/log/build/'+${item.id} + '/buildconfig'}">查看</a>
+                       th:attr="data-url=@{'/app/bd/log/build/'+${item.buildLogId} + '/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>
+                       th:attr="data-url=@{'/app/bd/log/build/'+${item.buildLogId} + '/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>
+                       th:attr="data-url=@{'/app/bd/log/build/'+${item.buildLogId} + '/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>
+                    <a class="open-popup" data-title="构建时" data-size="1000,500" href="#"
+                       th:attr="data-url=@{'/app/bd/log/build/'+${item.buildLogId} + '/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>
+                       th:attr="data-url=@{'/app/bd/log/build/'+${item.buildLogId} + '/result'}">查看</a>
                 </td>
                 <td th:text="${item.buildBy}">构建用户</td>
                 <td>
-                    <a class="ajax-post" th:href="@{'/api/app/bd/deploy?appId='+${item.id}}">部署</a>
+                    <a class="open-popup" data-title="部署日志" th:attr="data-url=@{'/app/bd/log/deploy/'+${item.buildLogId}}"
+                       href="#">部署日志</a>
+                    <a class="ajax-post" th:href="@{'/api/app/bd/deploy?appId='+${item.buildLogId}}">部署</a>
                 </td>
             </tr>
             </tbody>

+ 0 - 2
dmaster/src/main/resources/templates/app/bd/log/buildtime.html

@@ -9,7 +9,6 @@
             <th class="sortable" data-field="updateTotalTime">更新耗时(ms)</th>
             <th class="sortable" data-field="compileTotalTime">编译耗时(ms)</th>
             <th class="sortable" data-field="packTotalTime">打包耗时(ms)</th>
-            <th class="sortable" data-field="buildTime">构建时间</th>
         </tr>
         </thead>
         <tbody>
@@ -17,7 +16,6 @@
             <td th:text="${buildTime.updateTotalTime}">更新耗时</td>
             <td th:text="${buildTime.compileTotalTime}">编译耗时</td>
             <td th:text="${buildTime.packTotalTime}">打包耗时</td>
-            <td th:text="${buildTime.buildTime}">构建时间</td>
         </tr>
         </tbody>
     </table>

+ 0 - 8
dmaster/src/main/resources/templates/app/bd/log/commitinfo.html

@@ -5,14 +5,6 @@
 <div class="timo-detail-page">
     <table class="layui-table timo-detail-table">
         <tbody>
-        <tr>
-            <th>远程仓库</th>
-            <td th:text="${commitInfo?.remote}"></td>
-            <th>仓库分支</th>
-            <td th:text="${commitInfo?.branch}"></td>
-            <th>版本 ID</th>
-            <td th:text="${commitInfo?.commitId}"></td>
-        </tr>
         <tr>
             <th>提交用户</th>
             <td th:text="${commitInfo?.commitAuthor}"></td>

+ 0 - 5
dmaster/src/main/resources/templates/app/bd/log/index.html

@@ -46,7 +46,6 @@
                     <th class="sortable" data-field="repoBranch">分支</th>
                     <th class="sortable" data-field="httpPort">HTTP 端口</th>
                     <th class="sortable" data-field="commitId">构建日志</th>
-                    <th class="sortable" data-field="commitTime">部署日志</th>
                 </tr>
                 </thead>
                 <tbody>
@@ -64,10 +63,6 @@
                         <a class="open-popup" data-title="构建日志" th:attr="data-url=@{'/app/bd/log/build/'+${item.appId}}"
                            data-size="max" href="#">查看</a>
                     </td>
-                    <td>
-                        <a class="open-popup" data-title="部署日志" th:attr="data-url=@{'/app/bd/log/deploy/'+${item.appId}}"
-                           href="#">查看</a>
-                    </td>
                 </tr>
                 </tbody>
             </table>