From c15a5881c22a0f0576f3524cc77f416a5a16237d Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 9 Oct 2024 18:17:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9C=BA=E6=99=AF=E5=AF=BC=E5=85=A5=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=8F=82=E6=95=B0=E6=A8=A1=E5=9D=97=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiScenarioSelectAssociateController.java | 35 ++++ .../ApiScenarioSelectAssociateDTO.java | 7 + .../api/mapper/ExtApiDefinitionMapper.java | 7 +- .../api/mapper/ExtApiDefinitionMapper.xml | 8 +- .../api/mapper/ExtApiScenarioMapper.java | 1 + .../api/mapper/ExtApiScenarioMapper.xml | 13 ++ .../api/mapper/ExtApiTestCaseMapper.xml | 15 +- .../ApiScenarioSelectAssociateService.java | 192 +++++++++++++++--- .../service/scenario/ApiScenarioService.java | 14 +- ...cenarioSelectAssociateControllerTests.java | 115 +++++++++++ 10 files changed, 369 insertions(+), 38 deletions(-) create mode 100644 backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioSelectAssociateController.java create mode 100644 backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiScenarioSelectAssociateControllerTests.java diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioSelectAssociateController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioSelectAssociateController.java new file mode 100644 index 0000000000..274d791465 --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/scenario/ApiScenarioSelectAssociateController.java @@ -0,0 +1,35 @@ +package io.metersphere.api.controller.scenario; + +import io.metersphere.api.dto.scenario.ApiScenarioSelectAssociateDTO; +import io.metersphere.api.dto.scenario.ApiScenarioStepDTO; +import io.metersphere.api.service.scenario.ApiScenarioSelectAssociateService; +import io.metersphere.sdk.constants.PermissionConstants; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping(value = "/api/scenario/associate") +@Tag(name = "接口测试-接口场景管理-场景导入系统参数") +public class ApiScenarioSelectAssociateController { + + @Resource + private ApiScenarioSelectAssociateService apiScenarioSelectAssociateService; + + + @PostMapping("/all") + @Operation(summary = "接口场景管理-场景导入系统参数") + @RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_UPDATE) + public List getSelectDto(@Validated @RequestBody Map requestMap) { + return apiScenarioSelectAssociateService.getSelectDto(requestMap); + } +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioSelectAssociateDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioSelectAssociateDTO.java index c6d698a43b..2b75de620e 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioSelectAssociateDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/scenario/ApiScenarioSelectAssociateDTO.java @@ -1,5 +1,7 @@ package io.metersphere.api.dto.scenario; +import io.metersphere.api.constants.ApiScenarioStepRefType; +import io.metersphere.sdk.valid.EnumValue; import io.metersphere.system.dto.ModuleSelectDTO; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; @@ -29,6 +31,11 @@ public class ApiScenarioSelectAssociateDTO implements Serializable { @Schema(description = "模块下的id集合属性", requiredMode = Schema.RequiredMode.REQUIRED) private Map moduleMaps; + @Schema(description = "关联类型 COPY:复制 REF:引用") + @EnumValue(enumClass = ApiScenarioStepRefType.class) + @NotBlank + private String refType; + @Schema(description = "关联关系的type(接口定义:API/接口用例:API_CASE/场景:API_SCENARIO)", requiredMode = Schema.RequiredMode.REQUIRED) private String associateType; diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java index 293683d1b8..73433bb88e 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.java @@ -20,6 +20,7 @@ import java.util.List; public interface ExtApiDefinitionMapper { void deleteApiToGc(@Param("ids") List ids, @Param("userId") String userId, @Param("time") long time); + @BaseConditionFilter List list(@Param("request") ApiDefinitionPageRequest request); @@ -94,10 +95,10 @@ public interface ExtApiDefinitionMapper { List selectApiDefinitionWithBlob(@Param("ids") List ids); - List selectAllApi(@Param("projectId") String projectId, @Param("protocols") List protocols); + List selectAllApi(@Param("projectId") String projectId, @Param("protocols") List protocols); - List getListBySelectModules(@Param("projectId") String projectId, @Param("moduleIds") List moduleIds, @Param("protocols") List protocols); + List getListBySelectModules(@Param("projectId") String projectId, @Param("moduleIds") List moduleIds, @Param("protocols") List protocols); - List getListBySelectIds(@Param("ids") List ids, @Param("protocols") List protocols); + List getListBySelectIds(@Param("projectId") String projectId, @Param("ids") List ids, @Param("protocols") List protocols); } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml index 32f8dca35c..9012a46e1d 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionMapper.xml @@ -680,12 +680,14 @@ - select api_definition.id, api_definition.name, api_definition.method, api_definition.num, + api_definition.project_id, + api_definition.version_id, api_definition.pos from api_definition where api_definition.deleted = false @@ -705,6 +707,8 @@ api_definition.name, api_definition.method, api_definition.num, + api_definition.project_id, + api_definition.version_id, api_definition.pos from api_definition where api_definition.deleted = false @@ -727,6 +731,8 @@ api_definition.name, api_definition.method, api_definition.num, + api_definition.project_id, + api_definition.version_id, api_definition.pos from api_definition where api_definition.deleted = false diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java index d45d8a5c18..d66582d5d1 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.java @@ -89,6 +89,7 @@ public interface ExtApiScenarioMapper { List selectAllCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId); + List selectAllCaseExcludeSelf(@Param("projectId") String projectId); List getListBySelectModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("moduleIds") List moduleIds, @Param("testPlanId") String testPlanId); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml index b82025f538..c8ac6e11b2 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiScenarioMapper.xml @@ -698,6 +698,19 @@ order by api_scenario.pos asc + +