diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionController.java index acaf59d400..b6553ca475 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionController.java @@ -11,7 +11,6 @@ import io.metersphere.api.dto.request.ApiEditPosRequest; import io.metersphere.api.dto.request.ApiTransferRequest; import io.metersphere.api.dto.request.ImportRequest; import io.metersphere.api.dto.scenario.ApiFileCopyRequest; -import io.metersphere.api.dto.scenario.ApiScenarioStepFileCopyRequest; import io.metersphere.api.dto.schema.JsonSchemaItem; import io.metersphere.api.mapper.ExtApiDefinitionMapper; import io.metersphere.api.mapper.ExtApiScenarioStepMapper; @@ -109,8 +108,8 @@ public class ApiDefinitionController { // 获取 API 定义、测试用例 ID 和场景步骤中的 API ID List apiDefinitionIdFromCase = extApiTestCaseMapper.selectApiId(projectId); - List apiInScenarioStep = new ArrayList<>(extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API.name(), null)); - List apiCaseIdInStep = extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API_CASE.name(), null); + List apiInScenarioStep = new ArrayList<>(extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API.name())); + List apiCaseIdInStep = extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API_CASE.name()); // 如果有场景步骤中的 API 用例 ID,追加相关 API ID if (CollectionUtils.isNotEmpty(apiCaseIdInStep)) { diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.java index a775258480..9cc50ea09b 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.java @@ -26,7 +26,11 @@ public interface ExtApiScenarioStepMapper { */ List getHasBlobRequestStepIds(@Param("scenarioId") String scenarioId); - List selectResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType, @Param("protocols") List apiProtocols); + List selectResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType); + + List selectApiResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType, List protocols); + + List selectApiCaseResourceId(@Param("projectId") String projectId, @Param("stepType") String stepType, List protocols); List selectCustomRequestConfigByProjectId(String projectId); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.xml index d5a8b0c611..ce461ad616 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioStepMapper.xml @@ -36,6 +36,35 @@ where step.step_type = #{stepType} AND scenario.project_id = #{projectId} AND scenario.deleted IS FALSE + + + + + \ No newline at end of file diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java index 3963f0ce5f..a4b005ca99 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java @@ -201,8 +201,8 @@ public class ApiDefinitionService extends MoveNodeService { private List selectApiIdInScenarioStep(String projectId, List protocols, List ignoreApiIds) { - List apiInScenarioStep = new ArrayList<>(extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API.name(), protocols)); - List apiCaseIdInStep = extApiScenarioStepMapper.selectResourceId(projectId, ApiScenarioStepType.API_CASE.name(), protocols); + List apiInScenarioStep = extApiScenarioStepMapper.selectApiResourceId(projectId, ApiScenarioStepType.API.name(), protocols); + List apiCaseIdInStep = extApiScenarioStepMapper.selectApiCaseResourceId(projectId, ApiScenarioStepType.API_CASE.name(), protocols); // 如果有场景步骤中的 API 用例 ID,追加相关 API ID if (CollectionUtils.isNotEmpty(apiCaseIdInStep)) { List apiCaseIdInScenarioStep = extApiTestCaseMapper.selectApiIdByCaseId(apiCaseIdInStep, protocols, ignoreApiIds);