mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 21:19:52 +08:00
fix: 删除项目时强制删除项目下的资源
This commit is contained in:
parent
3a311dba44
commit
1625bff625
@ -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")
|
||||
|
@ -8,4 +8,8 @@ import lombok.Setter;
|
||||
public class DeleteAPITestRequest {
|
||||
|
||||
private String id;
|
||||
/**
|
||||
* 是否强制删除(删除项目时不检查关联关系,强制删除资源)
|
||||
*/
|
||||
private boolean forceDelete = false;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7238c00412997c529a2a28a47956977ebf83aa13
|
||||
Subproject commit 597a1681d1327a622b2a38bac3f17ae9daf95442
|
@ -1 +1 @@
|
||||
Subproject commit b9091a47b197faef77c72b134b7cf604fe3209f0
|
||||
Subproject commit f6f172c6451d0f9c51f5e3246a66dde9edcd7a5d
|
Loading…
Reference in New Issue
Block a user