From 2918fc8a61bc64b47fca5797257b7a39a6a25b72 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 23 Sep 2021 11:43:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=9E=E6=94=B6=E7=AB=99=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=88=A0=E9=99=A4=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/service/ApiDefinitionService.java | 2 ++ .../metersphere/api/service/ApiTestCaseService.java | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 716ec384f4..2d33732757 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -220,6 +220,7 @@ public class ApiDefinitionService { example.createCriteria().andIdIn(apiIds); esbApiParamService.deleteByResourceIdIn(apiIds); apiDefinitionMapper.deleteByExample(example); + apiTestCaseService.deleteBatchByDefinitionId(apiIds); } public void removeToGc(List apiIds) { @@ -1051,6 +1052,7 @@ public class ApiDefinitionService { public void deleteByParams(ApiBatchRequest request) { apiDefinitionMapper.deleteByExample(getBatchExample(request)); + apiTestCaseService.deleteBatchByDefinitionId(request.getIds()); } public ApiDefinitionExample getBatchExample(ApiBatchRequest request) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 1e99bd08b3..a73c4f3b89 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -433,6 +433,17 @@ public class ApiTestCaseService { apiTestCaseMapper.deleteByExample(example); } + public void deleteBatchByDefinitionId(List definitionIds) { + ApiTestCaseExample example = new ApiTestCaseExample(); + example.createCriteria().andApiDefinitionIdIn(definitionIds); + apiTestCaseMapper.deleteByExample(example); + List apiTestCases = apiTestCaseMapper.selectByExample(example); + List caseIds = apiTestCases.stream().map(ApiTestCase::getId).collect(Collectors.toList()); + for (String testId : caseIds) { + extTestPlanTestCaseMapper.deleteByTestCaseID(testId); + } + } + public void relevanceByApi(ApiCaseRelevanceRequest request) { if (CollectionUtils.isEmpty(request.getSelectIds())) { return;