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 51299f2b62..9c240af323 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -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 apiDefinitions = apiDefinitionMapper.selectByExample(example); + List ids = apiDefinitions.stream().map(ApiDefinition::getId).collect(Collectors.toList()); + + ApiTestCaseExample apiTestCaseExample = new ApiTestCaseExample(); + apiTestCaseExample.createCriteria().andApiDefinitionIdIn(ids); + apiTestCaseMapper.deleteByExample(apiTestCaseExample); + // apiDefinitionMapper.deleteByExample(example); }