refactor(项目管理): 优化环境查询接口模块树和选中的模块
This commit is contained in:
parent
7919e356e2
commit
2f0ff19744
|
@ -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 = "创建人")
|
|
@ -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<Criteria> oredCriteria;
|
||||
|
||||
public ProjectParametersExample() {
|
||||
public ProjectParameterExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
|
@ -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<ProjectParameter> selectByExampleWithBLOBs(ProjectParameterExample example);
|
||||
|
||||
List<ProjectParameter> 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<ProjectParameter> list);
|
||||
|
||||
int batchInsertSelective(@Param("list") List<ProjectParameter> list, @Param("selective") ProjectParameter.Column... selective);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.sdk.mapper.ProjectParametersMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.sdk.domain.ProjectParameters">
|
||||
<mapper namespace="io.metersphere.sdk.mapper.ProjectParameterMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.sdk.domain.ProjectParameter">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||
|
@ -9,7 +9,7 @@
|
|||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.sdk.domain.ProjectParameters">
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.sdk.domain.ProjectParameter">
|
||||
<result column="parameters" jdbcType="LONGVARBINARY" property="parameters" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
|
@ -76,7 +76,7 @@
|
|||
<sql id="Blob_Column_List">
|
||||
`parameters`
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.sdk.domain.ProjectParametersExample" resultMap="ResultMapWithBLOBs">
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.sdk.domain.ProjectParameterExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
|
@ -84,7 +84,7 @@
|
|||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from project_parameters
|
||||
from project_parameter
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -92,13 +92,13 @@
|
|||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByExample" parameterType="io.metersphere.sdk.domain.ProjectParametersExample" resultMap="BaseResultMap">
|
||||
<select id="selectByExample" parameterType="io.metersphere.sdk.domain.ProjectParameterExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from project_parameters
|
||||
from project_parameter
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -111,29 +111,29 @@
|
|||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from project_parameters
|
||||
from project_parameter
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from project_parameters
|
||||
delete from project_parameter
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.sdk.domain.ProjectParametersExample">
|
||||
delete from project_parameters
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.sdk.domain.ProjectParameterExample">
|
||||
delete from project_parameter
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.sdk.domain.ProjectParameters">
|
||||
insert into project_parameters (id, project_id, create_user,
|
||||
<insert id="insert" parameterType="io.metersphere.sdk.domain.ProjectParameter">
|
||||
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>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.sdk.domain.ProjectParameters">
|
||||
insert into project_parameters
|
||||
<insert id="insertSelective" parameterType="io.metersphere.sdk.domain.ProjectParameter">
|
||||
insert into project_parameter
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
|
@ -181,14 +181,14 @@
|
|||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.sdk.domain.ProjectParametersExample" resultType="java.lang.Long">
|
||||
select count(*) from project_parameters
|
||||
<select id="countByExample" parameterType="io.metersphere.sdk.domain.ProjectParameterExample" resultType="java.lang.Long">
|
||||
select count(*) from project_parameter
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update project_parameters
|
||||
update project_parameter
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
|
@ -217,7 +217,7 @@
|
|||
</if>
|
||||
</update>
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||
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 @@
|
|||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
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 @@
|
|||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.sdk.domain.ProjectParameters">
|
||||
update project_parameters
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.sdk.domain.ProjectParameter">
|
||||
update project_parameter
|
||||
<set>
|
||||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
|
@ -265,8 +265,8 @@
|
|||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.sdk.domain.ProjectParameters">
|
||||
update project_parameters
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.sdk.domain.ProjectParameter">
|
||||
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>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.sdk.domain.ProjectParameters">
|
||||
update project_parameters
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.sdk.domain.ProjectParameter">
|
||||
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}
|
||||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
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 @@
|
|||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
insert into project_parameters (
|
||||
insert into project_parameter (
|
||||
<foreach collection="selective" item="column" separator=",">
|
||||
${column.escapedColumnName}
|
||||
</foreach>
|
|
@ -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<ProjectParameters> selectByExampleWithBLOBs(ProjectParametersExample example);
|
||||
|
||||
List<ProjectParameters> 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<ProjectParameters> list);
|
||||
|
||||
int batchInsertSelective(@Param("list") List<ProjectParameters> list, @Param("selective") ProjectParameters.Column ... selective);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.api.constants;
|
||||
|
||||
public enum ModuleStatus {
|
||||
All, None, Current
|
||||
}
|
|
@ -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<BaseTreeNode> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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<ApiModuleDTO> selectedModules;
|
||||
|
||||
}
|
|
@ -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<BaseTreeNode> moduleTree;
|
||||
@Schema(description = "选中的id")
|
||||
private List<ApiModuleDTO> selectedModules;
|
||||
}
|
|
@ -39,4 +39,5 @@ public interface ExtApiDefinitionModuleMapper {
|
|||
List<ModuleCountDTO> countModuleIdByProviderRequest(@Param("table") String resourceType, @Param("sourceName") String sourceName, @Param("apiCaseColumnName") String apiCaseColumnName, @Param("request") AssociateCaseModuleProviderRequest request, @Param("deleted") boolean deleted);
|
||||
|
||||
List<BaseTreeNode> selectIdAndParentIdByProviderRequest(@Param("request") AssociateCaseModuleProviderRequest request);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ApiTreeNode> 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<BaseTreeNode> fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(apiModuleRequest);
|
||||
List<BaseTreeNode> baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API));
|
||||
envApiTreeDTO.setModuleTree(baseTreeNodes);
|
||||
//根据选择的模块id 来补充选中的id
|
||||
List<ApiModuleDTO> selectedModules = request.getSelectedModules();
|
||||
List<ApiModuleDTO> currentModules = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(selectedModules)) {
|
||||
//将选中的模块id转换为Map 方便后面的查询 key为id
|
||||
Map<String, ApiModuleDTO> selectedModuleMap = selectedModules.stream().collect(Collectors.toMap(ApiModuleDTO::getId, apiModuleDTO -> apiModuleDTO));
|
||||
getAllModuleIds(baseTreeNodes, currentModules, selectedModuleMap);
|
||||
}
|
||||
envApiTreeDTO.setSelectedModules(currentModules);
|
||||
return envApiTreeDTO;
|
||||
}
|
||||
|
||||
public void getAllModuleIds(List<BaseTreeNode> baseTreeNodes, List<ApiModuleDTO> currentModules, Map<String, ApiModuleDTO> 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<BaseTreeNode> baseTreeNodes, List<ApiModuleDTO> 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<BaseTreeNode> baseTreeNodes = envApiTreeDTO.getModuleTree();
|
||||
List<ApiModuleDTO> 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<BaseTreeNode> getModuleTreeNode() throws Exception {
|
||||
MvcResult result = this.requestPostWithOkAndReturn(URL_MODULE_TREE, new ApiModuleRequest() {{
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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> projectParameters = projectParametersMapper.selectByExample(example);
|
||||
if (projectParameters.isEmpty()) {
|
||||
List<ProjectParameter> 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<ProjectParameters> projectParametersList = projectParametersMapper.selectByExampleWithBLOBs(example);
|
||||
if (CollectionUtils.isNotEmpty(projectParametersList)) {
|
||||
List<ProjectParameter> 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> projectParameters = projectParametersMapper.selectByExample(example);
|
||||
List<ProjectParameter> 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> projectParameters = projectParametersMapper.selectByExampleWithBLOBs(projectParametersExample);
|
||||
ProjectParameterExample projectParameterExample = new ProjectParameterExample();
|
||||
projectParameterExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<ProjectParameter> 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);
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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<ProjectParameters> projectParametersList = projectParametersMapper.selectByExample(example);
|
||||
List<ProjectParameter> 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);
|
||||
// 修改全局参数 全局参数不存在
|
||||
|
|
Loading…
Reference in New Issue