refactor(系统设置): 项目增加模块设置
This commit is contained in:
parent
ca40ac7c60
commit
223a02fc61
|
@ -1,53 +1,61 @@
|
||||||
package io.metersphere.project.domain;
|
package io.metersphere.project.domain;
|
||||||
|
|
||||||
import io.metersphere.validation.groups.*;
|
import io.metersphere.validation.groups.Created;
|
||||||
|
import io.metersphere.validation.groups.Updated;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ProjectExtend implements Serializable {
|
public class ProjectExtend implements Serializable {
|
||||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{project_extend.id.not_blank}", groups = {Updated.class})
|
@NotBlank(message = "{project_extend.id.not_blank}", groups = {Updated.class})
|
||||||
@Size(min = 1, max = 50, message = "{project_extend.id.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 50, message = "{project_extend.id.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "")
|
@Schema(description = "")
|
||||||
private String tapdId;
|
private String tapdId;
|
||||||
|
|
||||||
@Schema(description = "")
|
@Schema(description = "")
|
||||||
private String jiraKey;
|
private String jiraKey;
|
||||||
|
|
||||||
@Schema(description = "")
|
@Schema(description = "")
|
||||||
private String zentaoId;
|
private String zentaoId;
|
||||||
|
|
||||||
@Schema(description = "")
|
@Schema(description = "")
|
||||||
private String azureDevopsId;
|
private String azureDevopsId;
|
||||||
|
|
||||||
@Schema(description = "用例模版ID")
|
@Schema(description = "用例模版ID")
|
||||||
private String caseTemplateId;
|
private String caseTemplateId;
|
||||||
|
|
||||||
@Schema(description = "azure 过滤需求的 parent workItem ID")
|
@Schema(description = "azure 过滤需求的 parent workItem ID")
|
||||||
private String azureFilterId;
|
private String azureFilterId;
|
||||||
|
|
||||||
@Schema(description = "项目使用哪个平台的模板")
|
@Schema(description = "项目使用哪个平台的模板", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotBlank(message = "{project_extend.platform.not_blank}", groups = {Created.class})
|
||||||
|
@Size(min = 1, max = 20, message = "{project_extend.platform.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String platform;
|
private String platform;
|
||||||
|
|
||||||
@Schema(description = "是否使用第三方平台缺陷模板")
|
@Schema(description = "是否使用第三方平台缺陷模板")
|
||||||
private Boolean thirdPartTemplate;
|
private Boolean thirdPartTemplate;
|
||||||
|
|
||||||
@Schema(description = "是否开启版本管理")
|
@Schema(description = "是否开启版本管理")
|
||||||
private Boolean versionEnable;
|
private Boolean versionEnable;
|
||||||
|
|
||||||
@Schema(description = "")
|
@Schema(description = "")
|
||||||
private String issueConfig;
|
private String issueConfig;
|
||||||
|
|
||||||
@Schema(description = "")
|
@Schema(description = "")
|
||||||
private String apiTemplateId;
|
private String apiTemplateId;
|
||||||
|
|
||||||
|
@Schema(description = "模块设置")
|
||||||
|
private String moduleSetting;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public enum Column {
|
public enum Column {
|
||||||
|
@ -62,7 +70,8 @@ public class ProjectExtend implements Serializable {
|
||||||
thirdPartTemplate("third_part_template", "thirdPartTemplate", "BIT", false),
|
thirdPartTemplate("third_part_template", "thirdPartTemplate", "BIT", false),
|
||||||
versionEnable("version_enable", "versionEnable", "BIT", false),
|
versionEnable("version_enable", "versionEnable", "BIT", false),
|
||||||
issueConfig("issue_config", "issueConfig", "VARCHAR", false),
|
issueConfig("issue_config", "issueConfig", "VARCHAR", false),
|
||||||
apiTemplateId("api_template_id", "apiTemplateId", "VARCHAR", false);
|
apiTemplateId("api_template_id", "apiTemplateId", "VARCHAR", false),
|
||||||
|
moduleSetting("module_setting", "moduleSetting", "VARCHAR", false);
|
||||||
|
|
||||||
private static final String BEGINNING_DELIMITER = "`";
|
private static final String BEGINNING_DELIMITER = "`";
|
||||||
|
|
||||||
|
|
|
@ -923,6 +923,76 @@ public class ProjectExtendExample {
|
||||||
addCriterion("api_template_id not between", value1, value2, "apiTemplateId");
|
addCriterion("api_template_id not between", value1, value2, "apiTemplateId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingIsNull() {
|
||||||
|
addCriterion("module_setting is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingIsNotNull() {
|
||||||
|
addCriterion("module_setting is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingEqualTo(String value) {
|
||||||
|
addCriterion("module_setting =", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingNotEqualTo(String value) {
|
||||||
|
addCriterion("module_setting <>", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingGreaterThan(String value) {
|
||||||
|
addCriterion("module_setting >", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingGreaterThanOrEqualTo(String value) {
|
||||||
|
addCriterion("module_setting >=", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingLessThan(String value) {
|
||||||
|
addCriterion("module_setting <", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingLessThanOrEqualTo(String value) {
|
||||||
|
addCriterion("module_setting <=", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingLike(String value) {
|
||||||
|
addCriterion("module_setting like", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingNotLike(String value) {
|
||||||
|
addCriterion("module_setting not like", value, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingIn(List<String> values) {
|
||||||
|
addCriterion("module_setting in", values, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingNotIn(List<String> values) {
|
||||||
|
addCriterion("module_setting not in", values, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingBetween(String value1, String value2) {
|
||||||
|
addCriterion("module_setting between", value1, value2, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andModuleSettingNotBetween(String value1, String value2) {
|
||||||
|
addCriterion("module_setting not between", value1, value2, "moduleSetting");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Criteria extends GeneratedCriteria {
|
public static class Criteria extends GeneratedCriteria {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<result column="version_enable" jdbcType="BIT" property="versionEnable" />
|
<result column="version_enable" jdbcType="BIT" property="versionEnable" />
|
||||||
<result column="issue_config" jdbcType="VARCHAR" property="issueConfig" />
|
<result column="issue_config" jdbcType="VARCHAR" property="issueConfig" />
|
||||||
<result column="api_template_id" jdbcType="VARCHAR" property="apiTemplateId" />
|
<result column="api_template_id" jdbcType="VARCHAR" property="apiTemplateId" />
|
||||||
|
<result column="module_setting" jdbcType="VARCHAR" property="moduleSetting" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Example_Where_Clause">
|
<sql id="Example_Where_Clause">
|
||||||
<where>
|
<where>
|
||||||
|
@ -75,7 +76,7 @@
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, tapd_id, jira_key, zentao_id, azure_devops_id, case_template_id, azure_filter_id,
|
id, tapd_id, jira_key, zentao_id, azure_devops_id, case_template_id, azure_filter_id,
|
||||||
platform, third_part_template, version_enable, issue_config, api_template_id
|
platform, third_part_template, version_enable, issue_config, api_template_id, module_setting
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" parameterType="io.metersphere.project.domain.ProjectExtendExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.metersphere.project.domain.ProjectExtendExample" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
|
@ -111,13 +112,13 @@
|
||||||
insert into project_extend (id, tapd_id, jira_key,
|
insert into project_extend (id, tapd_id, jira_key,
|
||||||
zentao_id, azure_devops_id, case_template_id,
|
zentao_id, azure_devops_id, case_template_id,
|
||||||
azure_filter_id, platform, third_part_template,
|
azure_filter_id, platform, third_part_template,
|
||||||
version_enable, issue_config, api_template_id
|
version_enable, issue_config, api_template_id,
|
||||||
)
|
module_setting)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR},
|
||||||
#{zentaoId,jdbcType=VARCHAR}, #{azureDevopsId,jdbcType=VARCHAR}, #{caseTemplateId,jdbcType=VARCHAR},
|
#{zentaoId,jdbcType=VARCHAR}, #{azureDevopsId,jdbcType=VARCHAR}, #{caseTemplateId,jdbcType=VARCHAR},
|
||||||
#{azureFilterId,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, #{thirdPartTemplate,jdbcType=BIT},
|
#{azureFilterId,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, #{thirdPartTemplate,jdbcType=BIT},
|
||||||
#{versionEnable,jdbcType=BIT}, #{issueConfig,jdbcType=VARCHAR}, #{apiTemplateId,jdbcType=VARCHAR}
|
#{versionEnable,jdbcType=BIT}, #{issueConfig,jdbcType=VARCHAR}, #{apiTemplateId,jdbcType=VARCHAR},
|
||||||
)
|
#{moduleSetting,jdbcType=VARCHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="io.metersphere.project.domain.ProjectExtend">
|
<insert id="insertSelective" parameterType="io.metersphere.project.domain.ProjectExtend">
|
||||||
insert into project_extend
|
insert into project_extend
|
||||||
|
@ -158,6 +159,9 @@
|
||||||
<if test="apiTemplateId != null">
|
<if test="apiTemplateId != null">
|
||||||
api_template_id,
|
api_template_id,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="moduleSetting != null">
|
||||||
|
module_setting,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
|
@ -196,6 +200,9 @@
|
||||||
<if test="apiTemplateId != null">
|
<if test="apiTemplateId != null">
|
||||||
#{apiTemplateId,jdbcType=VARCHAR},
|
#{apiTemplateId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="moduleSetting != null">
|
||||||
|
#{moduleSetting,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="countByExample" parameterType="io.metersphere.project.domain.ProjectExtendExample" resultType="java.lang.Long">
|
<select id="countByExample" parameterType="io.metersphere.project.domain.ProjectExtendExample" resultType="java.lang.Long">
|
||||||
|
@ -243,6 +250,9 @@
|
||||||
<if test="record.apiTemplateId != null">
|
<if test="record.apiTemplateId != null">
|
||||||
api_template_id = #{record.apiTemplateId,jdbcType=VARCHAR},
|
api_template_id = #{record.apiTemplateId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.moduleSetting != null">
|
||||||
|
module_setting = #{record.moduleSetting,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
|
@ -261,7 +271,8 @@
|
||||||
third_part_template = #{record.thirdPartTemplate,jdbcType=BIT},
|
third_part_template = #{record.thirdPartTemplate,jdbcType=BIT},
|
||||||
version_enable = #{record.versionEnable,jdbcType=BIT},
|
version_enable = #{record.versionEnable,jdbcType=BIT},
|
||||||
issue_config = #{record.issueConfig,jdbcType=VARCHAR},
|
issue_config = #{record.issueConfig,jdbcType=VARCHAR},
|
||||||
api_template_id = #{record.apiTemplateId,jdbcType=VARCHAR}
|
api_template_id = #{record.apiTemplateId,jdbcType=VARCHAR},
|
||||||
|
module_setting = #{record.moduleSetting,jdbcType=VARCHAR}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause" />
|
<include refid="Update_By_Example_Where_Clause" />
|
||||||
</if>
|
</if>
|
||||||
|
@ -302,6 +313,9 @@
|
||||||
<if test="apiTemplateId != null">
|
<if test="apiTemplateId != null">
|
||||||
api_template_id = #{apiTemplateId,jdbcType=VARCHAR},
|
api_template_id = #{apiTemplateId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="moduleSetting != null">
|
||||||
|
module_setting = #{moduleSetting,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
|
@ -317,20 +331,22 @@
|
||||||
third_part_template = #{thirdPartTemplate,jdbcType=BIT},
|
third_part_template = #{thirdPartTemplate,jdbcType=BIT},
|
||||||
version_enable = #{versionEnable,jdbcType=BIT},
|
version_enable = #{versionEnable,jdbcType=BIT},
|
||||||
issue_config = #{issueConfig,jdbcType=VARCHAR},
|
issue_config = #{issueConfig,jdbcType=VARCHAR},
|
||||||
api_template_id = #{apiTemplateId,jdbcType=VARCHAR}
|
api_template_id = #{apiTemplateId,jdbcType=VARCHAR},
|
||||||
|
module_setting = #{moduleSetting,jdbcType=VARCHAR}
|
||||||
where id = #{id,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
</update>
|
</update>
|
||||||
<insert id="batchInsert" parameterType="map">
|
<insert id="batchInsert" parameterType="map">
|
||||||
insert into project_extend
|
insert into project_extend
|
||||||
(id, tapd_id, jira_key, zentao_id, azure_devops_id, case_template_id, azure_filter_id,
|
(id, tapd_id, jira_key, zentao_id, azure_devops_id, case_template_id, azure_filter_id,
|
||||||
platform, third_part_template, version_enable, issue_config, api_template_id)
|
platform, third_part_template, version_enable, issue_config, api_template_id, module_setting
|
||||||
|
)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id,jdbcType=VARCHAR}, #{item.tapdId,jdbcType=VARCHAR}, #{item.jiraKey,jdbcType=VARCHAR},
|
(#{item.id,jdbcType=VARCHAR}, #{item.tapdId,jdbcType=VARCHAR}, #{item.jiraKey,jdbcType=VARCHAR},
|
||||||
#{item.zentaoId,jdbcType=VARCHAR}, #{item.azureDevopsId,jdbcType=VARCHAR}, #{item.caseTemplateId,jdbcType=VARCHAR},
|
#{item.zentaoId,jdbcType=VARCHAR}, #{item.azureDevopsId,jdbcType=VARCHAR}, #{item.caseTemplateId,jdbcType=VARCHAR},
|
||||||
#{item.azureFilterId,jdbcType=VARCHAR}, #{item.platform,jdbcType=VARCHAR}, #{item.thirdPartTemplate,jdbcType=BIT},
|
#{item.azureFilterId,jdbcType=VARCHAR}, #{item.platform,jdbcType=VARCHAR}, #{item.thirdPartTemplate,jdbcType=BIT},
|
||||||
#{item.versionEnable,jdbcType=BIT}, #{item.issueConfig,jdbcType=VARCHAR}, #{item.apiTemplateId,jdbcType=VARCHAR}
|
#{item.versionEnable,jdbcType=BIT}, #{item.issueConfig,jdbcType=VARCHAR}, #{item.apiTemplateId,jdbcType=VARCHAR},
|
||||||
)
|
#{item.moduleSetting,jdbcType=VARCHAR})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="batchInsertSelective" parameterType="map">
|
<insert id="batchInsertSelective" parameterType="map">
|
||||||
|
@ -379,6 +395,9 @@
|
||||||
<if test="'api_template_id'.toString() == column.value">
|
<if test="'api_template_id'.toString() == column.value">
|
||||||
#{item.apiTemplateId,jdbcType=VARCHAR}
|
#{item.apiTemplateId,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="'module_setting'.toString() == column.value">
|
||||||
|
#{item.moduleSetting,jdbcType=VARCHAR}
|
||||||
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
|
@ -3,21 +3,45 @@ SET SESSION innodb_lock_wait_timeout = 7200;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS custom_field
|
CREATE TABLE IF NOT EXISTS custom_field
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '自定义字段ID',
|
`id` VARCHAR
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '自定义字段名称',
|
(
|
||||||
`scene` VARCHAR(30) NOT NULL COMMENT '使用场景',
|
50
|
||||||
`type` VARCHAR(30) NOT NULL COMMENT '自定义字段类型',
|
) NOT NULL COMMENT '自定义字段ID',
|
||||||
`remark` VARCHAR(255) COMMENT '自定义字段备注',
|
`name` VARCHAR
|
||||||
`options` TEXT COMMENT '自定义字段选项',
|
(
|
||||||
`system` BIT DEFAULT 0 COMMENT '是否是系统字段',
|
255
|
||||||
`global` BIT DEFAULT 0 COMMENT '是否是全局字段',
|
) NOT NULL COMMENT '自定义字段名称',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`scene` VARCHAR
|
||||||
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
(
|
||||||
`create_user` VARCHAR(50) COMMENT '创建人',
|
30
|
||||||
`project_id` VARCHAR(50) COMMENT '项目ID',
|
) NOT NULL COMMENT '使用场景',
|
||||||
`third_part` BIT NOT NULL DEFAULT 0 COMMENT '是否关联第三方',
|
`type` VARCHAR
|
||||||
PRIMARY KEY (id)
|
(
|
||||||
) COMMENT = '自定义字段';
|
30
|
||||||
|
) NOT NULL COMMENT '自定义字段类型',
|
||||||
|
`remark` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '自定义字段备注',
|
||||||
|
`options` TEXT COMMENT '自定义字段选项',
|
||||||
|
`system` BIT DEFAULT 0 COMMENT '是否是系统字段',
|
||||||
|
`global` BIT DEFAULT 0 COMMENT '是否是全局字段',
|
||||||
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
|
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '创建人',
|
||||||
|
`project_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '项目ID',
|
||||||
|
`third_part` BIT NOT NULL DEFAULT 0 COMMENT '是否关联第三方',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '自定义字段';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_global ON custom_field (global);
|
CREATE INDEX idx_global ON custom_field (global);
|
||||||
|
@ -30,17 +54,38 @@ CREATE INDEX idx_project_id ON custom_field (project_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS custom_field_template
|
CREATE TABLE IF NOT EXISTS custom_field_template
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '自定义模版ID',
|
`id` VARCHAR
|
||||||
`field_id` VARCHAR(50) NOT NULL COMMENT '自定义字段ID',
|
(
|
||||||
`template_id` VARCHAR(50) NOT NULL COMMENT '模版ID',
|
50
|
||||||
`scene` VARCHAR(30) NOT NULL COMMENT '使用场景',
|
) NOT NULL COMMENT '自定义模版ID',
|
||||||
`required` BIT COMMENT '是否必填',
|
`field_id` VARCHAR
|
||||||
`pos` INT COMMENT '排序字段',
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '自定义字段ID',
|
||||||
|
`template_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '模版ID',
|
||||||
|
`scene` VARCHAR
|
||||||
|
(
|
||||||
|
30
|
||||||
|
) NOT NULL COMMENT '使用场景',
|
||||||
|
`required` BIT COMMENT '是否必填',
|
||||||
|
`pos` INT COMMENT '排序字段',
|
||||||
`default_value` LONGBLOB COMMENT '默认值',
|
`default_value` LONGBLOB COMMENT '默认值',
|
||||||
`custom_data` VARCHAR(255) COMMENT '自定义数据',
|
`custom_data` VARCHAR
|
||||||
`key` VARCHAR(1) COMMENT '自定义表头',
|
(
|
||||||
PRIMARY KEY (id)
|
255
|
||||||
) COMMENT = '自定义模版';
|
) COMMENT '自定义数据',
|
||||||
|
`key` VARCHAR
|
||||||
|
(
|
||||||
|
1
|
||||||
|
) COMMENT '自定义表头',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '自定义模版';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX custom_field_template_field_id_index ON custom_field_template (field_id);
|
CREATE INDEX custom_field_template_field_id_index ON custom_field_template (field_id);
|
||||||
|
@ -48,29 +93,65 @@ CREATE INDEX custom_field_template_template_id_index ON custom_field_template (t
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS custom_function
|
CREATE TABLE IF NOT EXISTS custom_function
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '',
|
`id` VARCHAR
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '函数名',
|
(
|
||||||
`tags` VARCHAR(1000) COMMENT '标签',
|
50
|
||||||
`description` VARCHAR(500) COMMENT '函数描述',
|
) NOT NULL COMMENT '',
|
||||||
PRIMARY KEY (id)
|
`name` VARCHAR
|
||||||
) COMMENT = '自定义函数-代码片段';
|
(
|
||||||
|
255
|
||||||
|
) NOT NULL COMMENT '函数名',
|
||||||
|
`tags` VARCHAR
|
||||||
|
(
|
||||||
|
1000
|
||||||
|
) COMMENT '标签',
|
||||||
|
`description` VARCHAR
|
||||||
|
(
|
||||||
|
500
|
||||||
|
) COMMENT '函数描述',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '自定义函数-代码片段';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX name ON custom_function (name);
|
CREATE INDEX name ON custom_function (name);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS fake_error
|
CREATE TABLE IF NOT EXISTS fake_error
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '误报ID',
|
`id` VARCHAR
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
(
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
50
|
||||||
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
) NOT NULL COMMENT '误报ID',
|
||||||
`create_user` VARCHAR(64) NOT NULL COMMENT '创建人',
|
`project_id` VARCHAR
|
||||||
`update_user` VARCHAR(64) NOT NULL COMMENT '更新人',
|
(
|
||||||
`error_code` VARCHAR(255) NOT NULL COMMENT '错误码',
|
50
|
||||||
`match_type` VARCHAR(255) NOT NULL COMMENT '匹配类型',
|
) NOT NULL COMMENT '项目ID',
|
||||||
`status` BIT COMMENT '状态',
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
PRIMARY KEY (id)
|
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
||||||
) COMMENT = '误报库';
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
64
|
||||||
|
) NOT NULL COMMENT '创建人',
|
||||||
|
`update_user` VARCHAR
|
||||||
|
(
|
||||||
|
64
|
||||||
|
) NOT NULL COMMENT '更新人',
|
||||||
|
`error_code` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) NOT NULL COMMENT '错误码',
|
||||||
|
`match_type` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) NOT NULL COMMENT '匹配类型',
|
||||||
|
`status` BIT COMMENT '状态',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '误报库';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_project_id ON fake_error (project_id);
|
CREATE INDEX idx_project_id ON fake_error (project_id);
|
||||||
|
@ -82,15 +163,39 @@ CREATE INDEX idx_update_user ON fake_error (update_user);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS file_association
|
CREATE TABLE IF NOT EXISTS file_association
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '',
|
`id` VARCHAR
|
||||||
`type` VARCHAR(50) NOT NULL COMMENT '模块类型,服务拆分后就是各个服务',
|
(
|
||||||
`source_id` VARCHAR(50) NOT NULL COMMENT '各个模块关联时自身Id/比如API/CASE/SCENAEIO',
|
50
|
||||||
`source_item_id` VARCHAR(50) NOT NULL COMMENT '对应资源引用时具体id,如一个用例引用多个文件',
|
) NOT NULL COMMENT '',
|
||||||
`file_metadata_id` VARCHAR(50) NOT NULL COMMENT '文件id',
|
`type` VARCHAR
|
||||||
`file_type` VARCHAR(50) NOT NULL COMMENT '文件类型',
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目id',
|
50
|
||||||
PRIMARY KEY (id)
|
) NOT NULL COMMENT '模块类型,服务拆分后就是各个服务',
|
||||||
) COMMENT = '文件关联资源关系(分散到模块)';
|
`source_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '各个模块关联时自身Id/比如API/CASE/SCENAEIO',
|
||||||
|
`source_item_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '对应资源引用时具体id,如一个用例引用多个文件',
|
||||||
|
`file_metadata_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '文件id',
|
||||||
|
`file_type` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '文件类型',
|
||||||
|
`project_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '项目id',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '文件关联资源关系(分散到模块)';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_file_metadata_id ON file_association (file_metadata_id);
|
CREATE INDEX idx_file_metadata_id ON file_association (file_metadata_id);
|
||||||
|
@ -99,26 +204,68 @@ CREATE INDEX idx_source_id ON file_association (source_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS file_metadata
|
CREATE TABLE IF NOT EXISTS file_metadata
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '文件ID',
|
`id` VARCHAR
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '文件名',
|
(
|
||||||
`type` VARCHAR(64) COMMENT '文件类型',
|
50
|
||||||
`size` BIGINT NOT NULL COMMENT '文件大小',
|
) NOT NULL COMMENT '文件ID',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`name` VARCHAR
|
||||||
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
255
|
||||||
`storage` VARCHAR(50) NOT NULL DEFAULT 'MINIO' COMMENT '文件存储方式',
|
) NOT NULL COMMENT '文件名',
|
||||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人',
|
`type` VARCHAR
|
||||||
`update_user` VARCHAR(50) NOT NULL COMMENT '修改人',
|
(
|
||||||
`tags` VARCHAR(1000) COMMENT '标签',
|
64
|
||||||
`description` VARCHAR(500) COMMENT '描述',
|
) COMMENT '文件类型',
|
||||||
`module_id` VARCHAR(50) COMMENT '文件所属模块',
|
`size` BIGINT NOT NULL COMMENT '文件大小',
|
||||||
`load_jar` BIT DEFAULT 0 COMMENT '是否加载jar(开启后用于接口测试执行时使用)',
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
`path` VARCHAR(1000) COMMENT '文件存储路径',
|
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
||||||
`resource_type` VARCHAR(50) COMMENT '资源作用范围,主要兼容2.1版本前的历史数据,后续版本不再产生数据',
|
`project_id` VARCHAR
|
||||||
`latest` BIT NOT NULL DEFAULT 1 COMMENT '是否是最新版',
|
(
|
||||||
`ref_id` VARCHAR(50) NOT NULL COMMENT '同版本数据关联的ID',
|
50
|
||||||
PRIMARY KEY (id)
|
) NOT NULL COMMENT '项目ID',
|
||||||
) COMMENT = '文件基础信息';
|
`storage` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL DEFAULT 'MINIO' COMMENT '文件存储方式',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '创建人',
|
||||||
|
`update_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '修改人',
|
||||||
|
`tags` VARCHAR
|
||||||
|
(
|
||||||
|
1000
|
||||||
|
) COMMENT '标签',
|
||||||
|
`description` VARCHAR
|
||||||
|
(
|
||||||
|
500
|
||||||
|
) COMMENT '描述',
|
||||||
|
`module_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '文件所属模块',
|
||||||
|
`load_jar` BIT DEFAULT 0 COMMENT '是否加载jar(开启后用于接口测试执行时使用)',
|
||||||
|
`path` VARCHAR
|
||||||
|
(
|
||||||
|
1000
|
||||||
|
) COMMENT '文件存储路径',
|
||||||
|
`resource_type` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '资源作用范围,主要兼容2.1版本前的历史数据,后续版本不再产生数据',
|
||||||
|
`latest` BIT NOT NULL DEFAULT 1 COMMENT '是否是最新版',
|
||||||
|
`ref_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '同版本数据关联的ID',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '文件基础信息';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_file_name ON file_metadata (name);
|
CREATE INDEX idx_file_name ON file_metadata (name);
|
||||||
|
@ -130,18 +277,39 @@ CREATE INDEX idx_project_id ON file_metadata (project_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS file_module
|
CREATE TABLE IF NOT EXISTS file_module
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
`id` VARCHAR
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
(
|
||||||
`name` VARCHAR(64) NOT NULL COMMENT '模块名称',
|
50
|
||||||
`parent_id` VARCHAR(50) COMMENT '父级ID',
|
) NOT NULL COMMENT 'ID',
|
||||||
`level` INT DEFAULT 1 COMMENT '层数',
|
`project_id` VARCHAR
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
(
|
||||||
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
50
|
||||||
`pos` DOUBLE COMMENT '排序用的标识',
|
) NOT NULL COMMENT '项目ID',
|
||||||
`create_user` VARCHAR(50) COMMENT '创建人',
|
`name` VARCHAR
|
||||||
`module_type` VARCHAR(20) DEFAULT 'module' COMMENT '模块类型: module/repository',
|
(
|
||||||
PRIMARY KEY (id)
|
64
|
||||||
) COMMENT = '文件管理模块';
|
) NOT NULL COMMENT '模块名称',
|
||||||
|
`parent_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '父级ID',
|
||||||
|
`level` INT DEFAULT 1 COMMENT '层数',
|
||||||
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
|
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
||||||
|
`pos` DOUBLE COMMENT '排序用的标识',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '创建人',
|
||||||
|
`module_type` VARCHAR
|
||||||
|
(
|
||||||
|
20
|
||||||
|
) DEFAULT 'module' COMMENT '模块类型: module/repository',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '文件管理模块';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_project_id ON file_module (project_id);
|
CREATE INDEX idx_project_id ON file_module (project_id);
|
||||||
|
@ -153,22 +321,49 @@ CREATE INDEX idx_create_user ON file_module (create_user);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS project
|
CREATE TABLE IF NOT EXISTS project
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
`id` VARCHAR
|
||||||
`num` BIGINT NOT NULL AUTO_INCREMENT COMMENT '项目编号',
|
(
|
||||||
`organization_id` VARCHAR(50) NOT NULL COMMENT '组织ID',
|
50
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '项目名称',
|
) NOT NULL COMMENT '项目ID',
|
||||||
`description` VARCHAR(500) COMMENT '项目描述',
|
`num` BIGINT NOT NULL AUTO_INCREMENT COMMENT '项目编号',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`organization_id` VARCHAR
|
||||||
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
(
|
||||||
`update_user` VARCHAR(50) NOT NULL COMMENT '修改人',
|
50
|
||||||
`create_user` VARCHAR(50) COMMENT '创建人',
|
) NOT NULL COMMENT '组织ID',
|
||||||
`delete_time` BIGINT COMMENT '删除时间',
|
`name` VARCHAR
|
||||||
`deleted` BIT NOT NULL DEFAULT 0 COMMENT '是否删除',
|
(
|
||||||
`delete_user` VARCHAR(50) COMMENT '删除人',
|
255
|
||||||
`enable` BIT COMMENT '是否启用',
|
) NOT NULL COMMENT '项目名称',
|
||||||
PRIMARY KEY (id),
|
`description` VARCHAR
|
||||||
CONSTRAINT idx_num UNIQUE (num)
|
(
|
||||||
) COMMENT = '项目';
|
500
|
||||||
|
) COMMENT '项目描述',
|
||||||
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
|
`update_time` BIGINT NOT NULL COMMENT '更新时间',
|
||||||
|
`update_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '修改人',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '创建人',
|
||||||
|
`delete_time` BIGINT COMMENT '删除时间',
|
||||||
|
`deleted` BIT NOT NULL DEFAULT 0 COMMENT '是否删除',
|
||||||
|
`delete_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) COMMENT '删除人',
|
||||||
|
`enable` BIT COMMENT '是否启用',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
),
|
||||||
|
CONSTRAINT idx_num UNIQUE
|
||||||
|
(
|
||||||
|
num
|
||||||
|
)
|
||||||
|
) COMMENT = '项目';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_organization_id ON project (organization_id);
|
CREATE INDEX idx_organization_id ON project (organization_id);
|
||||||
|
@ -177,34 +372,68 @@ CREATE INDEX idx_create_time ON project (create_time);
|
||||||
CREATE INDEX idx_update_time ON project (update_time);
|
CREATE INDEX idx_update_time ON project (update_time);
|
||||||
CREATE INDEX idx_name ON project (name);
|
CREATE INDEX idx_name ON project (name);
|
||||||
CREATE INDEX idx_deleted ON project (deleted);
|
CREATE INDEX idx_deleted ON project (deleted);
|
||||||
CREATE INDEX idx_update_user ON project(update_user);
|
CREATE INDEX idx_update_user ON project (update_user);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS project_application
|
CREATE TABLE IF NOT EXISTS project_application
|
||||||
(
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
`project_id` VARCHAR
|
||||||
`type` VARCHAR(50) NOT NULL COMMENT '配置项',
|
(
|
||||||
`type_value` VARCHAR(255) COMMENT '配置值',
|
50
|
||||||
PRIMARY KEY (project_id, type)
|
) NOT NULL COMMENT '项目ID',
|
||||||
) COMMENT = '项目应用';
|
`type` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '配置项',
|
||||||
|
`type_value` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '配置值',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
project_id,
|
||||||
|
type
|
||||||
|
)
|
||||||
|
) COMMENT = '项目应用';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_project_application_type ON project_application (type);
|
CREATE INDEX idx_project_application_type ON project_application (type);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS project_version
|
CREATE TABLE IF NOT EXISTS project_version
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '版本ID',
|
`id` VARCHAR
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
(
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '版本名称',
|
50
|
||||||
`description` VARCHAR(500) COMMENT '描述',
|
) NOT NULL COMMENT '版本ID',
|
||||||
`status` VARCHAR(20) COMMENT '状态',
|
`project_id` VARCHAR
|
||||||
`latest` BIT NOT NULL COMMENT '是否是最新版',
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '项目ID',
|
||||||
|
`name` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) NOT NULL COMMENT '版本名称',
|
||||||
|
`description` VARCHAR
|
||||||
|
(
|
||||||
|
500
|
||||||
|
) COMMENT '描述',
|
||||||
|
`status` VARCHAR
|
||||||
|
(
|
||||||
|
20
|
||||||
|
) COMMENT '状态',
|
||||||
|
`latest` BIT NOT NULL COMMENT '是否是最新版',
|
||||||
`publish_time` BIGINT COMMENT '发布时间',
|
`publish_time` BIGINT COMMENT '发布时间',
|
||||||
`start_time` BIGINT COMMENT '开始时间',
|
`start_time` BIGINT COMMENT '开始时间',
|
||||||
`end_time` BIGINT COMMENT '结束时间',
|
`end_time` BIGINT COMMENT '结束时间',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人',
|
`create_user` VARCHAR
|
||||||
PRIMARY KEY (id)
|
(
|
||||||
) COMMENT = '版本管理';
|
50
|
||||||
|
) NOT NULL COMMENT '创建人',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '版本管理';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_project_id ON project_version (project_id);
|
CREATE INDEX idx_project_id ON project_version (project_id);
|
||||||
|
@ -215,39 +444,73 @@ CREATE INDEX idx_latest ON project_version (latest);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS file_module_blob
|
CREATE TABLE IF NOT EXISTS file_module_blob
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
`id` VARCHAR
|
||||||
`repository_desc` LONGBLOB COMMENT '存储库描述',
|
(
|
||||||
`repository_path` VARCHAR(255) COMMENT '存储库路径',
|
50
|
||||||
`repository_user_name` VARCHAR(255) COMMENT '存储库Token',
|
) NOT NULL COMMENT 'ID',
|
||||||
`repository_token` VARCHAR(255) COMMENT '存储库Token',
|
`repository_desc` LONGBLOB COMMENT '存储库描述',
|
||||||
PRIMARY KEY (id)
|
`repository_path` VARCHAR
|
||||||
) COMMENT = '文件管理模块大字段';
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '存储库路径',
|
||||||
|
`repository_user_name` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '存储库Token',
|
||||||
|
`repository_token` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '存储库Token',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '文件管理模块大字段';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS custom_function_blob
|
CREATE TABLE IF NOT EXISTS custom_function_blob
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '',
|
`id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '',
|
||||||
`params` LONGBLOB COMMENT '参数列表',
|
`params` LONGBLOB COMMENT '参数列表',
|
||||||
`script` LONGBLOB COMMENT '函数体',
|
`script` LONGBLOB COMMENT '函数体',
|
||||||
`result` LONGBLOB COMMENT '执行结果',
|
`result` LONGBLOB COMMENT '执行结果',
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY
|
||||||
) COMMENT = '自定义函数-代码片段大字段';
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '自定义函数-代码片段大字段';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS fake_error_blob
|
CREATE TABLE IF NOT EXISTS fake_error_blob
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'Test ID',
|
`id` VARCHAR
|
||||||
`content` LONGBLOB COMMENT '内容',
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT 'Test ID',
|
||||||
|
`content` LONGBLOB COMMENT '内容',
|
||||||
`description` LONGBLOB COMMENT '报告内容',
|
`description` LONGBLOB COMMENT '报告内容',
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY
|
||||||
) COMMENT = '误报库大字段';
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '误报库大字段';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS file_metadata_blob
|
CREATE TABLE IF NOT EXISTS file_metadata_blob
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '文件ID',
|
`id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '文件ID',
|
||||||
`git_info` LONGBLOB COMMENT '储存库',
|
`git_info` LONGBLOB COMMENT '储存库',
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY
|
||||||
) COMMENT = '文件基础信息大字段';
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '文件基础信息大字段';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS project_extend
|
DROP TABLE IF EXISTS project_extend;
|
||||||
|
CREATE TABLE project_extend
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
`id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
||||||
`tapd_id` VARCHAR(50) COMMENT '',
|
`tapd_id` VARCHAR(50) COMMENT '',
|
||||||
|
@ -261,6 +524,7 @@ CREATE TABLE IF NOT EXISTS project_extend
|
||||||
`version_enable` BIT DEFAULT 1 COMMENT '是否开启版本管理',
|
`version_enable` BIT DEFAULT 1 COMMENT '是否开启版本管理',
|
||||||
`issue_config` VARCHAR(2000) COMMENT '',
|
`issue_config` VARCHAR(2000) COMMENT '',
|
||||||
`api_template_id` VARCHAR(64) COMMENT '',
|
`api_template_id` VARCHAR(64) COMMENT '',
|
||||||
|
`module_setting` VARCHAR(255) COMMENT '模块设置',
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
) COMMENT = '项目扩展';
|
) COMMENT = '项目扩展';
|
||||||
|
|
||||||
|
@ -269,15 +533,33 @@ CREATE INDEX idx_project_id ON project_extend (id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS functional_case_template
|
CREATE TABLE IF NOT EXISTS functional_case_template
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
`id` VARCHAR
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '名称',
|
(
|
||||||
`description` VARCHAR(500) COMMENT '描述',
|
50
|
||||||
`internal` BIT NOT NULL DEFAULT 0 COMMENT '是否是内置模板',
|
) NOT NULL COMMENT 'ID',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`name` VARCHAR
|
||||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人',
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
255
|
||||||
PRIMARY KEY (id)
|
) NOT NULL COMMENT '名称',
|
||||||
) COMMENT = '功能用例模版';
|
`description` VARCHAR
|
||||||
|
(
|
||||||
|
500
|
||||||
|
) COMMENT '描述',
|
||||||
|
`internal` BIT NOT NULL DEFAULT 0 COMMENT '是否是内置模板',
|
||||||
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '创建人',
|
||||||
|
`project_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '项目ID',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '功能用例模版';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_name ON functional_case_template (name);
|
CREATE INDEX idx_name ON functional_case_template (name);
|
||||||
|
@ -288,36 +570,75 @@ CREATE INDEX idx_project_id ON functional_case_template (project_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS functional_case_template_extend
|
CREATE TABLE IF NOT EXISTS functional_case_template_extend
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '模板ID',
|
`id` VARCHAR
|
||||||
`case_name` VARCHAR(255) COMMENT '用例名称模板',
|
(
|
||||||
`prerequisite` TEXT COMMENT '前置条件模板',
|
50
|
||||||
|
) NOT NULL COMMENT '模板ID',
|
||||||
|
`case_name` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '用例名称模板',
|
||||||
|
`prerequisite` TEXT COMMENT '前置条件模板',
|
||||||
`step_description` TEXT COMMENT '步骤描述模板',
|
`step_description` TEXT COMMENT '步骤描述模板',
|
||||||
`expected_result` TEXT COMMENT '预期结果模板',
|
`expected_result` TEXT COMMENT '预期结果模板',
|
||||||
`actual_result` TEXT COMMENT '实际结果模板',
|
`actual_result` TEXT COMMENT '实际结果模板',
|
||||||
`step_model` VARCHAR(64) NOT NULL DEFAULT 'Step' COMMENT '编辑模式模板:步骤模式/文本模式',
|
`step_model` VARCHAR
|
||||||
`steps` TEXT COMMENT '用例步骤',
|
(
|
||||||
PRIMARY KEY (id)
|
64
|
||||||
) COMMENT = '功能用例模版扩展';
|
) NOT NULL DEFAULT 'Step' COMMENT '编辑模式模板:步骤模式/文本模式',
|
||||||
|
`steps` TEXT COMMENT '用例步骤',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '功能用例模版扩展';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS bug_template_extend
|
CREATE TABLE IF NOT EXISTS bug_template_extend
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT '缺陷模板ID',
|
`id` VARCHAR
|
||||||
`title` VARCHAR(255) COMMENT '缺陷标题模板',
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '缺陷模板ID',
|
||||||
|
`title` VARCHAR
|
||||||
|
(
|
||||||
|
255
|
||||||
|
) COMMENT '缺陷标题模板',
|
||||||
`content` TEXT COMMENT '缺陷内容模板',
|
`content` TEXT COMMENT '缺陷内容模板',
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY
|
||||||
) COMMENT = '缺陷模板扩展';
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '缺陷模板扩展';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS bug_template
|
CREATE TABLE IF NOT EXISTS bug_template
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
`id` VARCHAR
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '名称',
|
(
|
||||||
`description` VARCHAR(500) COMMENT '描述',
|
50
|
||||||
`internal` BIT NOT NULL DEFAULT 0 COMMENT '是否是内置模板',
|
) NOT NULL COMMENT 'ID',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`name` VARCHAR
|
||||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人',
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
255
|
||||||
PRIMARY KEY (id)
|
) NOT NULL COMMENT '名称',
|
||||||
) COMMENT = '缺陷模版';
|
`description` VARCHAR
|
||||||
|
(
|
||||||
|
500
|
||||||
|
) COMMENT '描述',
|
||||||
|
`internal` BIT NOT NULL DEFAULT 0 COMMENT '是否是内置模板',
|
||||||
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '创建人',
|
||||||
|
`project_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '项目ID',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '缺陷模版';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_name ON bug_template (name);
|
CREATE INDEX idx_name ON bug_template (name);
|
||||||
|
@ -328,15 +649,33 @@ CREATE INDEX idx_project_id ON bug_template (project_id);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS api_template
|
CREATE TABLE IF NOT EXISTS api_template
|
||||||
(
|
(
|
||||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID',
|
`id` VARCHAR
|
||||||
`name` VARCHAR(255) NOT NULL COMMENT '名称',
|
(
|
||||||
`description` VARCHAR(500) COMMENT '描述',
|
50
|
||||||
`internal` BIT NOT NULL DEFAULT 0 COMMENT '是否是内置模板',
|
) NOT NULL COMMENT 'ID',
|
||||||
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
`name` VARCHAR
|
||||||
`create_user` VARCHAR(50) NOT NULL COMMENT '创建人',
|
(
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
|
255
|
||||||
PRIMARY KEY (id)
|
) NOT NULL COMMENT '名称',
|
||||||
) COMMENT = '接口定义模板';
|
`description` VARCHAR
|
||||||
|
(
|
||||||
|
500
|
||||||
|
) COMMENT '描述',
|
||||||
|
`internal` BIT NOT NULL DEFAULT 0 COMMENT '是否是内置模板',
|
||||||
|
`create_time` BIGINT NOT NULL COMMENT '创建时间',
|
||||||
|
`create_user` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '创建人',
|
||||||
|
`project_id` VARCHAR
|
||||||
|
(
|
||||||
|
50
|
||||||
|
) NOT NULL COMMENT '项目ID',
|
||||||
|
PRIMARY KEY
|
||||||
|
(
|
||||||
|
id
|
||||||
|
)
|
||||||
|
) COMMENT = '接口定义模板';
|
||||||
|
|
||||||
|
|
||||||
CREATE INDEX idx_name ON api_template (name);
|
CREATE INDEX idx_name ON api_template (name);
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class PermissionConstants {
|
||||||
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE = "SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE";
|
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE = "SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE";
|
||||||
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_DELETE = "SYSTEM_ORGANIZATION_PROJECT:READ+DELETE";
|
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_DELETE = "SYSTEM_ORGANIZATION_PROJECT:READ+DELETE";
|
||||||
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_RECOVER = "SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER";
|
public static final String SYSTEM_ORGANIZATION_PROJECT_READ_RECOVER = "SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER";
|
||||||
|
public static final String SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD = "SYSTEM_ORGANIZATION_PROJECT_MEMBER:ADD";
|
||||||
|
public static final String SYSTEM_ORGANIZATION_PROJECT_MEMBER_DELETE = "SYSTEM_ORGANIZATION_PROJECT_MEMBER:DELETE";
|
||||||
/*------ end: SYSTEM_ORGANIZATION_PROJECT ------*/
|
/*------ end: SYSTEM_ORGANIZATION_PROJECT ------*/
|
||||||
|
|
||||||
/*------ start: ORGANIZATION_USER_ROLE ------*/
|
/*------ start: ORGANIZATION_USER_ROLE ------*/
|
||||||
|
@ -40,6 +42,9 @@ public class PermissionConstants {
|
||||||
public static final String ORGANIZATION_PROJECT_READ_UPDATE = "ORGANIZATION_PROJECT:READ+UPDATE";
|
public static final String ORGANIZATION_PROJECT_READ_UPDATE = "ORGANIZATION_PROJECT:READ+UPDATE";
|
||||||
public static final String ORGANIZATION_PROJECT_READ_DELETE = "ORGANIZATION_PROJECT:READ+DELETE";
|
public static final String ORGANIZATION_PROJECT_READ_DELETE = "ORGANIZATION_PROJECT:READ+DELETE";
|
||||||
public static final String ORGANIZATION_PROJECT_READ_RECOVER = "ORGANIZATION_PROJECT:READ+RECOVER";
|
public static final String ORGANIZATION_PROJECT_READ_RECOVER = "ORGANIZATION_PROJECT:READ+RECOVER";
|
||||||
|
public static final String ORGANIZATION_PROJECT_MEMBER_ADD = "ORGANIZATION_PROJECT_MEMBER:ADD";
|
||||||
|
public static final String ORGANIZATION_PROJECT_MEMBER_DELETE = "ORGANIZATION_PROJECT_MEMBER:DELETE";
|
||||||
|
|
||||||
/*------ end: ORGANIZATION_PROJECT ------*/
|
/*------ end: ORGANIZATION_PROJECT ------*/
|
||||||
|
|
||||||
/*------ start: SYSTEM_PLUGIN ------*/
|
/*------ start: SYSTEM_PLUGIN ------*/
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package io.metersphere.sdk.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class ModuleSettingDTO {
|
||||||
|
|
||||||
|
@Schema(description = "接口测试")
|
||||||
|
private boolean apiTest;
|
||||||
|
@Schema(description = "性能测试")
|
||||||
|
private boolean loadTest;
|
||||||
|
@Schema(description = "UI测试")
|
||||||
|
private boolean uiTest;
|
||||||
|
@Schema(description = "测试计划")
|
||||||
|
private boolean testPlan;
|
||||||
|
@Schema(description = "工作台")
|
||||||
|
private boolean workstation;
|
||||||
|
@Schema(description = "缺陷管理")
|
||||||
|
private boolean bugManagement;
|
||||||
|
@Schema(description = "功能测试")
|
||||||
|
private boolean caseManagement;
|
||||||
|
}
|
|
@ -27,4 +27,7 @@ public class ProjectBaseRequest {
|
||||||
|
|
||||||
@Schema(description = "是否启用")
|
@Schema(description = "是否启用")
|
||||||
private Boolean enable;
|
private Boolean enable;
|
||||||
|
|
||||||
|
@Schema(description = "模块设置")
|
||||||
|
private ModuleSettingDTO moduleSetting;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,6 +192,8 @@ permission.organization_user_role.name=User group
|
||||||
permission.organization_member.name=User
|
permission.organization_member.name=User
|
||||||
permission.service_integration.name=Service Integration
|
permission.service_integration.name=Service Integration
|
||||||
permission.system_auth=Authorization Management
|
permission.system_auth=Authorization Management
|
||||||
|
permission.system_organization_project_member.add=Add member
|
||||||
|
permission.system_organization_project_member.delete=Delete member
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,9 @@ permission.organization_user_role.name=用户组
|
||||||
permission.organization_member.name=用户
|
permission.organization_member.name=用户
|
||||||
permission.service_integration.name=服务集成
|
permission.service_integration.name=服务集成
|
||||||
permission.system_auth=授权管理
|
permission.system_auth=授权管理
|
||||||
|
permission.system_organization_project_member.add=添加成员
|
||||||
|
permission.system_organization_project_member.delete=删除成员
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -191,4 +191,6 @@ permission.organization_user_role.name=用戶組
|
||||||
permission.organization_member.name=用戶
|
permission.organization_member.name=用戶
|
||||||
permission.service_integration.name=服務集成
|
permission.service_integration.name=服務集成
|
||||||
permission.system_auth=授權管理
|
permission.system_auth=授權管理
|
||||||
|
permission.system_organization_project_member.add=添加成员
|
||||||
|
permission.system_organization_project_member.delete=删除成员
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package io.metersphere.system.controller;
|
||||||
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.project.domain.Project;
|
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
|
@ -13,6 +12,7 @@ import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.util.PageUtils;
|
import io.metersphere.sdk.util.PageUtils;
|
||||||
import io.metersphere.sdk.util.Pager;
|
import io.metersphere.sdk.util.Pager;
|
||||||
import io.metersphere.sdk.util.SessionUtils;
|
import io.metersphere.sdk.util.SessionUtils;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
import io.metersphere.system.request.OrganizationProjectRequest;
|
import io.metersphere.system.request.OrganizationProjectRequest;
|
||||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||||
|
@ -46,7 +46,7 @@ public class OrganizationProjectController {
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_ADD)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_ADD)
|
||||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#project)", msClass = OrganizationProjectLogService.class)
|
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#project)", msClass = OrganizationProjectLogService.class)
|
||||||
@Operation(summary = "添加项目")
|
@Operation(summary = "添加项目")
|
||||||
public Project addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
public ProjectExtendDTO addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
||||||
return organizationProjectService.add(project, SessionUtils.getUserId());
|
return organizationProjectService.add(project, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class OrganizationProjectController {
|
||||||
@Operation(summary = "根据ID获取项目信息")
|
@Operation(summary = "根据ID获取项目信息")
|
||||||
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||||
public Project getProject(@PathVariable @NotBlank String id) {
|
public ProjectExtendDTO getProject(@PathVariable @NotBlank String id) {
|
||||||
return organizationProjectService.get(id);
|
return organizationProjectService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class OrganizationProjectController {
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#project)", msClass = OrganizationProjectLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#project)", msClass = OrganizationProjectLogService.class)
|
||||||
@Operation(summary = "更新项目信息")
|
@Operation(summary = "更新项目信息")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
||||||
public Project updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
public ProjectExtendDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
||||||
return organizationProjectService.update(project, SessionUtils.getUserId());
|
return organizationProjectService.update(project, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class OrganizationProjectController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add-members")
|
@PostMapping("/add-members")
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_MEMBER_ADD)
|
||||||
@Operation(summary = "添加项目成员")
|
@Operation(summary = "添加项目成员")
|
||||||
public void addProjectMember(@Validated @RequestBody ProjectAddMemberRequest request) {
|
public void addProjectMember(@Validated @RequestBody ProjectAddMemberRequest request) {
|
||||||
ProjectAddMemberBatchRequest batchRequest = new ProjectAddMemberBatchRequest();
|
ProjectAddMemberBatchRequest batchRequest = new ProjectAddMemberBatchRequest();
|
||||||
|
@ -117,7 +117,7 @@ public class OrganizationProjectController {
|
||||||
@Operation(summary = "移除项目成员")
|
@Operation(summary = "移除项目成员")
|
||||||
@Parameter(name = "userId", description = "用户id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "userId", description = "用户id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@Parameter(name = "projectId", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "projectId", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_MEMBER_DELETE)
|
||||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#projectId)", msClass = OrganizationProjectLogService.class)
|
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#projectId)", msClass = OrganizationProjectLogService.class)
|
||||||
public int removeProjectMember(@PathVariable String projectId, @PathVariable String userId) {
|
public int removeProjectMember(@PathVariable String projectId, @PathVariable String userId) {
|
||||||
return organizationProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId());
|
return organizationProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId());
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class SystemOrganizationController {
|
||||||
|
|
||||||
@PostMapping("/add-member")
|
@PostMapping("/add-member")
|
||||||
@Operation(summary = "添加组织成员")
|
@Operation(summary = "添加组织成员")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD)
|
||||||
public void addMember(@Validated @RequestBody OrganizationMemberRequest request) {
|
public void addMember(@Validated @RequestBody OrganizationMemberRequest request) {
|
||||||
organizationService.addMemberBySystem(request, SessionUtils.getUserId());
|
organizationService.addMemberBySystem(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class SystemOrganizationController {
|
||||||
@Parameter(name = "organizationId", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)),
|
@Parameter(name = "organizationId", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)),
|
||||||
@Parameter(name = "userId", description = "成员ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "userId", description = "成员ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
})
|
})
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_DELETE)
|
||||||
public void removeMember(@PathVariable String organizationId, @PathVariable String userId) {
|
public void removeMember(@PathVariable String organizationId, @PathVariable String userId) {
|
||||||
organizationService.removeMember(organizationId, userId);
|
organizationService.removeMember(organizationId, userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package io.metersphere.system.controller;
|
||||||
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.project.domain.Project;
|
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
|
@ -13,6 +12,7 @@ import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.util.PageUtils;
|
import io.metersphere.sdk.util.PageUtils;
|
||||||
import io.metersphere.sdk.util.Pager;
|
import io.metersphere.sdk.util.Pager;
|
||||||
import io.metersphere.sdk.util.SessionUtils;
|
import io.metersphere.sdk.util.SessionUtils;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||||
import io.metersphere.system.request.ProjectAddMemberRequest;
|
import io.metersphere.system.request.ProjectAddMemberRequest;
|
||||||
|
@ -46,7 +46,7 @@ public class SystemProjectController {
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD)
|
||||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#project)", msClass = SystemProjectLogService.class)
|
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#project)", msClass = SystemProjectLogService.class)
|
||||||
@Operation(summary = "添加项目")
|
@Operation(summary = "添加项目")
|
||||||
public Project addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
public ProjectExtendDTO addProject(@RequestBody @Validated({Created.class}) AddProjectRequest project) {
|
||||||
return systemProjectService.add(project, SessionUtils.getUserId());
|
return systemProjectService.add(project, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class SystemProjectController {
|
||||||
@Operation(summary = "根据ID获取项目信息")
|
@Operation(summary = "根据ID获取项目信息")
|
||||||
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||||
public Project getProject(@PathVariable @NotBlank String id) {
|
public ProjectExtendDTO getProject(@PathVariable @NotBlank String id) {
|
||||||
return systemProjectService.get(id);
|
return systemProjectService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class SystemProjectController {
|
||||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#project)", msClass = SystemProjectLogService.class)
|
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#project)", msClass = SystemProjectLogService.class)
|
||||||
@Operation(summary = "更新项目信息")
|
@Operation(summary = "更新项目信息")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
||||||
public Project updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
public ProjectExtendDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest project) {
|
||||||
return systemProjectService.update(project, SessionUtils.getUserId());
|
return systemProjectService.update(project, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class SystemProjectController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add-member")
|
@PostMapping("/add-member")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD)
|
||||||
@Operation(summary = "添加项目成员")
|
@Operation(summary = "添加项目成员")
|
||||||
public void addProjectMember(@Validated @RequestBody ProjectAddMemberRequest request) {
|
public void addProjectMember(@Validated @RequestBody ProjectAddMemberRequest request) {
|
||||||
ProjectAddMemberBatchRequest batchRequest = new ProjectAddMemberBatchRequest();
|
ProjectAddMemberBatchRequest batchRequest = new ProjectAddMemberBatchRequest();
|
||||||
|
@ -116,7 +116,7 @@ public class SystemProjectController {
|
||||||
@Operation(summary = "移除项目成员")
|
@Operation(summary = "移除项目成员")
|
||||||
@Parameter(name = "userId", description = "用户id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "userId", description = "用户id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@Parameter(name = "projectId", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
@Parameter(name = "projectId", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_DELETE)
|
||||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#projectId)", msClass = SystemProjectLogService.class)
|
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#projectId)", msClass = SystemProjectLogService.class)
|
||||||
public int removeProjectMember(@PathVariable String projectId, @PathVariable String userId) {
|
public int removeProjectMember(@PathVariable String projectId, @PathVariable String userId) {
|
||||||
return systemProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId());
|
return systemProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId());
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package io.metersphere.system.dto;
|
||||||
|
|
||||||
|
import io.metersphere.project.domain.Project;
|
||||||
|
import io.metersphere.sdk.dto.ModuleSettingDTO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class ProjectExtendDTO extends Project {
|
||||||
|
|
||||||
|
@Schema(description = "模块设置")
|
||||||
|
private ModuleSettingDTO moduleSetting;
|
||||||
|
}
|
|
@ -2,24 +2,25 @@ package io.metersphere.system.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.Project;
|
import io.metersphere.project.domain.Project;
|
||||||
import io.metersphere.project.domain.ProjectExample;
|
import io.metersphere.project.domain.ProjectExample;
|
||||||
|
import io.metersphere.project.domain.ProjectExtend;
|
||||||
|
import io.metersphere.project.mapper.ProjectExtendMapper;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||||
import io.metersphere.sdk.constants.InternalUserRole;
|
import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||||
import io.metersphere.sdk.constants.UserRoleType;
|
import io.metersphere.sdk.constants.UserRoleType;
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.*;
|
||||||
import io.metersphere.sdk.dto.LogDTO;
|
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
|
||||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
import io.metersphere.sdk.invoker.ProjectServiceInvoker;
|
import io.metersphere.sdk.invoker.ProjectServiceInvoker;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogModule;
|
import io.metersphere.sdk.log.constants.OperationLogModule;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.log.service.OperationLogService;
|
import io.metersphere.sdk.log.service.OperationLogService;
|
||||||
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.domain.*;
|
import io.metersphere.system.domain.*;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.mapper.*;
|
import io.metersphere.system.mapper.*;
|
||||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -53,6 +55,8 @@ public class CommonProjectService {
|
||||||
private UserRoleMapper userRoleMapper;
|
private UserRoleMapper userRoleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserRolePermissionMapper userRolePermissionMapper;
|
private UserRolePermissionMapper userRolePermissionMapper;
|
||||||
|
@Resource
|
||||||
|
private ProjectExtendMapper projectExtendMapper;
|
||||||
private final ProjectServiceInvoker serviceInvoker;
|
private final ProjectServiceInvoker serviceInvoker;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -60,18 +64,27 @@ public class CommonProjectService {
|
||||||
this.serviceInvoker = serviceInvoker;
|
this.serviceInvoker = serviceInvoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project get(String id) {
|
public ProjectExtendDTO get(String id) {
|
||||||
return projectMapper.selectByPrimaryKey(id);
|
Project project = projectMapper.selectByPrimaryKey(id);
|
||||||
|
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||||
|
if (ObjectUtils.isNotEmpty(project)) {
|
||||||
|
BeanUtils.copyBean(projectExtendDTO, project);
|
||||||
|
ProjectExtend projectExtend = projectExtendMapper.selectByPrimaryKey(id);
|
||||||
|
if (ObjectUtils.isNotEmpty(projectExtend)) {
|
||||||
|
projectExtendDTO.setModuleSetting(JSON.parseObject(projectExtend.getModuleSetting(), ModuleSettingDTO.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return projectExtendDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
||||||
* @param createUser
|
* @param createUser
|
||||||
* @param path 请求路径
|
* @param path 请求路径
|
||||||
* @param module 日志记录模块
|
* @param module 日志记录模块
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Project add(AddProjectRequest addProjectDTO, String createUser, String path, String module) {
|
public ProjectExtendDTO add(AddProjectRequest addProjectDTO, String createUser, String path, String module) {
|
||||||
|
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
project.setId(UUID.randomUUID().toString());
|
project.setId(UUID.randomUUID().toString());
|
||||||
|
@ -85,7 +98,21 @@ public class CommonProjectService {
|
||||||
project.setEnable(addProjectDTO.getEnable());
|
project.setEnable(addProjectDTO.getEnable());
|
||||||
project.setDescription(addProjectDTO.getDescription());
|
project.setDescription(addProjectDTO.getDescription());
|
||||||
addProjectDTO.setId(project.getId());
|
addProjectDTO.setId(project.getId());
|
||||||
|
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||||
|
BeanUtils.copyBean(projectExtendDTO, project);
|
||||||
projectMapper.insertSelective(project);
|
projectMapper.insertSelective(project);
|
||||||
|
|
||||||
|
//判断是否有模块设置
|
||||||
|
ProjectExtend projectExtend = new ProjectExtend();
|
||||||
|
projectExtend.setId(project.getId());
|
||||||
|
projectExtend.setPlatform("LOCAL");
|
||||||
|
if (ObjectUtils.isEmpty(addProjectDTO.getModuleSetting())) {
|
||||||
|
addProjectDTO.setModuleSetting(new ModuleSettingDTO());
|
||||||
|
}
|
||||||
|
projectExtend.setModuleSetting(JSON.toJSONString(addProjectDTO.getModuleSetting()));
|
||||||
|
projectExtendMapper.insert(projectExtend);
|
||||||
|
projectExtendDTO.setModuleSetting(addProjectDTO.getModuleSetting());
|
||||||
|
|
||||||
ProjectAddMemberBatchRequest memberRequest = new ProjectAddMemberBatchRequest();
|
ProjectAddMemberBatchRequest memberRequest = new ProjectAddMemberBatchRequest();
|
||||||
memberRequest.setProjectIds(List.of(project.getId()));
|
memberRequest.setProjectIds(List.of(project.getId()));
|
||||||
if (CollectionUtils.isEmpty(addProjectDTO.getUserIds())) {
|
if (CollectionUtils.isEmpty(addProjectDTO.getUserIds())) {
|
||||||
|
@ -95,30 +122,42 @@ public class CommonProjectService {
|
||||||
}
|
}
|
||||||
//添加项目管理员 创建的时候如果没有传管理员id 则默认创建者为管理员
|
//添加项目管理员 创建的时候如果没有传管理员id 则默认创建者为管理员
|
||||||
this.addProjectAdmin(memberRequest, createUser, path,
|
this.addProjectAdmin(memberRequest, createUser, path,
|
||||||
OperationLogType.ADD.name(), HttpMethodConstants.POST.name(), Translator.get("add"), module);
|
OperationLogType.ADD.name(), Translator.get("add"), module);
|
||||||
return project;
|
return projectExtendDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查添加的人员是否存在组织中
|
* 检查添加的人员是否存在组织中 判断传过来的用户id是否在组织下,如果不存在,给用户创建一个组织成员的身份
|
||||||
*
|
*
|
||||||
* @param
|
* @param
|
||||||
*/
|
*/
|
||||||
public void checkOrgRoleExit(String userId, String orgId, String createUser, String userName, String path, String module) {
|
public void checkOrgRoleExit(List<String> userId, String orgId, String createUser, Map<String, String> nameMap, String path, String module) {
|
||||||
List<LogDTO> logDTOList = new ArrayList<>();
|
List<LogDTO> logDTOList = new ArrayList<>();
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(orgId);
|
userRoleRelationExample.createCriteria().andUserIdIn(userId).andSourceIdEqualTo(orgId);
|
||||||
if (userRoleRelationMapper.selectByExample(userRoleRelationExample).size() == 0) {
|
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
UserRoleRelation memberRole = new UserRoleRelation();
|
//把用户id放到一个新的list
|
||||||
memberRole.setId(UUID.randomUUID().toString());
|
List<String> orgUserIds = userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList());
|
||||||
memberRole.setUserId(userId);
|
if (CollectionUtils.isNotEmpty(userId)) {
|
||||||
memberRole.setRoleId(InternalUserRole.ORG_MEMBER.getValue());
|
List<UserRoleRelation> userRoleRelation = new ArrayList<>();
|
||||||
memberRole.setSourceId(orgId);
|
userId.forEach(id -> {
|
||||||
memberRole.setCreateTime(System.currentTimeMillis());
|
if (!orgUserIds.contains(id)) {
|
||||||
memberRole.setCreateUser(createUser);
|
UserRoleRelation memberRole = new UserRoleRelation();
|
||||||
userRoleRelationMapper.insert(memberRole);
|
memberRole.setId(UUID.randomUUID().toString());
|
||||||
LogDTO logDTO = new LogDTO(orgId, orgId,memberRole.getId(), createUser, OperationLogType.ADD.name(), module,Translator.get("add") + Translator.get("organization_member") + ": " + userName);
|
memberRole.setUserId(id);
|
||||||
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
memberRole.setRoleId(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
|
memberRole.setSourceId(orgId);
|
||||||
|
memberRole.setCreateTime(System.currentTimeMillis());
|
||||||
|
memberRole.setCreateUser(createUser);
|
||||||
|
userRoleRelation.add(memberRole);
|
||||||
|
LogDTO logDTO = new LogDTO(orgId, orgId, memberRole.getId(), createUser, OperationLogType.ADD.name(), module, Translator.get("add") + Translator.get("organization_member") + ": " + nameMap.get(id));
|
||||||
|
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (CollectionUtils.isNotEmpty(userRoleRelation)) {
|
||||||
|
userRoleRelationMapper.batchInsert(userRoleRelation);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
operationLogService.batchAdd(logDTOList);
|
operationLogService.batchAdd(logDTOList);
|
||||||
}
|
}
|
||||||
|
@ -150,8 +189,9 @@ public class CommonProjectService {
|
||||||
return projectList;
|
return projectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project update(UpdateProjectRequest updateProjectDto, String updateUser, String path, String module) {
|
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser, String path, String module) {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
|
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||||
project.setId(updateProjectDto.getId());
|
project.setId(updateProjectDto.getId());
|
||||||
project.setName(updateProjectDto.getName());
|
project.setName(updateProjectDto.getName());
|
||||||
project.setDescription(updateProjectDto.getDescription());
|
project.setDescription(updateProjectDto.getDescription());
|
||||||
|
@ -163,6 +203,7 @@ public class CommonProjectService {
|
||||||
project.setUpdateTime(System.currentTimeMillis());
|
project.setUpdateTime(System.currentTimeMillis());
|
||||||
checkProjectExistByName(project);
|
checkProjectExistByName(project);
|
||||||
checkProjectNotExist(project.getId());
|
checkProjectNotExist(project.getId());
|
||||||
|
BeanUtils.copyBean(projectExtendDTO, project);
|
||||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||||
example.createCriteria().andSourceIdEqualTo(project.getId()).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
example.createCriteria().andSourceIdEqualTo(project.getId()).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(example);
|
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(example);
|
||||||
|
@ -182,7 +223,7 @@ public class CommonProjectService {
|
||||||
deleteExample.createCriteria().andSourceIdEqualTo(project.getId()).andUserIdIn(deleteIds).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
deleteExample.createCriteria().andSourceIdEqualTo(project.getId()).andUserIdIn(deleteIds).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
userRoleRelationMapper.selectByExample(deleteExample).forEach(userRoleRelation -> {
|
userRoleRelationMapper.selectByExample(deleteExample).forEach(userRoleRelation -> {
|
||||||
User user = userMapper.selectByPrimaryKey(userRoleRelation.getUserId());
|
User user = userMapper.selectByPrimaryKey(userRoleRelation.getUserId());
|
||||||
LogDTO logDTO = new LogDTO(project.getId(), project.getOrganizationId(),userRoleRelation.getId(), updateUser, OperationLogType.DELETE.name(), module,Translator.get("delete") + Translator.get("project_admin") + ": " + user.getName());
|
LogDTO logDTO = new LogDTO(project.getId(), project.getOrganizationId(), userRoleRelation.getId(), updateUser, OperationLogType.DELETE.name(), module, Translator.get("delete") + Translator.get("project_admin") + ": " + user.getName());
|
||||||
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
||||||
});
|
});
|
||||||
userRoleRelationMapper.deleteByExample(deleteExample);
|
userRoleRelationMapper.deleteByExample(deleteExample);
|
||||||
|
@ -191,8 +232,8 @@ public class CommonProjectService {
|
||||||
ProjectAddMemberBatchRequest memberRequest = new ProjectAddMemberBatchRequest();
|
ProjectAddMemberBatchRequest memberRequest = new ProjectAddMemberBatchRequest();
|
||||||
memberRequest.setProjectIds(List.of(project.getId()));
|
memberRequest.setProjectIds(List.of(project.getId()));
|
||||||
memberRequest.setUserIds(insertIds);
|
memberRequest.setUserIds(insertIds);
|
||||||
this.addProjectAdmin(memberRequest, updateUser, path, OperationLogType.UPDATE.name(),
|
this.addProjectAdmin(memberRequest, updateUser, path, OperationLogType.ADD.name(),
|
||||||
HttpMethodConstants.POST.name(), Translator.get("update"), module);
|
Translator.get("update"), module);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (CollectionUtils.isNotEmpty(orgUserIds)) {
|
if (CollectionUtils.isNotEmpty(orgUserIds)) {
|
||||||
|
@ -201,8 +242,8 @@ public class CommonProjectService {
|
||||||
deleteExample.createCriteria().andSourceIdEqualTo(project.getId()).andUserIdIn(orgUserIds).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
deleteExample.createCriteria().andSourceIdEqualTo(project.getId()).andUserIdIn(orgUserIds).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
userRoleRelationMapper.selectByExample(deleteExample).forEach(userRoleRelation -> {
|
userRoleRelationMapper.selectByExample(deleteExample).forEach(userRoleRelation -> {
|
||||||
User user = userMapper.selectByPrimaryKey(userRoleRelation.getUserId());
|
User user = userMapper.selectByPrimaryKey(userRoleRelation.getUserId());
|
||||||
LogDTO logDTO = new LogDTO(project.getId(), project.getOrganizationId(),userRoleRelation.getId(), updateUser, OperationLogType.DELETE.name(), module,Translator.get("delete") + Translator.get("project_admin") + ": " + user.getName());
|
LogDTO logDTO = new LogDTO(project.getId(), project.getOrganizationId(), userRoleRelation.getId(), updateUser, OperationLogType.DELETE.name(), module, Translator.get("delete") + Translator.get("project_admin") + ": " + user.getName());
|
||||||
setLog(logDTO, path, HttpMethodConstants.POST.name() ,logDTOList);
|
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
||||||
});
|
});
|
||||||
userRoleRelationMapper.deleteByExample(deleteExample);
|
userRoleRelationMapper.deleteByExample(deleteExample);
|
||||||
}
|
}
|
||||||
|
@ -210,9 +251,23 @@ public class CommonProjectService {
|
||||||
if (CollectionUtils.isNotEmpty(logDTOList)) {
|
if (CollectionUtils.isNotEmpty(logDTOList)) {
|
||||||
operationLogService.batchAdd(logDTOList);
|
operationLogService.batchAdd(logDTOList);
|
||||||
}
|
}
|
||||||
|
//判断是否有模块设置
|
||||||
|
ProjectExtend projectExtend = new ProjectExtend();
|
||||||
|
projectExtend.setId(project.getId());
|
||||||
|
if (ObjectUtils.isEmpty(updateProjectDto.getModuleSetting())) {
|
||||||
|
updateProjectDto.setModuleSetting(new ModuleSettingDTO());
|
||||||
|
}
|
||||||
|
projectExtend.setModuleSetting(JSON.toJSONString(updateProjectDto.getModuleSetting()));
|
||||||
|
if (projectExtendMapper.selectByPrimaryKey(project.getId()) == null) {
|
||||||
|
projectExtend.setPlatform("LOCAL");
|
||||||
|
projectExtendMapper.insert(projectExtend);
|
||||||
|
} else {
|
||||||
|
projectExtendMapper.updateByPrimaryKeySelective(projectExtend);
|
||||||
|
}
|
||||||
|
projectExtendDTO.setModuleSetting(updateProjectDto.getModuleSetting());
|
||||||
|
|
||||||
projectMapper.updateByPrimaryKeySelective(project);
|
projectMapper.updateByPrimaryKeySelective(project);
|
||||||
return project;
|
return projectExtendDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int delete(String id, String deleteUser) {
|
public int delete(String id, String deleteUser) {
|
||||||
|
@ -228,32 +283,26 @@ public class CommonProjectService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加项目管理员
|
* 添加项目管理员
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param createUser 创建人
|
* @param createUser 创建人
|
||||||
* @param path 请求路径
|
* @param path 请求路径
|
||||||
* @param type 操作类型
|
* @param type 操作类型
|
||||||
* @param method 请求方法
|
* @param content 操作内容
|
||||||
* @param content 操作内容
|
* @param module 日志记录模块
|
||||||
* @param module 日志记录模块
|
|
||||||
*/
|
*/
|
||||||
public void addProjectAdmin(ProjectAddMemberBatchRequest request, String createUser, String path, String type,
|
public void addProjectAdmin(ProjectAddMemberBatchRequest request, String createUser, String path, String type,
|
||||||
String method, String content, String module) {
|
String content, String module) {
|
||||||
|
|
||||||
List<LogDTO> logDTOList = new ArrayList<>();
|
List<LogDTO> logDTOList = new ArrayList<>();
|
||||||
List<UserRoleRelation> userRoleRelations = new ArrayList<>();
|
List<UserRoleRelation> userRoleRelations = new ArrayList<>();
|
||||||
request.getProjectIds().forEach(projectId -> {
|
request.getProjectIds().forEach(projectId -> {
|
||||||
checkProjectNotExist(projectId);
|
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||||
//判断传过来的用户id是否在组织下,如果不存在,给用户创建一个组织成员的身份
|
Map<String, String> nameMap = addUserPre(request, createUser, path, module, projectId, project);
|
||||||
request.getUserIds().forEach(userId -> {
|
request.getUserIds().forEach(userId -> {
|
||||||
User user = userMapper.selectByPrimaryKey(userId);
|
|
||||||
if (ObjectUtils.isEmpty(user)) {
|
|
||||||
throw new MSException(Translator.get("user_not_exist"));
|
|
||||||
}
|
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
|
||||||
this.checkOrgRoleExit(userId, project.getOrganizationId(), createUser, user.getName(), path, module);
|
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId)
|
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId)
|
||||||
.andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_MEMBER.getValue());
|
.andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
if (userRoleRelationMapper.selectByExample(userRoleRelationExample).size() == 0) {
|
if (userRoleRelationMapper.selectByExample(userRoleRelationExample).size() == 0) {
|
||||||
UserRoleRelation adminRole = new UserRoleRelation();
|
UserRoleRelation adminRole = new UserRoleRelation();
|
||||||
adminRole.setId(UUID.randomUUID().toString());
|
adminRole.setId(UUID.randomUUID().toString());
|
||||||
|
@ -263,39 +312,49 @@ public class CommonProjectService {
|
||||||
adminRole.setCreateTime(System.currentTimeMillis());
|
adminRole.setCreateTime(System.currentTimeMillis());
|
||||||
adminRole.setCreateUser(createUser);
|
adminRole.setCreateUser(createUser);
|
||||||
userRoleRelations.add(adminRole);
|
userRoleRelations.add(adminRole);
|
||||||
LogDTO logDTO = new LogDTO(projectId, project.getOrganizationId(), adminRole.getId(), createUser, type, module, content + Translator.get("project_admin") + ": " + user.getName());
|
LogDTO logDTO = new LogDTO(projectId, project.getOrganizationId(), adminRole.getId(), createUser, type, module, content + Translator.get("project_admin") + ": " + nameMap.get(userId));
|
||||||
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
userRoleRelationMapper.batchInsert(userRoleRelations);
|
if (CollectionUtils.isNotEmpty(userRoleRelations)) {
|
||||||
|
userRoleRelationMapper.batchInsert(userRoleRelations);
|
||||||
|
}
|
||||||
operationLogService.batchAdd(logDTOList);
|
operationLogService.batchAdd(logDTOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, String> addUserPre(ProjectAddMemberBatchRequest request, String createUser, String path, String module, String projectId, Project project) {
|
||||||
|
checkProjectNotExist(projectId);
|
||||||
|
UserExample userExample = new UserExample();
|
||||||
|
userExample.createCriteria().andIdIn(request.getUserIds());
|
||||||
|
List<User> users = userMapper.selectByExample(userExample);
|
||||||
|
if (request.getUserIds().size() != users.size()) {
|
||||||
|
throw new MSException(Translator.get("user_not_exist"));
|
||||||
|
}
|
||||||
|
//把id和名称放一个map中
|
||||||
|
Map<String, String> userMap = users.stream().collect(Collectors.toMap(User::getId, User::getName));
|
||||||
|
this.checkOrgRoleExit(request.getUserIds(), project.getOrganizationId(), createUser, userMap, path, module);
|
||||||
|
return userMap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加项目成员
|
* 添加项目成员
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param createUser 创建人
|
* @param createUser 创建人
|
||||||
* @param path 请求路径
|
* @param path 请求路径
|
||||||
* @param type 操作类型
|
* @param type 操作类型
|
||||||
* @param method 请求方法
|
* @param content 操作内容
|
||||||
* @param content 操作内容
|
* @param module 日志记录模块
|
||||||
* @param module 日志记录模块
|
|
||||||
*/
|
*/
|
||||||
public void addProjectMember(ProjectAddMemberBatchRequest request, String createUser, String path, String type,
|
public void addProjectMember(ProjectAddMemberBatchRequest request, String createUser, String path, String type, String content, String module) {
|
||||||
String method, String content, String module) {
|
|
||||||
|
|
||||||
List<LogDTO> logDTOList = new ArrayList<>();
|
List<LogDTO> logDTOList = new ArrayList<>();
|
||||||
List<UserRoleRelation> userRoleRelations = new ArrayList<>();
|
List<UserRoleRelation> userRoleRelations = new ArrayList<>();
|
||||||
request.getProjectIds().forEach(projectId -> {
|
request.getProjectIds().forEach(projectId -> {
|
||||||
checkProjectNotExist(projectId);
|
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||||
|
Map<String, String> userMap = addUserPre(request, createUser, path, module, projectId, project);
|
||||||
request.getUserIds().forEach(userId -> {
|
request.getUserIds().forEach(userId -> {
|
||||||
User user = userMapper.selectByPrimaryKey(userId);
|
|
||||||
if (ObjectUtils.isEmpty(user)) {
|
|
||||||
throw new MSException(Translator.get("user_not_exist"));
|
|
||||||
}
|
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
|
||||||
this.checkOrgRoleExit(userId, project.getOrganizationId(), createUser, user.getName(), path, module);
|
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId)
|
userRoleRelationExample.createCriteria().andUserIdEqualTo(userId)
|
||||||
.andSourceIdEqualTo(projectId);
|
.andSourceIdEqualTo(projectId);
|
||||||
|
@ -308,16 +367,18 @@ public class CommonProjectService {
|
||||||
memberRole.setCreateTime(System.currentTimeMillis());
|
memberRole.setCreateTime(System.currentTimeMillis());
|
||||||
memberRole.setCreateUser(createUser);
|
memberRole.setCreateUser(createUser);
|
||||||
userRoleRelations.add(memberRole);
|
userRoleRelations.add(memberRole);
|
||||||
LogDTO logDTO = new LogDTO(projectId, project.getOrganizationId(),memberRole.getId(), createUser, type, module, content + Translator.get("project_member") + ": " + user.getName());
|
LogDTO logDTO = new LogDTO(projectId, project.getOrganizationId(), memberRole.getId(), createUser, type, module, content + Translator.get("project_member") + ": " + userMap.get(userId));
|
||||||
setLog(logDTO , path, HttpMethodConstants.POST.name(), logDTOList);
|
setLog(logDTO, path, HttpMethodConstants.POST.name(), logDTOList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
userRoleRelationMapper.batchInsert(userRoleRelations);
|
if (CollectionUtils.isNotEmpty(userRoleRelations)) {
|
||||||
|
userRoleRelationMapper.batchInsert(userRoleRelations);
|
||||||
|
}
|
||||||
operationLogService.batchAdd(logDTOList);
|
operationLogService.batchAdd(logDTOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int removeProjectMember(String projectId, String userId,String createUser, String module, String path) {
|
public int removeProjectMember(String projectId, String userId, String createUser, String module, String path) {
|
||||||
checkProjectNotExist(projectId);
|
checkProjectNotExist(projectId);
|
||||||
User user = userMapper.selectByPrimaryKey(userId);
|
User user = userMapper.selectByPrimaryKey(userId);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -332,8 +393,8 @@ public class CommonProjectService {
|
||||||
}
|
}
|
||||||
List<LogDTO> logDTOList = new ArrayList<>();
|
List<LogDTO> logDTOList = new ArrayList<>();
|
||||||
userRoleRelationMapper.selectByExample(userRoleRelationExample).forEach(userRoleRelation -> {
|
userRoleRelationMapper.selectByExample(userRoleRelationExample).forEach(userRoleRelation -> {
|
||||||
LogDTO logDTO = new LogDTO(projectId, projectMapper.selectByPrimaryKey(projectId).getOrganizationId(),userRoleRelation.getId(), createUser, OperationLogType.DELETE.name(), module,Translator.get("delete") + Translator.get("project_member") + ": " + user.getName());
|
LogDTO logDTO = new LogDTO(projectId, projectMapper.selectByPrimaryKey(projectId).getOrganizationId(), userRoleRelation.getId(), createUser, OperationLogType.DELETE.name(), module, Translator.get("delete") + Translator.get("project_member") + ": " + user.getName());
|
||||||
setLog(logDTO,path,HttpMethodConstants.GET.name(), logDTOList);
|
setLog(logDTO, path, HttpMethodConstants.GET.name(), logDTOList);
|
||||||
});
|
});
|
||||||
operationLogService.batchAdd(logDTOList);
|
operationLogService.batchAdd(logDTOList);
|
||||||
return userRoleRelationMapper.deleteByExample(userRoleRelationExample);
|
return userRoleRelationMapper.deleteByExample(userRoleRelationExample);
|
||||||
|
@ -351,6 +412,7 @@ public class CommonProjectService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除项目 一般是定时任务会触发
|
* 删除项目 一般是定时任务会触发
|
||||||
|
*
|
||||||
* @param projects
|
* @param projects
|
||||||
*/
|
*/
|
||||||
public void deleteProject(List<Project> projects) {
|
public void deleteProject(List<Project> projects) {
|
||||||
|
@ -363,14 +425,15 @@ public class CommonProjectService {
|
||||||
deleteProjectUserGroup(project.getId());
|
deleteProjectUserGroup(project.getId());
|
||||||
// delete project
|
// delete project
|
||||||
projectMapper.deleteByPrimaryKey(project.getId());
|
projectMapper.deleteByPrimaryKey(project.getId());
|
||||||
LogDTO logDTO = new LogDTO(OperationLogConstants.SYSTEM, project.getOrganizationId(),project.getId(), StringUtils.EMPTY, OperationLogType.DELETE.name(), OperationLogModule.SYSTEM_PROJECT,Translator.get("delete") + Translator.get("project") + ": " + project.getName());
|
LogDTO logDTO = new LogDTO(OperationLogConstants.SYSTEM, project.getOrganizationId(), project.getId(), StringUtils.EMPTY, OperationLogType.DELETE.name(), OperationLogModule.SYSTEM_PROJECT, Translator.get("delete") + Translator.get("project") + ": " + project.getName());
|
||||||
setLog(logDTO, StringUtils.EMPTY,StringUtils.EMPTY, logDTOList);
|
setLog(logDTO, StringUtils.EMPTY, StringUtils.EMPTY, logDTOList);
|
||||||
});
|
});
|
||||||
operationLogService.batchAdd(logDTOList);
|
operationLogService.batchAdd(logDTOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除自定义用户组和权限关系表、项目和用户关系数据
|
* 删除自定义用户组和权限关系表、项目和用户关系数据
|
||||||
|
*
|
||||||
* @param projectId
|
* @param projectId
|
||||||
*/
|
*/
|
||||||
private void deleteProjectUserGroup(String projectId) {
|
private void deleteProjectUserGroup(String projectId) {
|
||||||
|
@ -390,9 +453,8 @@ public class CommonProjectService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param path 请求路径
|
||||||
* @param path 请求路径
|
* @param method 请求方法
|
||||||
* @param method 请求方法
|
|
||||||
* @param logDTOList 日志集合
|
* @param logDTOList 日志集合
|
||||||
*/
|
*/
|
||||||
private void setLog(LogDTO dto, String path, String method, List<LogDTO> logDTOList) {
|
private void setLog(LogDTO dto, String path, String method, List<LogDTO> logDTOList) {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package io.metersphere.system.service;
|
package io.metersphere.system.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.Project;
|
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||||
|
@ -10,6 +8,7 @@ import io.metersphere.sdk.log.constants.OperationLogModule;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
||||||
import io.metersphere.system.request.OrganizationProjectRequest;
|
import io.metersphere.system.request.OrganizationProjectRequest;
|
||||||
|
@ -41,16 +40,16 @@ public class OrganizationProjectService {
|
||||||
private final static String REMOVE_PROJECT_MEMBER = PREFIX + "/remove-member/";
|
private final static String REMOVE_PROJECT_MEMBER = PREFIX + "/remove-member/";
|
||||||
private final static String ADD_MEMBER = PREFIX + "/add-member";
|
private final static String ADD_MEMBER = PREFIX + "/add-member";
|
||||||
|
|
||||||
public Project get(String id) {
|
public ProjectExtendDTO get(String id) {
|
||||||
return projectMapper.selectByPrimaryKey(id);
|
return commonProjectService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Project add(AddProjectRequest addProjectDTO, String createUser) {
|
public ProjectExtendDTO add(AddProjectRequest addProjectDTO, String createUser) {
|
||||||
Project project = commonProjectService.add(addProjectDTO, createUser, ADD_PROJECT, OperationLogModule.SYSTEM_PROJECT);
|
ProjectExtendDTO project = commonProjectService.add(addProjectDTO, createUser, ADD_PROJECT, OperationLogModule.ORGANIZATION_PROJECT);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +60,8 @@ public class OrganizationProjectService {
|
||||||
return commonProjectService.buildUserInfo(projectList);
|
return commonProjectService.buildUserInfo(projectList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||||
Project project = commonProjectService.update(updateProjectDto, updateUser, UPDATE_PROJECT, OperationLogModule.SYSTEM_PROJECT);
|
ProjectExtendDTO project = commonProjectService.update(updateProjectDto, updateUser, UPDATE_PROJECT, OperationLogModule.ORGANIZATION_PROJECT);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +82,11 @@ public class OrganizationProjectService {
|
||||||
*/
|
*/
|
||||||
public void addProjectMember(ProjectAddMemberBatchRequest request, String createUser) {
|
public void addProjectMember(ProjectAddMemberBatchRequest request, String createUser) {
|
||||||
commonProjectService.addProjectMember(request, createUser, ADD_MEMBER,
|
commonProjectService.addProjectMember(request, createUser, ADD_MEMBER,
|
||||||
OperationLogType.ADD.name(), HttpMethodConstants.POST.name(), Translator.get("add"), OperationLogModule.SYSTEM_PROJECT);
|
OperationLogType.ADD.name(), Translator.get("add"), OperationLogModule.ORGANIZATION_PROJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int removeProjectMember(String projectId, String userId, String createUser) {
|
public int removeProjectMember(String projectId, String userId, String createUser) {
|
||||||
return commonProjectService.removeProjectMember(projectId, userId, createUser,OperationLogModule.SYSTEM_PROJECT, StringUtils.join(REMOVE_PROJECT_MEMBER,projectId, "/", userId));
|
return commonProjectService.removeProjectMember(projectId, userId, createUser,OperationLogModule.ORGANIZATION_PROJECT, StringUtils.join(REMOVE_PROJECT_MEMBER,projectId, "/", userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int revoke(String id) {
|
public int revoke(String id) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package io.metersphere.system.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.Project;
|
import io.metersphere.project.domain.Project;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||||
|
@ -10,6 +9,7 @@ import io.metersphere.sdk.log.constants.OperationLogModule;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
||||||
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
|
||||||
|
@ -39,16 +39,16 @@ public class SystemProjectService {
|
||||||
private final static String REMOVE_PROJECT_MEMBER = PREFIX + "/remove-member/";
|
private final static String REMOVE_PROJECT_MEMBER = PREFIX + "/remove-member/";
|
||||||
private final static String ADD_MEMBER = PREFIX + "/add-member";
|
private final static String ADD_MEMBER = PREFIX + "/add-member";
|
||||||
|
|
||||||
public Project get(String id) {
|
public ProjectExtendDTO get(String id) {
|
||||||
return projectMapper.selectByPrimaryKey(id);
|
return commonProjectService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
* @param addProjectDTO 添加项目的时候 默认给用户组添加管理员的权限
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Project add(AddProjectRequest addProjectDTO, String createUser) {
|
public ProjectExtendDTO add(AddProjectRequest addProjectDTO, String createUser) {
|
||||||
Project project = commonProjectService.add(addProjectDTO, createUser, ADD_PROJECT, OperationLogModule.SYSTEM_PROJECT);
|
ProjectExtendDTO project = commonProjectService.add(addProjectDTO, createUser, ADD_PROJECT, OperationLogModule.SYSTEM_PROJECT);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ public class SystemProjectService {
|
||||||
return commonProjectService.buildUserInfo(projectList);
|
return commonProjectService.buildUserInfo(projectList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||||
Project project = commonProjectService.update(updateProjectDto, updateUser, UPDATE_PROJECT, OperationLogModule.SYSTEM_PROJECT);
|
ProjectExtendDTO project = commonProjectService.update(updateProjectDto, updateUser, UPDATE_PROJECT, OperationLogModule.SYSTEM_PROJECT);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class SystemProjectService {
|
||||||
*/
|
*/
|
||||||
public void addProjectMember(ProjectAddMemberBatchRequest request, String createUser) {
|
public void addProjectMember(ProjectAddMemberBatchRequest request, String createUser) {
|
||||||
commonProjectService.addProjectMember(request, createUser, ADD_MEMBER,
|
commonProjectService.addProjectMember(request, createUser, ADD_MEMBER,
|
||||||
OperationLogType.ADD.name(), HttpMethodConstants.POST.name(), Translator.get("add"), OperationLogModule.SYSTEM_PROJECT);
|
OperationLogType.ADD.name(), Translator.get("add"), OperationLogModule.SYSTEM_PROJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int removeProjectMember(String projectId, String userId, String createUser) {
|
public int removeProjectMember(String projectId, String userId, String createUser) {
|
||||||
|
|
|
@ -22,6 +22,14 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER"
|
"id": "SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "SYSTEM_ORGANIZATION_PROJECT_MEMBER:ADD",
|
||||||
|
"name": "permission.system_organization_project_member.add"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "SYSTEM_ORGANIZATION_PROJECT_MEMBER:DELETE",
|
||||||
|
"name": "permission.system_organization_project_member.delete"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -208,6 +216,14 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "ORGANIZATION_PROJECT:READ+RECOVER"
|
"id": "ORGANIZATION_PROJECT:READ+RECOVER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ORGANIZATION_PROJECT_MEMBER:ADD",
|
||||||
|
"name": "permission.system_organization_project_member.add"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ORGANIZATION_PROJECT_MEMBER:DELETE",
|
||||||
|
"name": "permission.system_organization_project_member.delete"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ package io.metersphere.system.controller;
|
||||||
|
|
||||||
import io.metersphere.project.domain.Project;
|
import io.metersphere.project.domain.Project;
|
||||||
import io.metersphere.project.domain.ProjectExample;
|
import io.metersphere.project.domain.ProjectExample;
|
||||||
|
import io.metersphere.project.domain.ProjectExtend;
|
||||||
|
import io.metersphere.project.mapper.ProjectExtendMapper;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.base.BaseTest;
|
import io.metersphere.sdk.base.BaseTest;
|
||||||
import io.metersphere.sdk.constants.InternalUserRole;
|
import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
|
@ -9,6 +11,7 @@ import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.controller.handler.ResultHolder;
|
import io.metersphere.sdk.controller.handler.ResultHolder;
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
|
import io.metersphere.sdk.dto.ModuleSettingDTO;
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
|
@ -17,6 +20,7 @@ import io.metersphere.sdk.util.Pager;
|
||||||
import io.metersphere.system.domain.UserRoleRelation;
|
import io.metersphere.system.domain.UserRoleRelation;
|
||||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||||
import io.metersphere.system.dto.OrganizationDTO;
|
import io.metersphere.system.dto.OrganizationDTO;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||||
import io.metersphere.system.request.OrganizationProjectRequest;
|
import io.metersphere.system.request.OrganizationProjectRequest;
|
||||||
|
@ -75,6 +79,8 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
private UserRoleRelationMapper userRoleRelationMapper;
|
private UserRoleRelationMapper userRoleRelationMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private OrganizationService organizationService;
|
private OrganizationService organizationService;
|
||||||
|
@Resource
|
||||||
|
private ProjectExtendMapper projectExtendMapper;
|
||||||
|
|
||||||
private OrganizationDTO getDefault() {
|
private OrganizationDTO getDefault() {
|
||||||
return organizationService.getDefault();
|
return organizationService.getDefault();
|
||||||
|
@ -179,7 +185,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
public void testAddProjectSuccess() throws Exception {
|
public void testAddProjectSuccess() throws Exception {
|
||||||
AddProjectRequest project = this.generatorAdd("organizationId","organization-name", "description", true, List.of("admin"));
|
AddProjectRequest project = this.generatorAdd("organizationId","organization-name", "description", true, List.of("admin"));
|
||||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||||
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
ProjectExample projectExample = new ProjectExample();
|
ProjectExample projectExample = new ProjectExample();
|
||||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||||
|
@ -196,13 +202,15 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
projectId = result.getId();
|
projectId = result.getId();
|
||||||
|
ProjectExtend projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(new ModuleSettingDTO()));
|
||||||
// 校验日志
|
// 校验日志
|
||||||
checkLog(projectId, OperationLogType.ADD);
|
checkLog(projectId, OperationLogType.ADD);
|
||||||
|
|
||||||
//userId为空的时候
|
//userId为空的时候
|
||||||
project = this.generatorAdd("organizationId","organization-userIdIsNull", "description", true, new ArrayList<>());
|
project = this.generatorAdd("organizationId","organization-userIdIsNull", "description", true, new ArrayList<>());
|
||||||
mvcResult = this.responsePost(addProject, project);
|
mvcResult = this.responsePost(addProject, project);
|
||||||
result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
projectExample = new ProjectExample();
|
projectExample = new ProjectExample();
|
||||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||||
projects = projectMapper.selectByExample(projectExample);
|
projects = projectMapper.selectByExample(projectExample);
|
||||||
|
@ -218,6 +226,34 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(new ModuleSettingDTO()));
|
||||||
|
|
||||||
|
//设置了模块模版
|
||||||
|
ModuleSettingDTO moduleSettingDTO = new ModuleSettingDTO();
|
||||||
|
moduleSettingDTO.setApiTest(true);
|
||||||
|
moduleSettingDTO.setLoadTest(true);
|
||||||
|
project.setModuleSetting(moduleSettingDTO);
|
||||||
|
project.setName("org-moduleSetting");
|
||||||
|
mvcResult = this.responsePost(addProject, project);
|
||||||
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
|
projectExample = new ProjectExample();
|
||||||
|
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||||
|
projects = projectMapper.selectByExample(projectExample);
|
||||||
|
projectId = result.getId();
|
||||||
|
// 校验日志
|
||||||
|
checkLog(projectId, OperationLogType.ADD);
|
||||||
|
|
||||||
|
this.compareProjectDTO(projects.get(0), result);
|
||||||
|
userRoleRelationExample = new UserRoleRelationExample();
|
||||||
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleSettingDTO));
|
||||||
|
|
||||||
project.setName("organization-testAddProjectSuccess1");
|
project.setName("organization-testAddProjectSuccess1");
|
||||||
project.setOrganizationId(getDefault().getId());
|
project.setOrganizationId(getDefault().getId());
|
||||||
|
@ -252,11 +288,16 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
public void testGetProject() throws Exception {
|
public void testGetProject() throws Exception {
|
||||||
AddProjectRequest project = this.generatorAdd("organizationId","organization-getName", "description", true, List.of("admin"));
|
AddProjectRequest project = this.generatorAdd("organizationId","organization-getName", "description", true, List.of("admin"));
|
||||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||||
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
projectId = result.getId();
|
projectId = result.getId();
|
||||||
mvcResult = this.responseGet(getProject + projectId);
|
mvcResult = this.responseGet(getProject + projectId);
|
||||||
Project getProjects = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO getProjects = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
|
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
|
||||||
|
|
||||||
|
|
||||||
|
mvcResult = this.responseGet(getProject + "projectId1");
|
||||||
|
getProjects = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
|
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), "projectId1"));
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getProject + projectId);
|
requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getProject + projectId);
|
||||||
}
|
}
|
||||||
|
@ -265,9 +306,8 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
public void testGetProjectError() throws Exception {
|
public void testGetProjectError() throws Exception {
|
||||||
//项目不存在
|
//项目不存在
|
||||||
MvcResult mvcResult = this.responseGet(getProject + "111111");
|
MvcResult mvcResult = this.responseGet(getProject + "111111");
|
||||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
ProjectExtend project = this.parseObjectFromMvcResult(mvcResult, ProjectExtend.class);
|
||||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
Assertions.assertEquals(project, new ProjectExtend());
|
||||||
Assertions.assertNull(resultHolder.getData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -348,34 +388,69 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
@Order(7)
|
@Order(7)
|
||||||
public void testUpdateProject() throws Exception {
|
public void testUpdateProject() throws Exception {
|
||||||
UpdateProjectRequest project = this.generatorUpdate("organizationId", projectId,"organization-TestName", "Edit name", true, List.of("admin", "admin1"));
|
UpdateProjectRequest project = this.generatorUpdate("organizationId", projectId,"organization-TestName", "Edit name", true, List.of("admin1"));
|
||||||
|
ProjectExtend projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
ModuleSettingDTO moduleSettingDTO = JSON.parseObject(projectExtend.getModuleSetting(), ModuleSettingDTO.class);
|
||||||
|
moduleSettingDTO.setApiTest(true);
|
||||||
|
moduleSettingDTO.setTestPlan(true);
|
||||||
|
moduleSettingDTO.setUiTest(true);
|
||||||
|
project.setModuleSetting(moduleSettingDTO);
|
||||||
MvcResult mvcResult = this.responsePost(updateProject, project);
|
MvcResult mvcResult = this.responsePost(updateProject, project);
|
||||||
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||||
this.compareProjectDTO(currentProject, result);
|
this.compareProjectDTO(currentProject, result);
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin", "admin1")), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin1")), true);
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin", "admin1")), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of( "admin1")), true);
|
||||||
|
//断言模块设置
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleSettingDTO));
|
||||||
|
|
||||||
// 校验日志
|
// 校验日志
|
||||||
checkLog(projectId, OperationLogType.ADD);
|
checkLog(projectId, OperationLogType.ADD);
|
||||||
//用户id为空
|
//用户id为空
|
||||||
project = this.generatorUpdate("organizationId", projectId, "organization-TestNameUserIdIsNull", "Edit name", true, new ArrayList<>());
|
project = this.generatorUpdate("organizationId", "projectId2", "organization-TestNameUserIdIsNull", "Edit name", true, new ArrayList<>());
|
||||||
mvcResult = this.responsePost(updateProject, project);
|
mvcResult = this.responsePost(updateProject, project);
|
||||||
result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||||
this.compareProjectDTO(currentProject, result);
|
this.compareProjectDTO(currentProject, result);
|
||||||
userRoleRelationExample = new UserRoleRelationExample();
|
userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("projectId2").andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
//断言userRoleRelations是空的
|
//断言userRoleRelations是空的
|
||||||
Assertions.assertTrue(userRoleRelations.isEmpty());
|
Assertions.assertTrue(userRoleRelations.isEmpty());
|
||||||
|
//断言模块设置
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey("projectId2");
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(new ModuleSettingDTO()));
|
||||||
|
|
||||||
|
// 修改模块设置
|
||||||
|
project = this.generatorUpdate("organizationId", "projectId2", "org-Module", "Edit name", true, new ArrayList<>());
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey("projectId2");
|
||||||
|
moduleSettingDTO = JSON.parseObject(projectExtend.getModuleSetting(), ModuleSettingDTO.class);
|
||||||
|
moduleSettingDTO.setApiTest(true);
|
||||||
|
moduleSettingDTO.setTestPlan(true);
|
||||||
|
moduleSettingDTO.setUiTest(true);
|
||||||
|
moduleSettingDTO.setWorkstation(true);
|
||||||
|
project.setModuleSetting(moduleSettingDTO);
|
||||||
|
mvcResult = this.responsePost(updateProject, project);
|
||||||
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
|
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||||
|
this.compareProjectDTO(currentProject, result);
|
||||||
|
userRoleRelationExample = new UserRoleRelationExample();
|
||||||
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("projectId2").andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
|
//断言userRoleRelations是空的
|
||||||
|
Assertions.assertTrue(userRoleRelations.isEmpty());
|
||||||
|
//断言模块设置
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey("projectId2");
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleSettingDTO));
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
project.setName("organization-TestName2");
|
project.setName("organization-TestName2");
|
||||||
|
project.setId("projectId1");
|
||||||
project.setOrganizationId(getDefault().getId());
|
project.setOrganizationId(getDefault().getId());
|
||||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE, updateProject, project);
|
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE, updateProject, project);
|
||||||
// 校验日志
|
// 校验日志
|
||||||
|
@ -456,7 +531,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
projectAddMemberRequest.setUserIds(userIds);
|
projectAddMemberRequest.setUserIds(userIds);
|
||||||
this.requestPost(addProjectMember, projectAddMemberRequest, status().isOk());
|
this.requestPost(addProjectMember, projectAddMemberRequest, status().isOk());
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_MEMBER.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId);
|
||||||
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds), true);
|
||||||
Assertions.assertTrue(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds));
|
Assertions.assertTrue(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds));
|
||||||
|
@ -468,7 +543,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE, addProjectMember, projectAddMemberRequest);
|
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_MEMBER_ADD, addProjectMember, projectAddMemberRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -569,7 +644,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
// 校验日志
|
// 校验日志
|
||||||
checkLog(userRoleRelations.get(0).getId(), OperationLogType.DELETE);
|
checkLog(userRoleRelations.get(0).getId(), OperationLogType.DELETE);
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE, removeProjectMember + projectId + "/" + userId);
|
requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_MEMBER_DELETE, removeProjectMember + projectId + "/" + userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
||||||
|| StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword()));
|
|| StringUtils.contains(userExtend.getPhone(), organizationRequest.getKeyword()));
|
||||||
// 权限校验
|
// 权限校验
|
||||||
organizationMemberRequest.setMemberIds(List.of("admin"));
|
organizationMemberRequest.setMemberIds(List.of("admin"));
|
||||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE, ORGANIZATION_ADD_MEMBER, organizationMemberRequest);
|
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD, ORGANIZATION_ADD_MEMBER, organizationMemberRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -312,7 +312,7 @@ public class SystemOrganizationControllerTests extends BaseTest{
|
||||||
// 日志校验
|
// 日志校验
|
||||||
checkLog("default-organization-3", OperationLogType.DELETE);
|
checkLog("default-organization-3", OperationLogType.DELETE);
|
||||||
// 权限校验
|
// 权限校验
|
||||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE, ORGANIZATION_REMOVE_MEMBER + "/default-organization-3/admin");
|
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_DELETE, ORGANIZATION_REMOVE_MEMBER + "/default-organization-3/admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package io.metersphere.system.controller;
|
package io.metersphere.system.controller;
|
||||||
|
|
||||||
import io.metersphere.sdk.base.BaseTest;
|
|
||||||
import io.metersphere.project.domain.Project;
|
import io.metersphere.project.domain.Project;
|
||||||
import io.metersphere.project.domain.ProjectExample;
|
import io.metersphere.project.domain.ProjectExample;
|
||||||
|
import io.metersphere.project.domain.ProjectExtend;
|
||||||
|
import io.metersphere.project.mapper.ProjectExtendMapper;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
|
import io.metersphere.sdk.base.BaseTest;
|
||||||
import io.metersphere.sdk.constants.InternalUserRole;
|
import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.controller.handler.ResultHolder;
|
import io.metersphere.sdk.controller.handler.ResultHolder;
|
||||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
|
import io.metersphere.sdk.dto.ModuleSettingDTO;
|
||||||
import io.metersphere.sdk.dto.ProjectDTO;
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
|
@ -16,6 +19,7 @@ import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.Pager;
|
import io.metersphere.sdk.util.Pager;
|
||||||
import io.metersphere.system.domain.UserRoleRelation;
|
import io.metersphere.system.domain.UserRoleRelation;
|
||||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||||
|
import io.metersphere.system.dto.ProjectExtendDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||||
import io.metersphere.system.request.ProjectAddMemberRequest;
|
import io.metersphere.system.request.ProjectAddMemberRequest;
|
||||||
|
@ -71,6 +75,8 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserRoleRelationMapper userRoleRelationMapper;
|
private UserRoleRelationMapper userRoleRelationMapper;
|
||||||
|
@Resource
|
||||||
|
private ProjectExtendMapper projectExtendMapper;
|
||||||
|
|
||||||
private void requestPost(String url, Object param, ResultMatcher resultMatcher) throws Exception {
|
private void requestPost(String url, Object param, ResultMatcher resultMatcher) throws Exception {
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post(url)
|
mockMvc.perform(MockMvcRequestBuilders.post(url)
|
||||||
|
@ -171,7 +177,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
public void testAddProjectSuccess() throws Exception {
|
public void testAddProjectSuccess() throws Exception {
|
||||||
AddProjectRequest project = this.generatorAdd("organizationId","name", "description", true, List.of("admin"));
|
AddProjectRequest project = this.generatorAdd("organizationId","name", "description", true, List.of("admin"));
|
||||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||||
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
ProjectExample projectExample = new ProjectExample();
|
ProjectExample projectExample = new ProjectExample();
|
||||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||||
|
@ -187,12 +193,13 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
ProjectExtend projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(new ModuleSettingDTO()));
|
||||||
|
|
||||||
//userId为空的时候
|
//userId为空的时候
|
||||||
project = this.generatorAdd("organizationId","userIdIsNull", "description", true, new ArrayList<>());
|
project = this.generatorAdd("organizationId","userIdIsNull", "description", true, new ArrayList<>());
|
||||||
mvcResult = this.responsePost(addProject, project);
|
mvcResult = this.responsePost(addProject, project);
|
||||||
result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
projectExample = new ProjectExample();
|
projectExample = new ProjectExample();
|
||||||
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||||
projects = projectMapper.selectByExample(projectExample);
|
projects = projectMapper.selectByExample(projectExample);
|
||||||
|
@ -208,6 +215,35 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(new ModuleSettingDTO()));
|
||||||
|
|
||||||
|
//设置了模块模版
|
||||||
|
ModuleSettingDTO moduleSettingDTO = new ModuleSettingDTO();
|
||||||
|
moduleSettingDTO.setApiTest(true);
|
||||||
|
moduleSettingDTO.setLoadTest(true);
|
||||||
|
project.setModuleSetting(moduleSettingDTO);
|
||||||
|
project.setName("moduleSetting");
|
||||||
|
mvcResult = this.responsePost(addProject, project);
|
||||||
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
|
projectExample = new ProjectExample();
|
||||||
|
projectExample.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId()).andNameEqualTo(project.getName());
|
||||||
|
projects = projectMapper.selectByExample(projectExample);
|
||||||
|
projectId = result.getId();
|
||||||
|
// 校验日志
|
||||||
|
checkLog(projectId, OperationLogType.ADD);
|
||||||
|
|
||||||
|
this.compareProjectDTO(projects.get(0), result);
|
||||||
|
userRoleRelationExample = new UserRoleRelationExample();
|
||||||
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo(projectId).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("organizationId").andRoleIdEqualTo(InternalUserRole.ORG_MEMBER.getValue());
|
||||||
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(List.of("admin")), true);
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey(projectId);
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleSettingDTO));
|
||||||
|
|
||||||
|
|
||||||
project.setName("testAddProjectSuccess1");
|
project.setName("testAddProjectSuccess1");
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
|
@ -241,11 +277,16 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
public void testGetProject() throws Exception {
|
public void testGetProject() throws Exception {
|
||||||
AddProjectRequest project = this.generatorAdd("organizationId","getName", "description", true, List.of("admin"));
|
AddProjectRequest project = this.generatorAdd("organizationId","getName", "description", true, List.of("admin"));
|
||||||
MvcResult mvcResult = this.responsePost(addProject, project);
|
MvcResult mvcResult = this.responsePost(addProject, project);
|
||||||
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
projectId = result.getId();
|
projectId = result.getId();
|
||||||
mvcResult = this.responseGet(getProject + projectId);
|
mvcResult = this.responseGet(getProject + projectId);
|
||||||
Project getProjects = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO getProjects = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
|
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), projectId));
|
||||||
|
|
||||||
|
|
||||||
|
mvcResult = this.responseGet(getProject + "projectId1");
|
||||||
|
getProjects = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
|
Assertions.assertTrue(StringUtils.equals(getProjects.getId(), "projectId1"));
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProject + projectId);
|
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProject + projectId);
|
||||||
}
|
}
|
||||||
|
@ -254,9 +295,8 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
public void testGetProjectError() throws Exception {
|
public void testGetProjectError() throws Exception {
|
||||||
//项目不存在
|
//项目不存在
|
||||||
MvcResult mvcResult = this.responseGet(getProject + "111111");
|
MvcResult mvcResult = this.responseGet(getProject + "111111");
|
||||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
ProjectExtend project = this.parseObjectFromMvcResult(mvcResult, ProjectExtend.class);
|
||||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
Assertions.assertEquals(project, new ProjectExtend());
|
||||||
Assertions.assertNull(resultHolder.getData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -329,7 +369,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
public void testUpdateProject() throws Exception {
|
public void testUpdateProject() throws Exception {
|
||||||
UpdateProjectRequest project = this.generatorUpdate("organizationId", "projectId1","TestName", "Edit name", true, List.of("admin", "admin1"));
|
UpdateProjectRequest project = this.generatorUpdate("organizationId", "projectId1","TestName", "Edit name", true, List.of("admin", "admin1"));
|
||||||
MvcResult mvcResult = this.responsePost(updateProject, project);
|
MvcResult mvcResult = this.responsePost(updateProject, project);
|
||||||
Project result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
ProjectExtendDTO result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||||
this.compareProjectDTO(currentProject, result);
|
this.compareProjectDTO(currentProject, result);
|
||||||
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
UserRoleRelationExample userRoleRelationExample = new UserRoleRelationExample();
|
||||||
|
@ -342,8 +382,10 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
|
|
||||||
//用户id为空
|
//用户id为空
|
||||||
project = this.generatorUpdate("organizationId", "projectId1", "TestNameUserIdIsNull", "Edit name", true, new ArrayList<>());
|
project = this.generatorUpdate("organizationId", "projectId1", "TestNameUserIdIsNull", "Edit name", true, new ArrayList<>());
|
||||||
|
ProjectExtend projectExtend = projectExtendMapper.selectByPrimaryKey("projectId1");
|
||||||
|
project.setModuleSetting(JSON.parseObject(projectExtend.getModuleSetting(), ModuleSettingDTO.class));
|
||||||
mvcResult = this.responsePost(updateProject, project);
|
mvcResult = this.responsePost(updateProject, project);
|
||||||
result = this.parseObjectFromMvcResult(mvcResult, Project.class);
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||||
this.compareProjectDTO(currentProject, result);
|
this.compareProjectDTO(currentProject, result);
|
||||||
userRoleRelationExample = new UserRoleRelationExample();
|
userRoleRelationExample = new UserRoleRelationExample();
|
||||||
|
@ -351,6 +393,29 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
//断言userRoleRelations是空的
|
//断言userRoleRelations是空的
|
||||||
Assertions.assertTrue(userRoleRelations.isEmpty());
|
Assertions.assertTrue(userRoleRelations.isEmpty());
|
||||||
|
|
||||||
|
// 修改模块设置
|
||||||
|
project = this.generatorUpdate("organizationId", "projectId1", "Module", "Edit name", true, new ArrayList<>());
|
||||||
|
ModuleSettingDTO moduleSettingDTO = JSON.parseObject(projectExtend.getModuleSetting(), ModuleSettingDTO.class);
|
||||||
|
moduleSettingDTO.setApiTest(true);
|
||||||
|
moduleSettingDTO.setTestPlan(true);
|
||||||
|
moduleSettingDTO.setUiTest(true);
|
||||||
|
moduleSettingDTO.setWorkstation(true);
|
||||||
|
project.setModuleSetting(moduleSettingDTO);
|
||||||
|
mvcResult = this.responsePost(updateProject, project);
|
||||||
|
result = this.parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||||
|
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||||
|
this.compareProjectDTO(currentProject, result);
|
||||||
|
userRoleRelationExample = new UserRoleRelationExample();
|
||||||
|
userRoleRelationExample.createCriteria().andSourceIdEqualTo("projectId1").andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||||
|
userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
|
||||||
|
//断言userRoleRelations是空的
|
||||||
|
Assertions.assertTrue(userRoleRelations.isEmpty());
|
||||||
|
//断言模块设置
|
||||||
|
projectExtend = projectExtendMapper.selectByPrimaryKey("projectId1");
|
||||||
|
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleSettingDTO));
|
||||||
|
|
||||||
|
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
project.setName("TestName2");
|
project.setName("TestName2");
|
||||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE, updateProject, project);
|
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE, updateProject, project);
|
||||||
|
@ -433,7 +498,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds), true);
|
Assertions.assertEquals(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds), true);
|
||||||
Assertions.assertTrue(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds));
|
Assertions.assertTrue(userRoleRelations.stream().map(UserRoleRelation::getUserId).collect(Collectors.toList()).containsAll(userIds));
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE, addProjectMember, projectAddMemberRequest);
|
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_ADD, addProjectMember, projectAddMemberRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -540,7 +605,7 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
int count = parseObjectFromMvcResult(mvcResult, Integer.class);
|
int count = parseObjectFromMvcResult(mvcResult, Integer.class);
|
||||||
Assertions.assertTrue(count == userRoleRelations.size());
|
Assertions.assertTrue(count == userRoleRelations.size());
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE, removeProjectMember + projectId + "/" + userId);
|
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_MEMBER_DELETE, removeProjectMember + projectId + "/" + userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue