|
|
@@ -18,9 +18,7 @@ import seecoder.devcloud.web.model.vo.project.BugListVO;
|
|
|
import seecoder.devcloud.web.service.project.BugListService;
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -52,29 +50,33 @@ public class BugListServiceImpl implements BugListService {
|
|
|
.description(vo.getDescription())
|
|
|
.timeToTake(vo.getTimeToTake())
|
|
|
.state(BugListStateEnum.CREATED)
|
|
|
+ .startTime(new Timestamp(System.currentTimeMillis()))
|
|
|
.priority(vo.getPriority())
|
|
|
- .startTime(new Timestamp(new Date().getTime()))
|
|
|
.endTime(null)
|
|
|
.projectId(vo.getProjectId())
|
|
|
.build();
|
|
|
- bugListMapper.insert(po, "startTime");
|
|
|
+ bugListMapper.insert(po);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<BugListVO> list(Integer projectId) {
|
|
|
List<BugListPO> bugs = bugListMapper.selectByProjectId(projectId);
|
|
|
List<CommitPO> commits = commitMapper.selectByProjectIdAndType(projectId, CommitRelatedType.BUG_ID);
|
|
|
- Map<Integer,List<CommitPO>> commitsMap = commits.stream().collect(Collectors.groupingBy(CommitPO::getRelatedId));
|
|
|
- List<UserPO> users = userMapper.selectByIds(bugs.stream().map(BugListPO::getProcessorId).collect(Collectors.toList()));
|
|
|
- Map<Integer,String> usernameMap = users.stream().collect(Collectors.toMap(UserPO::getId, UserPO::getUsername));
|
|
|
- return bugs.stream().map(x->new BugListVO(x,commitsMap.get(x.getId()),usernameMap.get(x.getProcessorId()))).collect(Collectors.toList());
|
|
|
+ Map<Integer, List<CommitPO>> commitsMap = commits.stream().collect(Collectors.groupingBy(CommitPO::getRelatedId));
|
|
|
+ List<Integer> userIds = bugs.stream().map(x -> {
|
|
|
+ Integer userId = x.getProcessorId();
|
|
|
+ return userId != null? userId : -1;
|
|
|
+ }).filter(x -> x!=-1).collect(Collectors.toList());
|
|
|
+ List<UserPO> users = userIds.size()==0? new ArrayList<>() :userMapper.selectByIds(userIds);
|
|
|
+ Map<Integer, String> usernameMap = users.stream().collect(Collectors.toMap(UserPO::getId, UserPO::getUsername));
|
|
|
+ return bugs.stream().map(x -> new BugListVO(x, commitsMap.getOrDefault(x.getId(),new ArrayList<>()), usernameMap.getOrDefault(x.getProcessorId(), "no one"))).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void updateBasicInfo(BugListUpdateBasicVO vo) {
|
|
|
BugListPO po = BugListPO.builder().build();
|
|
|
- BeanUtils.copyProperties(vo,po);
|
|
|
+ BeanUtils.copyProperties(vo, po);
|
|
|
bugListMapper.update(po);
|
|
|
}
|
|
|
|
|
|
@@ -82,7 +84,7 @@ public class BugListServiceImpl implements BugListService {
|
|
|
public void updateState(CommitState state, Integer id) {
|
|
|
BugListPO po = new BugListPO();
|
|
|
po.setId(id);
|
|
|
- switch (state){
|
|
|
+ switch (state) {
|
|
|
case FIXING_ON:
|
|
|
po.setState(BugListStateEnum.PROCESSING);
|
|
|
break;
|