فهرست منبع

fix: 流水线列表空值情况

370774330@qq.com 5 سال پیش
والد
کامیت
226c81ffe8

+ 1 - 1
web/src/main/java/seecoder/devcloud/web/controller/project/BugListController.java

@@ -48,7 +48,7 @@ public class BugListController {
     @PutMapping
     @ApiOperation(value = "更新bug list基本信息, 不需要更新的信息不需要填", httpMethod = "PUT")
     @ApiImplicitParam(value = "bugListUpdateBasicVO", dataType = "object", paramType = "body")
-    Response updateBasicInfo(@RequestBody BugListUpdateBasicVO bugListUpdateBasicVO){
+    public Response updateBasicInfo(@RequestBody BugListUpdateBasicVO bugListUpdateBasicVO){
         bugListService.updateBasicInfo(bugListUpdateBasicVO);
         return Response.buildSuccess();
     }

+ 2 - 5
web/src/main/java/seecoder/devcloud/web/dao/pipeline/DeploymentMapper.java

@@ -1,9 +1,6 @@
 package seecoder.devcloud.web.dao.pipeline;
 
-import org.apache.ibatis.annotations.InsertProvider;
-import org.apache.ibatis.annotations.Options;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.UpdateProvider;
+import org.apache.ibatis.annotations.*;
 import org.springframework.stereotype.Repository;
 import seecoder.devcloud.web.dao.provider.GeneralInsertUpdateSqlProvider;
 import seecoder.devcloud.web.model.po.pipeline.DeploymentPO;
@@ -35,6 +32,6 @@ public interface DeploymentMapper {
             "   WHERE pipeline_id in" +
             "   <foreach collection='ids' open='(' item='id' separator=',' close=')'> #{id}</foreach>" +
             "</script>")
-    List<DeploymentPO> selectByPipelineIds(List<Integer> ids);
+    List<DeploymentPO> selectByPipelineIds(@Param("ids") List<Integer> ids);
 
 }

+ 5 - 5
web/src/main/java/seecoder/devcloud/web/dao/pipeline/PipelineHistoryMapper.java

@@ -19,7 +19,7 @@ public interface PipelineHistoryMapper {
     @Options(useGeneratedKeys = true, keyProperty = "param1.id", keyColumn = "id")
     void insert(PipelineHistoryPO pipelineHistoryPO, String... ignoredCols);
 
-    @UpdateProvider(type= GeneralInsertUpdateSqlProvider.class, method="updateById")
+    @UpdateProvider(type = GeneralInsertUpdateSqlProvider.class, method = "updateById")
     int update(PipelineHistoryPO pipelineHistoryPO);
 
 
@@ -31,10 +31,10 @@ public interface PipelineHistoryMapper {
      * 获取一个项目里所有流水线配置的最新构建历史
      */
     @Select("<script>" +
-            "SELECT *" +
-            "FROM   pipeline_history" +
-            "WHERE  startTime=" +
-            "(  SELECT MAX(startTime) " +
+            "SELECT * " +
+            " FROM   pipeline_history " +
+            " WHERE  start_time = " +
+            "(  SELECT MAX(start_time) " +
             "   FROM pipeline_history" +
             "   WHERE pipeline_id in" +
             "   <foreach collection='pipelineIds' open='(' item='pipelineId' separator=',' close=')'> #{pipelineId}</foreach>" +

+ 7 - 5
web/src/main/java/seecoder/devcloud/web/model/vo/pipeline/PipelineInfoVO.java

@@ -43,13 +43,15 @@ public class PipelineInfoVO {
     String details;
 
     public PipelineInfoVO(PipelinePO pipelinePO, PipelineHistoryPO pipelineHistoryPO, String username){
-        startTime = pipelineHistoryPO.getStartTime();
-        userId = pipelineHistoryPO.getUserId();
-        result = pipelineHistoryPO.getResult();
-        details = pipelineHistoryPO.getDetails();
+        if (pipelineHistoryPO != null && username != null){
+            startTime = pipelineHistoryPO.getStartTime();
+            userId = pipelineHistoryPO.getUserId();
+            result = pipelineHistoryPO.getResult();
+            details = pipelineHistoryPO.getDetails();
+            this.username = username;
+        }
         name = pipelinePO.getName();
         id = pipelinePO.getId();
-        this.username = username;
     }
 
 }

+ 13 - 1
web/src/main/java/seecoder/devcloud/web/service/impl/pipeline/PipelineServiceImpl.java

@@ -16,6 +16,7 @@ import seecoder.devcloud.web.model.po.user.UserPO;
 import seecoder.devcloud.web.model.vo.pipeline.*;
 import seecoder.devcloud.web.service.pipeline.PipelineService;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -51,6 +52,10 @@ public class PipelineServiceImpl implements PipelineService {
         //projectAuthentication(projectId);
         // 获取项目所关联的所有流水线
         List<PipelinePO> pipelinePOS = pipelineMapper.selectByProjectId(projectId);
+        if (pipelinePOS.size() == 0){
+            return new ArrayList<>();
+        }
+
         List<Integer> pipelineIds = pipelinePOS.stream().map(PipelinePO::getId).collect(Collectors.toList());
         // 获取流水线历史
         List<PipelineHistoryPO> histories = pipelineHistoryMapper.selectPipelinesRecentlyHistory(pipelineIds);
@@ -58,7 +63,14 @@ public class PipelineServiceImpl implements PipelineService {
         // 获取流水线历史中具体执行人信息
         List<Integer> userIds = histories.stream().map(PipelineHistoryPO::getUserId).collect(Collectors.toList());
         Map<Integer, String> usernameMap =  userMapper.selectByIds(userIds).stream().collect(Collectors.toMap(UserPO::getId, UserPO::getUsername));
-        return pipelinePOS.stream().map(x->new PipelineInfoVO(x,historyMap.get(x.getId()),usernameMap.get(historyMap.get(x.getId()).getUserId()))).collect(Collectors.toList());
+        return pipelinePOS.stream().map(x->{
+            PipelineHistoryPO pipelineHistoryPO = historyMap.getOrDefault(x.getId(),null);
+            if (pipelineHistoryPO == null){
+                return new PipelineInfoVO(x,null,null);
+            }
+            String username = usernameMap.get(pipelineHistoryPO.getUserId());
+            return new PipelineInfoVO(x,pipelineHistoryPO,username);
+        }).collect(Collectors.toList());
     }
 
     @Override