diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 96278e134a..a8a190bf6e 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -124,6 +124,12 @@ public class ApiAutomationService { apiScenarioMapper.deleteByExample(example); } + public void removeToGcByIds(List nodeIds) { + ApiScenarioExample example = new ApiScenarioExample(); + example.createCriteria().andApiScenarioModuleIdIn(nodeIds); + extApiScenarioMapper.removeToGcByExample(example); + } + public ApiScenario create(SaveApiScenarioRequest request, List bodyFiles) { request.setId(UUID.randomUUID().toString()); checkNameExist(request); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index aa93724dae..b80947b793 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -240,7 +240,7 @@ public class ApiModuleService extends NodeTreeService { public int deleteNode(List nodeIds) { ApiDefinitionExample apiDefinitionExample = new ApiDefinitionExample(); apiDefinitionExample.createCriteria().andModuleIdIn(nodeIds); - apiDefinitionMapper.deleteByExample(apiDefinitionExample); + extApiDefinitionMapper.removeToGcByExample(apiDefinitionExample); // 删除模块,则模块下的接口放入回收站 ApiModuleExample apiDefinitionNodeExample = new ApiModuleExample(); apiDefinitionNodeExample.createCriteria().andIdIn(nodeIds); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index 94a62fb6e7..6445f7d13a 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -194,7 +194,7 @@ public class ApiScenarioModuleService extends NodeTreeService nodeIds) { - apiAutomationService.deleteByIds(nodeIds); + apiAutomationService.removeToGcByIds(nodeIds); ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample(); apiScenarioModuleExample.createCriteria().andIdIn(nodeIds); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index 7c0156407f..d523317de7 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -6,6 +6,8 @@ import io.metersphere.api.dto.definition.ApiDefinitionRequest; import io.metersphere.api.dto.definition.ApiDefinitionResult; import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO; import io.metersphere.base.domain.ApiDefinition; +import io.metersphere.base.domain.ApiDefinitionExample; +import io.metersphere.base.domain.ApiModuleExample; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -19,6 +21,8 @@ public interface ExtApiDefinitionMapper { int removeToGc(@Param("ids") List ids); + int removeToGcByExample(ApiDefinitionExample example); + int reduction(@Param("ids") List ids); List countProtocolByProjectID(String projectId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index cc3ead40b4..3a61cea026 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -311,6 +311,15 @@ + + update api_definition + set + status = 'Trash', module_path = null, module_id = null + + + + + update api_definition set diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java index 7645843c99..07ea9c380d 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java @@ -4,6 +4,7 @@ import io.metersphere.api.dto.automation.ApiScenarioDTO; import io.metersphere.api.dto.automation.ApiScenarioRequest; import io.metersphere.api.dto.datacount.ApiDataCountResult; import io.metersphere.base.domain.ApiScenario; +import io.metersphere.base.domain.ApiScenarioExample; import io.metersphere.base.domain.ApiScenarioWithBLOBs; import org.apache.ibatis.annotations.Param; @@ -20,6 +21,8 @@ public interface ExtApiScenarioMapper { int removeToGc(@Param("ids") List ids); + int removeToGcByExample(ApiScenarioExample example); + int reduction(@Param("ids") List ids); long countByProjectID(String projectId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index 56556c85dd..1f391c031a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -7,6 +7,35 @@ + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + @@ -243,6 +272,15 @@ + + update api_scenario + set + status = 'Trash', module_path = null, api_scenario_module_id = null + + + + + update api_scenario set