From 1625bff625da419f231650aa7ac4c0704203e5d3 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 5 Nov 2020 14:41:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=97=B6=E5=BC=BA=E5=88=B6=E5=88=A0=E9=99=A4=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/controller/APITestController.java | 5 ++--- .../io/metersphere/api/dto/DeleteAPITestRequest.java | 4 ++++ .../java/io/metersphere/api/service/APITestService.java | 7 +++++-- .../performance/service/PerformanceTestService.java | 4 +++- .../main/java/io/metersphere/service/ProjectService.java | 7 ++++++- .../track/request/testplan/DeleteTestPlanRequest.java | 9 +++++++++ backend/src/main/java/io/metersphere/xpack | 2 +- frontend/src/business/components/xpack | 2 +- 8 files changed, 31 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 0b73d1f183..8a2beaab59 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -104,9 +104,8 @@ public class APITestController { @PostMapping("/delete") public void delete(@RequestBody DeleteAPITestRequest request) { - String testId = request.getId(); - checkownerService.checkApiTestOwner(testId); - apiTestService.delete(testId); + checkownerService.checkApiTestOwner(request.getId()); + apiTestService.delete(request); } @PostMapping(value = "/run") diff --git a/backend/src/main/java/io/metersphere/api/dto/DeleteAPITestRequest.java b/backend/src/main/java/io/metersphere/api/dto/DeleteAPITestRequest.java index c05e6d9f05..fa73ae004b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/DeleteAPITestRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/DeleteAPITestRequest.java @@ -8,4 +8,8 @@ import lombok.Setter; public class DeleteAPITestRequest { private String id; + /** + * 是否强制删除(删除项目时不检查关联关系,强制删除资源) + */ + private boolean forceDelete = false; } diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index cc9238c205..9f4a96bd23 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -193,8 +193,11 @@ public class APITestService { return extApiTestMapper.getApiTestByProjectId(projectId); } - public void delete(String testId) { - testCaseService.checkIsRelateTest(testId); + public void delete(DeleteAPITestRequest request) { + String testId = request.getId(); + if (!request.isForceDelete()) { + testCaseService.checkIsRelateTest(testId); + } deleteFileByTestId(testId); apiReportService.deleteByTestId(testId); scheduleService.deleteByResourceId(testId); diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 251eda42c1..5bd56c5215 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -85,7 +85,9 @@ public class PerformanceTestService { public void delete(DeleteTestPlanRequest request) { String testId = request.getId(); - testCaseService.checkIsRelateTest(testId); + if (!request.isForceDelete()) { + testCaseService.checkIsRelateTest(testId); + } LoadTestReportExample loadTestReportExample = new LoadTestReportExample(); loadTestReportExample.createCriteria().andTestIdEqualTo(testId); diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 292fbf8229..9354f3575d 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -1,5 +1,6 @@ package io.metersphere.service; +import io.metersphere.api.dto.DeleteAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.service.APITestService; import io.metersphere.base.domain.LoadTest; @@ -96,6 +97,7 @@ public class ProjectService { loadTestIdList.forEach(loadTestId -> { DeleteTestPlanRequest deleteTestPlanRequest = new DeleteTestPlanRequest(); deleteTestPlanRequest.setId(loadTestId); + deleteTestPlanRequest.setForceDelete(true); performanceTestService.delete(deleteTestPlanRequest); }); @@ -122,7 +124,10 @@ public class ProjectService { QueryAPITestRequest request = new QueryAPITestRequest(); request.setProjectId(projectId); apiTestService.list(request).forEach(test -> { - apiTestService.delete(test.getId()); + DeleteAPITestRequest deleteAPITestRequest = new DeleteAPITestRequest(); + deleteAPITestRequest.setId(test.getId()); + deleteAPITestRequest.setForceDelete(true); + apiTestService.delete(deleteAPITestRequest); }); } diff --git a/backend/src/main/java/io/metersphere/track/request/testplan/DeleteTestPlanRequest.java b/backend/src/main/java/io/metersphere/track/request/testplan/DeleteTestPlanRequest.java index 25726bf29a..fff9accc2f 100644 --- a/backend/src/main/java/io/metersphere/track/request/testplan/DeleteTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testplan/DeleteTestPlanRequest.java @@ -1,4 +1,13 @@ package io.metersphere.track.request.testplan; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter public class DeleteTestPlanRequest extends TestPlanRequest { + /** + * 是否强制删除(删除项目时不检查关联关系,强制删除资源) + */ + private boolean forceDelete = false; } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 7238c00412..597a1681d1 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 7238c00412997c529a2a28a47956977ebf83aa13 +Subproject commit 597a1681d1327a622b2a38bac3f17ae9daf95442 diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index b9091a47b1..f6f172c645 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit b9091a47b197faef77c72b134b7cf604fe3209f0 +Subproject commit f6f172c6451d0f9c51f5e3246a66dde9edcd7a5d