fix(测试跟踪): 修复删除计划关联项目,测试计划也被删除的问题

This commit is contained in:
shiziyuan9527 2021-02-08 14:29:02 +08:00
parent f3e0eb5b9d
commit f233d8d5cb
2 changed files with 17 additions and 14 deletions

View File

@ -180,6 +180,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId); List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId);
projectIds.forEach(id -> { projectIds.forEach(id -> {
Project project = projectMapper.selectByPrimaryKey(id); Project project = projectMapper.selectByPrimaryKey(id);
if (project != null) {
String name = project.getName(); String name = project.getName();
List<TestCaseNodeDTO> nodeList = getNodeDTO(id, planId); List<TestCaseNodeDTO> nodeList = getNodeDTO(id, planId);
TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO(); TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO();
@ -188,6 +189,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
testCaseNodeDTO.setLabel(name); testCaseNodeDTO.setLabel(name);
testCaseNodeDTO.setChildren(nodeList); testCaseNodeDTO.setChildren(nodeList);
list.add(testCaseNodeDTO); list.add(testCaseNodeDTO);
}
}); });
return list; return list;

View File

@ -62,15 +62,16 @@ public class TestPlanProjectService {
} }
public List<String> getPlanIdByProjectId(String projectId) { public List<String> getPlanIdByProjectId(String projectId) {
TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample(); TestPlanExample testPlanExample = new TestPlanExample();
testPlanProjectExample.createCriteria().andProjectIdEqualTo(projectId); testPlanExample.createCriteria().andProjectIdEqualTo(projectId);
List<TestPlanProject> testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample); List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
if (CollectionUtils.isEmpty(testPlanProjects)) {
if (CollectionUtils.isEmpty(testPlans)) {
return null; return null;
} }
return testPlanProjects return testPlans
.stream() .stream()
.map(TestPlanProject::getTestPlanId) .map(TestPlan::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }