From bbd3138808838172185ae8ef31935f5d1a8e47ec Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 8 Jun 2022 15:18:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=84=91=E5=9B=BE=E5=88=A0=E9=99=A4=E6=A8=A1=E5=9D=97=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1013880 --user=陈建星 【测试跟踪】脑图 模块 删除后保存 报错 https://www.tapd.cn/55049933/s/1176300 --- .../track/service/TestCaseService.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 033c197ff2..b77f1f1311 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -239,13 +239,19 @@ public class TestCaseService { } } - public void addDemandHyperLinkBatch(List testcaseIds) { + public void addDemandHyperLinkBatch(List testcaseIds, String projectId) { if (CollectionUtils.isEmpty(testcaseIds)) { return; } - TestCaseWithBLOBs testCase = testCaseMapper.selectByPrimaryKey(testcaseIds.get(0)); - // 同步删除用例与需求的关联关系 - Project project = projectService.getProjectById(testCase.getProjectId()); + + Project project; + if (StringUtils.isNotBlank(projectId)) { + project = projectService.getProjectById(projectId); + } else { + TestCaseWithBLOBs testCase = testCaseMapper.selectByPrimaryKey(testcaseIds.get(0)); + // 同步删除用例与需求的关联关系 + project = projectService.getProjectById(testCase.getProjectId()); + } // AzureDevops 才处理 if (StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) { @@ -639,6 +645,10 @@ public class TestCaseService { } public int deleteToGcBatch(List ids) { + return deleteToGcBatch(ids, null); + } + + public int deleteToGcBatch(List ids, String projectId) { if (CollectionUtils.isEmpty(ids)) { return 0; } @@ -646,7 +656,7 @@ public class TestCaseService { testCase.setDeleteUserId(SessionUtils.getUserId()); testCase.setDeleteTime(System.currentTimeMillis()); - addDemandHyperLinkBatch(ids); + addDemandHyperLinkBatch(ids, projectId); DeleteTestCaseRequest request = new DeleteTestCaseRequest(); BeanUtils.copyBean(request, testCase); @@ -1943,7 +1953,7 @@ public class TestCaseService { public void minderEdit(TestCaseMinderEditRequest request) { - deleteToGcBatch(request.getIds()); + deleteToGcBatch(request.getIds(), request.getProjectId()); testCaseNodeService.minderEdit(request);