|
|
@@ -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
|