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 + +