fix: 删除接口时删除关联的用例

This commit is contained in:
CaptainB 2022-01-20 17:15:20 +08:00 committed by xiaomeinvG
parent b8edfe2532
commit 685b31ed44
1 changed files with 7 additions and 0 deletions

View File

@ -1864,6 +1864,13 @@ public class ApiDefinitionService {
public void deleteApiDefinitionByVersion(String refId, String version) {
ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria().andRefIdEqualTo(refId).andVersionIdEqualTo(version);
List<ApiDefinition> apiDefinitions = apiDefinitionMapper.selectByExample(example);
List<String> ids = apiDefinitions.stream().map(ApiDefinition::getId).collect(Collectors.toList());
ApiTestCaseExample apiTestCaseExample = new ApiTestCaseExample();
apiTestCaseExample.createCriteria().andApiDefinitionIdIn(ids);
apiTestCaseMapper.deleteByExample(apiTestCaseExample);
//
apiDefinitionMapper.deleteByExample(example);
}