From 6f93e09f4749f406d7326258c534e18c9a100553 Mon Sep 17 00:00:00 2001 From: Coooder-X <55648333+Coooder-X@users.noreply.github.com> Date: Tue, 26 Jan 2021 17:21:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E3=80=81=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96)=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A8=A1=E5=9D=97=E6=97=B6=EF=BC=8C=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=B8=8B=E7=9A=84=E6=89=80=E6=9C=89=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=88=96=E5=9C=BA=E6=99=AF=E8=A2=AB=E6=94=BE=E5=85=A5=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E7=AB=99=20(#1268)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiAutomationService.java | 6 +++ .../api/service/ApiModuleService.java | 2 +- .../api/service/ApiScenarioModuleService.java | 2 +- .../mapper/ext/ExtApiDefinitionMapper.java | 4 ++ .../mapper/ext/ExtApiDefinitionMapper.xml | 9 +++++ .../base/mapper/ext/ExtApiScenarioMapper.java | 3 ++ .../base/mapper/ext/ExtApiScenarioMapper.xml | 38 +++++++++++++++++++ 7 files changed, 62 insertions(+), 2 deletions(-) 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