fix: 回收站批量删除接口定义没有删除用例

This commit is contained in:
chenjianxing 2021-09-23 11:43:13 +08:00 committed by jianxing
parent 9d347826ce
commit 2918fc8a61
2 changed files with 13 additions and 0 deletions

View File

@ -220,6 +220,7 @@ public class ApiDefinitionService {
example.createCriteria().andIdIn(apiIds); example.createCriteria().andIdIn(apiIds);
esbApiParamService.deleteByResourceIdIn(apiIds); esbApiParamService.deleteByResourceIdIn(apiIds);
apiDefinitionMapper.deleteByExample(example); apiDefinitionMapper.deleteByExample(example);
apiTestCaseService.deleteBatchByDefinitionId(apiIds);
} }
public void removeToGc(List<String> apiIds) { public void removeToGc(List<String> apiIds) {
@ -1051,6 +1052,7 @@ public class ApiDefinitionService {
public void deleteByParams(ApiBatchRequest request) { public void deleteByParams(ApiBatchRequest request) {
apiDefinitionMapper.deleteByExample(getBatchExample(request)); apiDefinitionMapper.deleteByExample(getBatchExample(request));
apiTestCaseService.deleteBatchByDefinitionId(request.getIds());
} }
public ApiDefinitionExample getBatchExample(ApiBatchRequest request) { public ApiDefinitionExample getBatchExample(ApiBatchRequest request) {

View File

@ -433,6 +433,17 @@ public class ApiTestCaseService {
apiTestCaseMapper.deleteByExample(example); apiTestCaseMapper.deleteByExample(example);
} }
public void deleteBatchByDefinitionId(List<String> definitionIds) {
ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andApiDefinitionIdIn(definitionIds);
apiTestCaseMapper.deleteByExample(example);
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
List<String> caseIds = apiTestCases.stream().map(ApiTestCase::getId).collect(Collectors.toList());
for (String testId : caseIds) {
extTestPlanTestCaseMapper.deleteByTestCaseID(testId);
}
}
public void relevanceByApi(ApiCaseRelevanceRequest request) { public void relevanceByApi(ApiCaseRelevanceRequest request) {
if (CollectionUtils.isEmpty(request.getSelectIds())) { if (CollectionUtils.isEmpty(request.getSelectIds())) {
return; return;