From f233d8d5cbd6419937af3728a82af313465e3609 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 8 Feb 2021 14:29:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4=E8=AE=A1=E5=88=92=E5=85=B3?= =?UTF-8?q?=E8=81=94=E9=A1=B9=E7=9B=AE=EF=BC=8C=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E4=B9=9F=E8=A2=AB=E5=88=A0=E9=99=A4=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestCaseNodeService.java | 18 ++++++++++-------- .../track/service/TestPlanProjectService.java | 13 +++++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index 5f41d6c6b1..fedd336094 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -180,14 +180,16 @@ public class TestCaseNodeService extends NodeTreeService { List projectIds = testPlanProjectService.getProjectIdsByPlanId(planId); projectIds.forEach(id -> { Project project = projectMapper.selectByPrimaryKey(id); - String name = project.getName(); - List nodeList = getNodeDTO(id, planId); - TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO(); - testCaseNodeDTO.setId(project.getId()); - testCaseNodeDTO.setName(name); - testCaseNodeDTO.setLabel(name); - testCaseNodeDTO.setChildren(nodeList); - list.add(testCaseNodeDTO); + if (project != null) { + String name = project.getName(); + List nodeList = getNodeDTO(id, planId); + TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO(); + testCaseNodeDTO.setId(project.getId()); + testCaseNodeDTO.setName(name); + testCaseNodeDTO.setLabel(name); + testCaseNodeDTO.setChildren(nodeList); + list.add(testCaseNodeDTO); + } }); return list; diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java index ee74dd65b5..bb8b69ee18 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java @@ -62,15 +62,16 @@ public class TestPlanProjectService { } public List getPlanIdByProjectId(String projectId) { - TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample(); - testPlanProjectExample.createCriteria().andProjectIdEqualTo(projectId); - List testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample); - if (CollectionUtils.isEmpty(testPlanProjects)) { + TestPlanExample testPlanExample = new TestPlanExample(); + testPlanExample.createCriteria().andProjectIdEqualTo(projectId); + List testPlans = testPlanMapper.selectByExample(testPlanExample); + + if (CollectionUtils.isEmpty(testPlans)) { return null; } - return testPlanProjects + return testPlans .stream() - .map(TestPlanProject::getTestPlanId) + .map(TestPlan::getId) .collect(Collectors.toList()); } }