diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioController.java index 4c5c9cb1e9..4697d5a5c6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioController.java @@ -134,11 +134,11 @@ public class ApiScenarioController { return apiScenarioService.get(scenarioId); } - @PostMapping("/step/get") + @GetMapping("/step/get/{stepId}") @Operation(summary = "接口测试-接口场景管理-获取场景步骤详情") @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ) - public Object getStepDetail(@Validated @RequestBody StepRequest request) { - return apiScenarioService.getStepDetail(request); + public Object getStepDetail(@PathVariable String stepId) { + return apiScenarioService.getStepDetail(stepId); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/StepRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/StepRequest.java deleted file mode 100644 index 0fc58716a8..0000000000 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/StepRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.metersphere.api.dto.scenario; - -import io.metersphere.api.constants.ApiScenarioStepType; -import io.metersphere.system.valid.EnumValue; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Size; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -public class StepRequest { - @Schema(description = "步骤id", requiredMode = Schema.RequiredMode.REQUIRED) - @Size(max = 50, message = "{api_scenario_step.id.length_range}") - @NotBlank - private String stepId; - @Schema(description = "资源id", requiredMode = Schema.RequiredMode.REQUIRED) - @Size(max = 50, message = "{api_scenario_step.resource_id.length_range}") - @NotBlank - private String resourceId; - @Schema(description = "步骤类型 API:接口 API_CASE:用例 API_SCENARIO:场景", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank - @EnumValue(enumClass = ApiScenarioStepType.class) - private String stepType; -} - diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java index d07e75a987..991db3eb27 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioService.java @@ -1846,14 +1846,8 @@ public class ApiScenarioService extends MoveNodeService { return extApiScenarioStepMapper.getStepDTOByScenarioIds(scenarioIds); } - public Object getStepDetail(StepRequest request) { - ApiScenarioStep step = apiScenarioStepMapper.selectByPrimaryKey(request.getStepId()); - if (step == null) { - step = new ApiScenarioStep(); - step.setStepType(request.getStepType()); - step.setResourceId(request.getResourceId()); - step.setRefType(ApiScenarioStepRefType.REF.name()); - } + public Object getStepDetail(String stepId) { + ApiScenarioStep step = apiScenarioStepMapper.selectByPrimaryKey(stepId); StepParser stepParser = StepParserFactory.getStepParser(step.getStepType()); Object stepDetail = stepParser.parseDetail(step); if (stepDetail instanceof AbstractMsTestElement msTestElement) { diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java index 8ef61262a8..d162e97178 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioControllerTests.java @@ -95,7 +95,7 @@ public class ApiScenarioControllerTests extends BaseTest { private static final String FOLLOW = "follow/"; protected static final String UPLOAD_TEMP_FILE = "upload/temp/file"; protected static final String DELETE_TO_GC = "delete-to-gc/{0}"; - protected static final String STEP_GET = "step/get"; + protected static final String STEP_GET = "step/get/{0}"; protected static final String DEBUG = "debug"; protected static final String RUN = "run/{0}"; protected static final String RUN_REAL_TIME = "run/{0}?reportId={1}"; @@ -1125,12 +1125,8 @@ public class ApiScenarioControllerTests extends BaseTest { steps = apiScenarioDetail.getSteps(); requestGetStepDetail(steps); - StepRequest stepRequest = new StepRequest(); - stepRequest.setStepId(addApiScenario.getId()); - stepRequest.setStepType("API_SCENARIO"); - stepRequest.setResourceId(addApiScenario.getId()); // @@校验权限 - requestPostPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_READ, STEP_GET, stepRequest); + requestGetPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_READ, STEP_GET, addApiScenario.getId()); } private void requestGetStepDetail(List steps) throws Exception { @@ -1138,11 +1134,7 @@ public class ApiScenarioControllerTests extends BaseTest { return; } for (ApiScenarioStepCommonDTO step : steps) { - StepRequest stepRequest = new StepRequest(); - stepRequest.setStepId(step.getId()); - stepRequest.setStepType(step.getStepType()); - stepRequest.setResourceId(step.getResourceId()); - this.requestPost(STEP_GET, stepRequest); + this.requestGet(STEP_GET, step.getId()); List children = step.getChildren(); requestGetStepDetail(children); } @@ -2630,12 +2622,7 @@ public class ApiScenarioControllerTests extends BaseTest { apiScenarioSystemRequest.setRefType(ApiScenarioStepRefType.COPY.name()); this.requestPostWithOkAndReturn("/get/system-request", apiScenarioSystemRequest); - StepRequest stepRequest = new StepRequest(); - stepRequest.setStepId("system-scenario-id1"); - stepRequest.setStepType(ApiScenarioStepType.API_SCENARIO.name()); - stepRequest.setResourceId("system-scenario-id1"); - - mockMvc.perform(getPostRequestBuilder(STEP_GET, stepRequest)) + mockMvc.perform(getRequestBuilder(STEP_GET, "system-scenario-id1")) .andExpect(status().isOk()); }