From 2f0ff19744fe0c94bc7079430507245cef87ac93 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 12 Jan 2024 19:58:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E7=8E=AF=E5=A2=83=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=A8=A1=E5=9D=97=E6=A0=91=E5=92=8C=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tParameters.java => ProjectParameter.java} | 10 +- ...mple.java => ProjectParameterExample.java} | 4 +- .../sdk/mapper/ProjectParameterMapper.java | 41 +++++++ ...sMapper.xml => ProjectParameterMapper.xml} | 56 +++++----- .../sdk/mapper/ProjectParametersMapper.java | 40 ------- .../migration/3.0.0/ddl/V3.0.0_2__sdk_ddl.sql | 4 +- .../api/constants/ModuleStatus.java | 5 + .../ApiDefinitionModuleController.java | 8 ++ .../api/dto/definition/ApiModuleDTO.java | 14 +++ .../dto/definition/EnvApiModuleRequest.java | 18 ++++ .../api/dto/definition/EnvApiTreeDTO.java | 16 +++ .../mapper/ExtApiDefinitionModuleMapper.java | 1 + .../ApiDefinitionModuleService.java | 59 ++++++++++ .../ApiDefinitionModuleControllerTests.java | 50 +++++++++ .../controller/GlobalParamsController.java | 6 +- .../CleanupEnvironmentResourceService.java | 4 +- .../project/service/EnvironmentService.java | 3 - .../service/GlobalParamsLogService.java | 11 +- .../project/service/GlobalParamsService.java | 102 +++++++++--------- .../EnvironmentControllerTests.java | 3 - .../GlobalParamsControllerTests.java | 32 +++--- 21 files changed, 326 insertions(+), 161 deletions(-) rename backend/framework/domain/src/main/java/io/metersphere/sdk/domain/{ProjectParameters.java => ProjectParameter.java} (87%) rename backend/framework/domain/src/main/java/io/metersphere/sdk/domain/{ProjectParametersExample.java => ProjectParameterExample.java} (99%) create mode 100644 backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.java rename backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/{ProjectParametersMapper.xml => ProjectParameterMapper.xml} (91%) delete mode 100644 backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.java create mode 100644 backend/services/api-test/src/main/java/io/metersphere/api/constants/ModuleStatus.java create mode 100644 backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java create mode 100644 backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiModuleRequest.java create mode 100644 backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiTreeDTO.java diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameters.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameter.java similarity index 87% rename from backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameters.java rename to backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameter.java index 69986c7b37..880d07f5d2 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameters.java +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameter.java @@ -9,15 +9,15 @@ import java.util.Arrays; import lombok.Data; @Data -public class ProjectParameters implements Serializable { +public class ProjectParameter implements Serializable { @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{project_parameters.id.not_blank}", groups = {Updated.class}) - @Size(min = 1, max = 50, message = "{project_parameters.id.length_range}", groups = {Created.class, Updated.class}) + @NotBlank(message = "{project_parameter.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{project_parameter.id.length_range}", groups = {Created.class, Updated.class}) private String id; @Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{project_parameters.project_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{project_parameters.project_id.length_range}", groups = {Created.class, Updated.class}) + @NotBlank(message = "{project_parameter.project_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{project_parameter.project_id.length_range}", groups = {Created.class, Updated.class}) private String projectId; @Schema(description = "创建人") diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParametersExample.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameterExample.java similarity index 99% rename from backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParametersExample.java rename to backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameterExample.java index 7ab03da39c..e061461205 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParametersExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/domain/ProjectParameterExample.java @@ -3,14 +3,14 @@ package io.metersphere.sdk.domain; import java.util.ArrayList; import java.util.List; -public class ProjectParametersExample { +public class ProjectParameterExample { protected String orderByClause; protected boolean distinct; protected List oredCriteria; - public ProjectParametersExample() { + public ProjectParameterExample() { oredCriteria = new ArrayList(); } diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.java new file mode 100644 index 0000000000..dee9899205 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.java @@ -0,0 +1,41 @@ +package io.metersphere.sdk.mapper; + +import io.metersphere.sdk.domain.ProjectParameter; +import io.metersphere.sdk.domain.ProjectParameterExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ProjectParameterMapper { + long countByExample(ProjectParameterExample example); + + int deleteByExample(ProjectParameterExample example); + + int deleteByPrimaryKey(String id); + + int insert(ProjectParameter record); + + int insertSelective(ProjectParameter record); + + List selectByExampleWithBLOBs(ProjectParameterExample example); + + List selectByExample(ProjectParameterExample example); + + ProjectParameter selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") ProjectParameter record, @Param("example") ProjectParameterExample example); + + int updateByExampleWithBLOBs(@Param("record") ProjectParameter record, @Param("example") ProjectParameterExample example); + + int updateByExample(@Param("record") ProjectParameter record, @Param("example") ProjectParameterExample example); + + int updateByPrimaryKeySelective(ProjectParameter record); + + int updateByPrimaryKeyWithBLOBs(ProjectParameter record); + + int updateByPrimaryKey(ProjectParameter record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") ProjectParameter.Column... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.xml similarity index 91% rename from backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.xml rename to backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.xml index e05d4dce3d..1fdaf1ce78 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParameterMapper.xml @@ -1,7 +1,7 @@ - - + + @@ -9,7 +9,7 @@ - + @@ -76,7 +76,7 @@ `parameters` - select distinct @@ -84,7 +84,7 @@ , - from project_parameters + from project_parameter @@ -92,13 +92,13 @@ order by ${orderByClause} - select distinct - from project_parameters + from project_parameter @@ -111,29 +111,29 @@ , - from project_parameters + from project_parameter where id = #{id,jdbcType=VARCHAR} - delete from project_parameters + delete from project_parameter where id = #{id,jdbcType=VARCHAR} - - delete from project_parameters + + delete from project_parameter - - insert into project_parameters (id, project_id, create_user, + + insert into project_parameter (id, project_id, create_user, update_user, create_time, update_time, `parameters`) values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{updateUser,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{parameters,jdbcType=LONGVARBINARY}) - - insert into project_parameters + + insert into project_parameter id, @@ -181,14 +181,14 @@ - + select count(*) from project_parameter - update project_parameters + update project_parameter id = #{record.id,jdbcType=VARCHAR}, @@ -217,7 +217,7 @@ - update project_parameters + update project_parameter set id = #{record.id,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, @@ -230,7 +230,7 @@ - update project_parameters + update project_parameter set id = #{record.id,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, @@ -241,8 +241,8 @@ - - update project_parameters + + update project_parameter project_id = #{projectId,jdbcType=VARCHAR}, @@ -265,8 +265,8 @@ where id = #{id,jdbcType=VARCHAR} - - update project_parameters + + update project_parameter set project_id = #{projectId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, update_user = #{updateUser,jdbcType=VARCHAR}, @@ -275,8 +275,8 @@ `parameters` = #{parameters,jdbcType=LONGVARBINARY} where id = #{id,jdbcType=VARCHAR} - - update project_parameters + + update project_parameter set project_id = #{projectId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, update_user = #{updateUser,jdbcType=VARCHAR}, @@ -285,7 +285,7 @@ where id = #{id,jdbcType=VARCHAR} - insert into project_parameters + insert into project_parameter (id, project_id, create_user, update_user, create_time, update_time, `parameters` ) values @@ -296,7 +296,7 @@ - insert into project_parameters ( + insert into project_parameter ( ${column.escapedColumnName} diff --git a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.java b/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.java deleted file mode 100644 index 7380fd51ae..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/sdk/mapper/ProjectParametersMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.metersphere.sdk.mapper; - -import io.metersphere.sdk.domain.ProjectParameters; -import io.metersphere.sdk.domain.ProjectParametersExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; - -public interface ProjectParametersMapper { - long countByExample(ProjectParametersExample example); - - int deleteByExample(ProjectParametersExample example); - - int deleteByPrimaryKey(String id); - - int insert(ProjectParameters record); - - int insertSelective(ProjectParameters record); - - List selectByExampleWithBLOBs(ProjectParametersExample example); - - List selectByExample(ProjectParametersExample example); - - ProjectParameters selectByPrimaryKey(String id); - - int updateByExampleSelective(@Param("record") ProjectParameters record, @Param("example") ProjectParametersExample example); - - int updateByExampleWithBLOBs(@Param("record") ProjectParameters record, @Param("example") ProjectParametersExample example); - - int updateByExample(@Param("record") ProjectParameters record, @Param("example") ProjectParametersExample example); - - int updateByPrimaryKeySelective(ProjectParameters record); - - int updateByPrimaryKeyWithBLOBs(ProjectParameters record); - - int updateByPrimaryKey(ProjectParameters record); - - int batchInsert(@Param("list") List list); - - int batchInsertSelective(@Param("list") List list, @Param("selective") ProjectParameters.Column ... selective); -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_2__sdk_ddl.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_2__sdk_ddl.sql index 9c3550bcb5..bd2e772379 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_2__sdk_ddl.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_2__sdk_ddl.sql @@ -103,7 +103,7 @@ CREATE INDEX idx_environment_group_id ON environment_group_relation(environment_ CREATE INDEX idx_environment_id ON environment_group_relation(environment_id); CREATE INDEX idx_project_id ON environment_group_relation(project_id); -CREATE TABLE IF NOT EXISTS project_parameters( +CREATE TABLE IF NOT EXISTS project_parameter( `id` VARCHAR(50) NOT NULL COMMENT 'ID' , `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' , `create_user` VARCHAR(50) NOT NULL COMMENT '创建人' , @@ -116,7 +116,7 @@ CREATE TABLE IF NOT EXISTS project_parameters( DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '项目级参数'; -CREATE INDEX idx_project_id ON project_parameters(project_id); +CREATE INDEX idx_project_id ON project_parameter(project_id); CREATE TABLE IF NOT EXISTS worker_node diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/constants/ModuleStatus.java b/backend/services/api-test/src/main/java/io/metersphere/api/constants/ModuleStatus.java new file mode 100644 index 0000000000..e999244681 --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/constants/ModuleStatus.java @@ -0,0 +1,5 @@ +package io.metersphere.api.constants; + +public enum ModuleStatus { + All, None, Current +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java index 886c76ebc7..68c1a5ef8a 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiDefinitionModuleController.java @@ -3,6 +3,8 @@ package io.metersphere.api.controller.definition; import io.metersphere.api.dto.debug.ModuleCreateRequest; import io.metersphere.api.dto.debug.ModuleUpdateRequest; import io.metersphere.api.dto.definition.ApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiTreeDTO; import io.metersphere.api.service.definition.ApiDefinitionModuleService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.dto.sdk.BaseTreeNode; @@ -89,4 +91,10 @@ public class ApiDefinitionModuleController { public List getTrashTree(@RequestBody @Validated ApiModuleRequest request) { return apiDefinitionModuleService.getTrashTree(request, true); } + + @PostMapping("/env/tree") + @Operation(summary = "获取环境中的接口树和选中的模块") + public EnvApiTreeDTO envTree(@RequestBody @Validated EnvApiModuleRequest request) { + return apiDefinitionModuleService.envTree(request); + } } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java new file mode 100644 index 0000000000..3ab79ef3f8 --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleDTO.java @@ -0,0 +1,14 @@ +package io.metersphere.api.dto.definition; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class ApiModuleDTO { + @Schema(description = "模块ID") + private String id; + @Schema(description = "id的状态 None:手动选 Current:选中当前 All:全选中") + private String status; + @Schema(description = "是否禁用") + private Boolean disabled = false; +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiModuleRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiModuleRequest.java new file mode 100644 index 0000000000..0af8dd8ba3 --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiModuleRequest.java @@ -0,0 +1,18 @@ +package io.metersphere.api.dto.definition; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.util.List; + +@Data +public class EnvApiModuleRequest { + @Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_definition_module.project_id.not_blank}") + private String projectId; + + @Schema(description = "关键字") + private List selectedModules; + +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiTreeDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiTreeDTO.java new file mode 100644 index 0000000000..eaded0a86f --- /dev/null +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/EnvApiTreeDTO.java @@ -0,0 +1,16 @@ +package io.metersphere.api.dto.definition; + +import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +public class EnvApiTreeDTO { + + @Schema(description = "模块树") + private List moduleTree; + @Schema(description = "选中的id") + private List selectedModules; +} diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java index dbedc244c7..8d0bd002bc 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java @@ -39,4 +39,5 @@ public interface ExtApiDefinitionModuleMapper { List countModuleIdByProviderRequest(@Param("table") String resourceType, @Param("sourceName") String sourceName, @Param("apiCaseColumnName") String apiCaseColumnName, @Param("request") AssociateCaseModuleProviderRequest request, @Param("deleted") boolean deleted); List selectIdAndParentIdByProviderRequest(@Param("request") AssociateCaseModuleProviderRequest request); + } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java index 0851afe118..986dc4b253 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionModuleService.java @@ -1,11 +1,15 @@ package io.metersphere.api.service.definition; import com.github.pagehelper.PageHelper; +import io.metersphere.api.constants.ModuleStatus; import io.metersphere.api.domain.*; import io.metersphere.api.dto.debug.ApiTreeNode; import io.metersphere.api.dto.debug.ModuleCreateRequest; import io.metersphere.api.dto.debug.ModuleUpdateRequest; +import io.metersphere.api.dto.definition.ApiModuleDTO; import io.metersphere.api.dto.definition.ApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiTreeDTO; import io.metersphere.api.mapper.*; import io.metersphere.api.service.debug.ApiDebugModuleService; import io.metersphere.project.dto.ModuleCountDTO; @@ -30,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) @@ -283,4 +288,58 @@ public class ApiDefinitionModuleService extends ModuleTreeService { List apiTreeNodeList = extApiDefinitionModuleMapper.selectApiDataByRequest(request, deleted); return apiDebugModuleService.getBaseTreeNodes(apiTreeNodeList, baseTreeNodes); } + + public EnvApiTreeDTO envTree(EnvApiModuleRequest request) { + EnvApiTreeDTO envApiTreeDTO = new EnvApiTreeDTO(); + ApiModuleRequest apiModuleRequest = new ApiModuleRequest(); + apiModuleRequest.setProjectId(request.getProjectId()); + apiModuleRequest.setProtocol(ModuleConstants.NODE_PROTOCOL_HTTP); + List fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(apiModuleRequest); + List baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API)); + envApiTreeDTO.setModuleTree(baseTreeNodes); + //根据选择的模块id 来补充选中的id + List selectedModules = request.getSelectedModules(); + List currentModules = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(selectedModules)) { + //将选中的模块id转换为Map 方便后面的查询 key为id + Map selectedModuleMap = selectedModules.stream().collect(Collectors.toMap(ApiModuleDTO::getId, apiModuleDTO -> apiModuleDTO)); + getAllModuleIds(baseTreeNodes, currentModules, selectedModuleMap); + } + envApiTreeDTO.setSelectedModules(currentModules); + return envApiTreeDTO; + } + + public void getAllModuleIds(List baseTreeNodes, List currentModules, Map selectedModuleMap) { + baseTreeNodes.forEach(baseTreeNode -> { + if (selectedModuleMap.containsKey(baseTreeNode.getId())) { + ApiModuleDTO apiModuleDTO = selectedModuleMap.get(baseTreeNode.getId()); + if (StringUtils.equals(apiModuleDTO.getStatus(), ModuleStatus.All.name())) { + currentModules.add(apiModuleDTO); + if (CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) { + setChildren(baseTreeNode.getChildren(), currentModules); + } + } else { + currentModules.add(apiModuleDTO); + } + } + if (CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) { + getAllModuleIds(baseTreeNode.getChildren(), currentModules, selectedModuleMap); + } + }); + } + + public void setChildren(List baseTreeNodes, List currentModules) { + baseTreeNodes.forEach(baseTreeNode -> { + ApiModuleDTO children = new ApiModuleDTO(); + children.setId(baseTreeNode.getId()); + children.setStatus(ModuleStatus.All.name()); + children.setDisabled(true); + currentModules.add(children); + if (CollectionUtils.isNotEmpty(baseTreeNode.getChildren())) { + setChildren(baseTreeNode.getChildren(), currentModules); + } + }); + } + + } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java index cacf307310..f042cb20ac 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionModuleControllerTests.java @@ -4,7 +4,10 @@ import io.metersphere.api.domain.*; import io.metersphere.api.dto.debug.ApiDebugRequest; import io.metersphere.api.dto.debug.ModuleCreateRequest; import io.metersphere.api.dto.debug.ModuleUpdateRequest; +import io.metersphere.api.dto.definition.ApiModuleDTO; import io.metersphere.api.dto.definition.ApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiModuleRequest; +import io.metersphere.api.dto.definition.EnvApiTreeDTO; import io.metersphere.api.dto.request.http.MsHTTPElement; import io.metersphere.api.mapper.*; import io.metersphere.api.service.definition.ApiDefinitionModuleService; @@ -868,6 +871,53 @@ public class ApiDefinitionModuleControllerTests extends BaseTest { requestPostPermissionTest(PermissionConstants.PROJECT_API_DEFINITION_READ, URL_MODULE_TRASH_COUNT, request); } + @Test + @Order(13) + public void getTree() throws Exception { + MvcResult result = this.requestPostWithOkAndReturn("/api/definition/module/env/tree", new EnvApiModuleRequest() {{ + this.setProjectId(project.getId()); + }}); + String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); + EnvApiTreeDTO envApiTreeDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), EnvApiTreeDTO.class); + List baseTreeNodes = envApiTreeDTO.getModuleTree(); + List apiModuleDTOS = new ArrayList<>(); + BaseTreeNode a1a1Node = getNodeByName(baseTreeNodes, "500-test-root-20"); + assert a1a1Node != null; + ApiModuleDTO apiModuleDTO = new ApiModuleDTO(); + apiModuleDTO.setId(a1a1Node.getId()); + apiModuleDTO.setStatus("None"); + apiModuleDTOS.add(apiModuleDTO); + BaseTreeNode a40Node = getNodeByName(baseTreeNodes, "500-test-root-40"); + assert a40Node != null; + apiModuleDTO = new ApiModuleDTO(); + apiModuleDTO.setId(a40Node.getId()); + apiModuleDTO.setStatus("All"); + apiModuleDTOS.add(apiModuleDTO); + BaseTreeNode a50Node = getNodeByName(baseTreeNodes, "500-test-root-50"); + assert a50Node != null; + apiModuleDTO = new ApiModuleDTO(); + apiModuleDTO.setId(a50Node.getId()); + apiModuleDTO.setStatus("Current"); + apiModuleDTOS.add(apiModuleDTO); + BaseTreeNode a100Node = getNodeByName(baseTreeNodes, "500-test-root-100"); + assert a100Node != null; + apiModuleDTO = new ApiModuleDTO(); + apiModuleDTO.setId(a100Node.getId()); + apiModuleDTO.setStatus("All"); + apiModuleDTOS.add(apiModuleDTO); + result = this.requestPostWithOkAndReturn("/api/definition/module/env/tree", new EnvApiModuleRequest() {{ + this.setProjectId(project.getId()); + this.setSelectedModules(apiModuleDTOS); + }}); + returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8); + resultHolder = JSON.parseObject(returnData, ResultHolder.class); + envApiTreeDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), EnvApiTreeDTO.class); + envApiTreeDTO.getModuleTree(); + envApiTreeDTO.getSelectedModules(); + + } + private List getModuleTreeNode() throws Exception { MvcResult result = this.requestPostWithOkAndReturn(URL_MODULE_TREE, new ApiModuleRequest() {{ diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/GlobalParamsController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/GlobalParamsController.java index 3ae0c77997..d7dd12f0bd 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/GlobalParamsController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/GlobalParamsController.java @@ -5,7 +5,7 @@ import io.metersphere.project.dto.environment.GlobalParamsRequest; import io.metersphere.project.service.GlobalParamsLogService; import io.metersphere.project.service.GlobalParamsService; import io.metersphere.sdk.constants.PermissionConstants; -import io.metersphere.sdk.domain.ProjectParameters; +import io.metersphere.sdk.domain.ProjectParameter; import io.metersphere.system.log.annotation.Log; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.utils.SessionUtils; @@ -32,7 +32,7 @@ public class GlobalParamsController { @Operation(summary = "项目管理-环境-全局参数-新增") @RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD) @Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = GlobalParamsLogService.class) - public ProjectParameters add(@Validated({Created.class}) @RequestBody GlobalParamsRequest request) { + public ProjectParameter add(@Validated({Created.class}) @RequestBody GlobalParamsRequest request) { return globalParamsService.add(request, SessionUtils.getUserId()); } @@ -40,7 +40,7 @@ public class GlobalParamsController { @Operation(summary = "项目管理-环境-全局参数-修改") @RequiresPermissions(PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE) @Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = GlobalParamsLogService.class) - public ProjectParameters update(@Validated({Updated.class}) @RequestBody GlobalParamsRequest request) { + public ProjectParameter update(@Validated({Updated.class}) @RequestBody GlobalParamsRequest request) { return globalParamsService.update(request, SessionUtils.getUserId()); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java index 1b6e18d749..3c679cce13 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/CleanupEnvironmentResourceService.java @@ -17,7 +17,7 @@ public class CleanupEnvironmentResourceService implements CleanupProjectResource @Resource private EnvironmentBlobMapper environmentBlobMapper; @Resource - private ProjectParametersMapper projectParametersMapper; + private ProjectParameterMapper projectParametersMapper; @Resource private EnvironmentGroupMapper environmentGroupMapper; @Resource @@ -29,7 +29,7 @@ public class CleanupEnvironmentResourceService implements CleanupProjectResource environmentExample.createCriteria().andProjectIdEqualTo(projectId); environmentMapper.deleteByExample(environmentExample); environmentBlobMapper.deleteByPrimaryKey(projectId); - ProjectParametersExample projectExample = new ProjectParametersExample(); + ProjectParameterExample projectExample = new ProjectParameterExample(); projectExample.createCriteria().andProjectIdEqualTo(projectId); projectParametersMapper.deleteByExample(projectExample); EnvironmentGroupExample environmentGroupExample = new EnvironmentGroupExample(); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java index ee3318c0ed..ba4fdfa193 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java @@ -17,7 +17,6 @@ import io.metersphere.sdk.file.FileRequest; import io.metersphere.sdk.file.MinioRepository; import io.metersphere.sdk.mapper.EnvironmentBlobMapper; import io.metersphere.sdk.mapper.EnvironmentMapper; -import io.metersphere.sdk.mapper.ProjectParametersMapper; import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; @@ -68,8 +67,6 @@ public class EnvironmentService { @Resource private ExtEnvironmentMapper extEnvironmentMapper; public static final Long ORDER_STEP = 5000L; - @Resource - private ProjectParametersMapper projectParametersMapper; private static final String USERNAME = "user"; private static final String PASSWORD = "password"; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsLogService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsLogService.java index ef754da351..3483aad033 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsLogService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsLogService.java @@ -3,13 +3,12 @@ package io.metersphere.project.service; import io.metersphere.project.domain.Project; import io.metersphere.project.dto.environment.GlobalParamsRequest; import io.metersphere.project.mapper.ProjectMapper; -import io.metersphere.sdk.domain.ProjectParameters; -import io.metersphere.system.log.dto.LogDTO; - -import io.metersphere.sdk.mapper.ProjectParametersMapper; +import io.metersphere.sdk.domain.ProjectParameter; +import io.metersphere.sdk.mapper.ProjectParameterMapper; import io.metersphere.sdk.util.JSON; import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.log.constants.OperationLogType; +import io.metersphere.system.log.dto.LogDTO; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,7 +18,7 @@ import org.springframework.transaction.annotation.Transactional; public class GlobalParamsLogService { @Resource - private ProjectParametersMapper projectParametersMapper; + private ProjectParameterMapper projectParametersMapper; @Resource private ProjectMapper projectMapper; @@ -49,7 +48,7 @@ public class GlobalParamsLogService { OperationLogType.UPDATE.name(), OperationLogModule.PROJECT_MANAGEMENT_ENVIRONMENT, null); - ProjectParameters projectParameters = projectParametersMapper.selectByPrimaryKey(request.getId()); + ProjectParameter projectParameters = projectParametersMapper.selectByPrimaryKey(request.getId()); dto.setOriginalValue(projectParameters.getParameters()); dto.setModifiedValue(JSON.toJSONBytes(request.getGlobalParams())); return dto; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsService.java index 1061daff18..0102fb774c 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/GlobalParamsService.java @@ -5,10 +5,10 @@ import io.metersphere.project.dto.environment.GlobalParams; import io.metersphere.project.dto.environment.GlobalParamsDTO; import io.metersphere.project.dto.environment.GlobalParamsRequest; import io.metersphere.project.mapper.ProjectMapper; -import io.metersphere.sdk.domain.ProjectParameters; -import io.metersphere.sdk.domain.ProjectParametersExample; +import io.metersphere.sdk.domain.ProjectParameter; +import io.metersphere.sdk.domain.ProjectParameterExample; import io.metersphere.sdk.exception.MSException; -import io.metersphere.sdk.mapper.ProjectParametersMapper; +import io.metersphere.sdk.mapper.ProjectParameterMapper; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Translator; @@ -32,57 +32,57 @@ import java.util.List; public class GlobalParamsService { @Resource - private ProjectParametersMapper projectParametersMapper; + private ProjectParameterMapper projectParameterMapper; @Resource private ProjectMapper projectMapper; - public ProjectParameters add(GlobalParamsRequest globalParamsRequest, String userId) { - ProjectParameters projectParameters = new ProjectParameters(); - projectParameters.setProjectId(globalParamsRequest.getProjectId()); + public ProjectParameter add(GlobalParamsRequest globalParamsRequest, String userId) { + ProjectParameter projectParameter = new ProjectParameter(); + projectParameter.setProjectId(globalParamsRequest.getProjectId()); checkExist(globalParamsRequest.getProjectId()); checkProjectExist(globalParamsRequest.getProjectId()); - projectParameters.setId(IDGenerator.nextStr()); - projectParameters.setCreateUser(userId); - projectParameters.setUpdateUser(userId); - projectParameters.setCreateTime(System.currentTimeMillis()); - projectParameters.setUpdateTime(System.currentTimeMillis()); - projectParameters.setParameters(JSON.toJSONBytes(globalParamsRequest.getGlobalParams())); - projectParametersMapper.insert(projectParameters); - globalParamsRequest.setId(projectParameters.getId()); - return projectParameters; + projectParameter.setId(IDGenerator.nextStr()); + projectParameter.setCreateUser(userId); + projectParameter.setUpdateUser(userId); + projectParameter.setCreateTime(System.currentTimeMillis()); + projectParameter.setUpdateTime(System.currentTimeMillis()); + projectParameter.setParameters(JSON.toJSONBytes(globalParamsRequest.getGlobalParams())); + projectParameterMapper.insert(projectParameter); + globalParamsRequest.setId(projectParameter.getId()); + return projectParameter; } - public ProjectParameters update(GlobalParamsRequest globalParamsRequest, String userId) { - ProjectParameters projectParameters = new ProjectParameters(); - projectParameters.setProjectId(globalParamsRequest.getProjectId()); + public ProjectParameter update(GlobalParamsRequest globalParamsRequest, String userId) { + ProjectParameter projectParameter = new ProjectParameter(); + projectParameter.setProjectId(globalParamsRequest.getProjectId()); checkDataExist(globalParamsRequest.getProjectId()); checkProjectExist(globalParamsRequest.getProjectId()); - projectParameters.setId(globalParamsRequest.getId()); - projectParameters.setUpdateUser(userId); - projectParameters.setUpdateTime(System.currentTimeMillis()); - projectParameters.setParameters(JSON.toJSONBytes(globalParamsRequest.getGlobalParams())); - projectParametersMapper.updateByPrimaryKeySelective(projectParameters); - return projectParameters; + projectParameter.setId(globalParamsRequest.getId()); + projectParameter.setUpdateUser(userId); + projectParameter.setUpdateTime(System.currentTimeMillis()); + projectParameter.setParameters(JSON.toJSONBytes(globalParamsRequest.getGlobalParams())); + projectParameterMapper.updateByPrimaryKeySelective(projectParameter); + return projectParameter; } private void checkDataExist(String projectId) { - ProjectParametersExample example = new ProjectParametersExample(); + ProjectParameterExample example = new ProjectParameterExample(); example.createCriteria().andProjectIdEqualTo(projectId); - List projectParameters = projectParametersMapper.selectByExample(example); - if (projectParameters.isEmpty()) { + List projectParameter = projectParameterMapper.selectByExample(example); + if (projectParameter.isEmpty()) { throw new MSException(Translator.get("global_parameters_is_not_exist")); } } public GlobalParamsDTO get(String projectId) { - ProjectParametersExample example = new ProjectParametersExample(); + ProjectParameterExample example = new ProjectParameterExample(); example.createCriteria().andProjectIdEqualTo(projectId); - List projectParametersList = projectParametersMapper.selectByExampleWithBLOBs(example); - if (CollectionUtils.isNotEmpty(projectParametersList)) { + List projectParameters = projectParameterMapper.selectByExampleWithBLOBs(example); + if (CollectionUtils.isNotEmpty(projectParameters)) { GlobalParamsDTO globalParamsDTO = new GlobalParamsDTO(); globalParamsDTO.setProjectId(projectId); - globalParamsDTO.setId(projectParametersList.get(0).getId()); - globalParamsDTO.setGlobalParams(JSON.parseObject(new String(projectParametersList.get(0).getParameters()), GlobalParams.class)); + globalParamsDTO.setId(projectParameters.get(0).getId()); + globalParamsDTO.setGlobalParams(JSON.parseObject(new String(projectParameters.get(0).getParameters()), GlobalParams.class)); return globalParamsDTO; } else { return null; @@ -91,9 +91,9 @@ public class GlobalParamsService { } private void checkExist(String projectId) { - ProjectParametersExample example = new ProjectParametersExample(); + ProjectParameterExample example = new ProjectParameterExample(); example.createCriteria().andProjectIdEqualTo(projectId); - List projectParameters = projectParametersMapper.selectByExample(example); + List projectParameters = projectParameterMapper.selectByExample(example); if (!projectParameters.isEmpty()) { throw new MSException(Translator.get("global_parameters_already_exist")); } @@ -109,9 +109,9 @@ public class GlobalParamsService { try { Project project = projectMapper.selectByPrimaryKey(projectId); //查询全局参数 - ProjectParametersExample projectParametersExample = new ProjectParametersExample(); - projectParametersExample.createCriteria().andProjectIdEqualTo(projectId); - List projectParameters = projectParametersMapper.selectByExampleWithBLOBs(projectParametersExample); + ProjectParameterExample projectParameterExample = new ProjectParameterExample(); + projectParameterExample.createCriteria().andProjectIdEqualTo(projectId); + List projectParameters = projectParameterMapper.selectByExampleWithBLOBs(projectParameterExample); byte[] bytes = new byte[0]; if (CollectionUtils.isNotEmpty(projectParameters)) { GlobalParamsDTO globalParamsDTO = new GlobalParamsDTO(); @@ -141,20 +141,20 @@ public class GlobalParamsService { inputStream.close(); //参数是一个对象 GlobalParamsDTO globalParamsDTO = JSON.parseObject(content, GlobalParamsDTO.class); - ProjectParametersExample projectParametersExample = new ProjectParametersExample(); - projectParametersExample.createCriteria().andProjectIdEqualTo(currentProjectId); - if (projectParametersMapper.countByExample(projectParametersExample) > 0) { - projectParametersMapper.deleteByExample(projectParametersExample); + ProjectParameterExample projectParameterExample = new ProjectParameterExample(); + projectParameterExample.createCriteria().andProjectIdEqualTo(currentProjectId); + if (projectParameterMapper.countByExample(projectParameterExample) > 0) { + projectParameterMapper.deleteByExample(projectParameterExample); } - ProjectParameters projectParameters = new ProjectParameters(); - projectParameters.setId(IDGenerator.nextStr()); - projectParameters.setProjectId(currentProjectId); - projectParameters.setCreateUser(userId); - projectParameters.setUpdateUser(userId); - projectParameters.setCreateTime(System.currentTimeMillis()); - projectParameters.setUpdateTime(System.currentTimeMillis()); - projectParameters.setParameters(JSON.toJSONBytes(globalParamsDTO.getGlobalParams())); - projectParametersMapper.insert(projectParameters); + ProjectParameter projectParameter = new ProjectParameter(); + projectParameter.setId(IDGenerator.nextStr()); + projectParameter.setProjectId(currentProjectId); + projectParameter.setCreateUser(userId); + projectParameter.setUpdateUser(userId); + projectParameter.setCreateTime(System.currentTimeMillis()); + projectParameter.setUpdateTime(System.currentTimeMillis()); + projectParameter.setParameters(JSON.toJSONBytes(globalParamsDTO.getGlobalParams())); + projectParameterMapper.insert(projectParameter); } catch (Exception e) { LogUtils.error("获取文件输入流异常", e); throw new RuntimeException("获取文件输入流异常", e); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java index ce508ad8de..7b2ff7582c 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java @@ -27,7 +27,6 @@ import io.metersphere.sdk.file.FileRequest; import io.metersphere.sdk.file.MinioRepository; import io.metersphere.sdk.mapper.EnvironmentBlobMapper; import io.metersphere.sdk.mapper.EnvironmentMapper; -import io.metersphere.sdk.mapper.ProjectParametersMapper; import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.JSON; import io.metersphere.system.base.BaseTest; @@ -96,8 +95,6 @@ public class EnvironmentControllerTests extends BaseTest { private EnvironmentMapper environmentMapper; @Resource private EnvironmentBlobMapper environmentBlobMapper; - @Resource - private ProjectParametersMapper projectParametersMapper; @Value("${spring.datasource.url}") private String dburl; @Value("${spring.datasource.username}") diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/GlobalParamsControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/GlobalParamsControllerTests.java index 290f21401f..1bedb52971 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/GlobalParamsControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/GlobalParamsControllerTests.java @@ -10,9 +10,9 @@ import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.constants.VariableTypeConstants; -import io.metersphere.sdk.domain.ProjectParameters; -import io.metersphere.sdk.domain.ProjectParametersExample; -import io.metersphere.sdk.mapper.ProjectParametersMapper; +import io.metersphere.sdk.domain.ProjectParameter; +import io.metersphere.sdk.domain.ProjectParameterExample; +import io.metersphere.sdk.mapper.ProjectParameterMapper; import io.metersphere.sdk.util.JSON; import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; @@ -69,7 +69,7 @@ public class GlobalParamsControllerTests extends BaseTest { private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError(); @Resource - private ProjectParametersMapper projectParametersMapper; + private ProjectParameterMapper projectParametersMapper; private final ProjectServiceInvoker serviceInvoker; @Resource private ProjectMapper projectMapper; @@ -260,9 +260,9 @@ public class GlobalParamsControllerTests extends BaseTest { globalParams.setCommonVariables(getEnvVariables(1)); request.setGlobalParams(globalParams); MvcResult mvcResult = this.responsePost(add, request); - ProjectParameters globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameters.class); + ProjectParameter globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameter.class); Assertions.assertNotNull(globalParamsRequest); - ProjectParameters projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); + ProjectParameter projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); Assertions.assertNotNull(projectParameters); Assertions.assertEquals("projectId1", projectParameters.getProjectId()); Assertions.assertEquals(1, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size()); @@ -276,7 +276,7 @@ public class GlobalParamsControllerTests extends BaseTest { globalParams.setCommonVariables(new ArrayList<>()); request.setGlobalParams(globalParams); mvcResult = this.responsePost(add, request); - globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameters.class); + globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameter.class); Assertions.assertNotNull(globalParamsRequest); projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); Assertions.assertNotNull(projectParameters); @@ -292,7 +292,7 @@ public class GlobalParamsControllerTests extends BaseTest { globalParams.setCommonVariables(getEnvVariables(1)); request.setGlobalParams(globalParams); mvcResult = this.responsePost(add, request); - globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameters.class); + globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameter.class); Assertions.assertNotNull(globalParamsRequest); projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); Assertions.assertNotNull(projectParameters); @@ -308,7 +308,7 @@ public class GlobalParamsControllerTests extends BaseTest { globalParams.setCommonVariables(new ArrayList<>()); request.setGlobalParams(globalParams); mvcResult = this.responsePost(add, request); - globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameters.class); + globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameter.class); Assertions.assertNotNull(globalParamsRequest); projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); Assertions.assertNotNull(projectParameters); @@ -320,7 +320,7 @@ public class GlobalParamsControllerTests extends BaseTest { request.setProjectId("projectId5"); request.setGlobalParams(new GlobalParams()); mvcResult = this.responsePost(add, request); - globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameters.class); + globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameter.class); Assertions.assertNotNull(globalParamsRequest); //校验日志 checkLog(globalParamsRequest.getId(), OperationLogType.ADD); @@ -363,9 +363,9 @@ public class GlobalParamsControllerTests extends BaseTest { @Order(3) public void testUpdateSuccess() throws Exception { //修改全局参数 有headers 有envVariables - ProjectParametersExample example = new ProjectParametersExample(); + ProjectParameterExample example = new ProjectParameterExample(); example.createCriteria().andProjectIdEqualTo("projectId1"); - List projectParametersList = projectParametersMapper.selectByExample(example); + List projectParametersList = projectParametersMapper.selectByExample(example); GlobalParamsRequest request = new GlobalParamsRequest(); request.setProjectId("projectId1"); request.setId(projectParametersList.get(0).getId()); @@ -374,11 +374,11 @@ public class GlobalParamsControllerTests extends BaseTest { globalParams.setCommonVariables(getEnvVariables(2)); request.setGlobalParams(globalParams); MvcResult mvcResult = this.responsePost(update, request); - ProjectParameters globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameters.class); + ProjectParameter globalParamsRequest = parseObjectFromMvcResult(mvcResult, ProjectParameter.class); Assertions.assertNotNull(globalParamsRequest); //校验日志 checkLog(globalParamsRequest.getId(), OperationLogType.UPDATE); - ProjectParameters projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); + ProjectParameter projectParameters = projectParametersMapper.selectByPrimaryKey(globalParamsRequest.getId()); Assertions.assertNotNull(projectParameters); Assertions.assertEquals("projectId1", projectParameters.getProjectId()); Assertions.assertEquals(2, JSON.parseObject(new String(projectParameters.getParameters()), GlobalParams.class).getHeaders().size()); @@ -386,7 +386,7 @@ public class GlobalParamsControllerTests extends BaseTest { //校验权限 request = new GlobalParamsRequest(); - example = new ProjectParametersExample(); + example = new ProjectParameterExample(); example.createCriteria().andProjectIdEqualTo(DEFAULT_PROJECT_ID); projectParametersList = projectParametersMapper.selectByExample(example); request.setProjectId(DEFAULT_PROJECT_ID); @@ -415,7 +415,7 @@ public class GlobalParamsControllerTests extends BaseTest { request.setProjectId("projectId1111"); this.requestPost(update, request, ERROR_REQUEST_MATCHER); - ProjectParametersExample example = new ProjectParametersExample(); + ProjectParameterExample example = new ProjectParameterExample(); example.createCriteria().andProjectIdEqualTo("projectId2"); projectParametersMapper.deleteByExample(example); // 修改全局参数 全局参数不存在