feat: add message enable

This commit is contained in:
guoyuqi 2023-08-17 16:26:52 +08:00 committed by 刘瑞斌
parent 8627f7b68f
commit 4f27990b2c
4 changed files with 108 additions and 21 deletions

View File

@ -10,45 +10,51 @@ import lombok.Data;
@Data @Data
public class MessageTask implements Serializable { public class MessageTask implements Serializable {
@Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(title = "", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.id.not_blank}", groups = {Updated.class}) @NotBlank(message = "{message_task.id.not_blank}", groups = {Updated.class})
@Size(min = 1, max = 50, message = "{message_task.id.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 50, message = "{message_task.id.length_range}", groups = {Created.class, Updated.class})
private String id; private String id;
@Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(title = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.type.not_blank}", groups = {Created.class}) @NotBlank(message = "{message_task.type.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{message_task.type.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 50, message = "{message_task.type.length_range}", groups = {Created.class, Updated.class})
private String type; private String type;
@Schema(description = "通知事件类型", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(title = "通知事件类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.event.not_blank}", groups = {Created.class}) @NotBlank(message = "{message_task.event.not_blank}", groups = {Created.class})
@Size(min = 1, max = 255, message = "{message_task.event.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 255, message = "{message_task.event.length_range}", groups = {Created.class, Updated.class})
private String event; private String event;
@Schema(description = "接收人id", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(title = "接收人id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.receiver.not_blank}", groups = {Created.class}) @NotBlank(message = "{message_task.receiver.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{message_task.receiver.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 50, message = "{message_task.receiver.length_range}", groups = {Created.class, Updated.class})
private String receiver; private String receiver;
@Schema(description = "任务类型", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(title = "任务类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.task_type.not_blank}", groups = {Created.class}) @NotBlank(message = "{message_task.task_type.not_blank}", groups = {Created.class})
@Size(min = 1, max = 64, message = "{message_task.task_type.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 64, message = "{message_task.task_type.length_range}", groups = {Created.class, Updated.class})
private String taskType; private String taskType;
@Schema(description = "webhook地址") @Schema(title = "webhook地址")
private String webhook; private String webhook;
@Schema(description = "具体测试的ID") @Schema(title = "具体测试的ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.test_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{message_task.test_id.length_range}", groups = {Created.class, Updated.class})
private String testId; private String testId;
@Schema(description = "创建时间") @Schema(title = "创建时间")
private Long createTime; private Long createTime;
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(title = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.project_id.not_blank}", groups = {Created.class}) @NotBlank(message = "{message_task.project_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{message_task.project_id.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 50, message = "{message_task.project_id.length_range}", groups = {Created.class, Updated.class})
private String projectId; private String projectId;
@Schema(title = "是否启用")
@NotNull(message = "{message_task.enable.not_blank}", groups = {Created.class, Updated.class})
private Boolean enable;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public enum Column { public enum Column {
@ -60,7 +66,8 @@ public class MessageTask implements Serializable {
webhook("webhook", "webhook", "VARCHAR", false), webhook("webhook", "webhook", "VARCHAR", false),
testId("test_id", "testId", "VARCHAR", false), testId("test_id", "testId", "VARCHAR", false),
createTime("create_time", "createTime", "BIGINT", false), createTime("create_time", "createTime", "BIGINT", false),
projectId("project_id", "projectId", "VARCHAR", false); projectId("project_id", "projectId", "VARCHAR", false),
enable("enable", "enable", "BIT", true);
private static final String BEGINNING_DELIMITER = "`"; private static final String BEGINNING_DELIMITER = "`";

View File

@ -723,6 +723,66 @@ public class MessageTaskExample {
addCriterion("project_id not between", value1, value2, "projectId"); addCriterion("project_id not between", value1, value2, "projectId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andEnableIsNull() {
addCriterion("`enable` is null");
return (Criteria) this;
}
public Criteria andEnableIsNotNull() {
addCriterion("`enable` is not null");
return (Criteria) this;
}
public Criteria andEnableEqualTo(Boolean value) {
addCriterion("`enable` =", value, "enable");
return (Criteria) this;
}
public Criteria andEnableNotEqualTo(Boolean value) {
addCriterion("`enable` <>", value, "enable");
return (Criteria) this;
}
public Criteria andEnableGreaterThan(Boolean value) {
addCriterion("`enable` >", value, "enable");
return (Criteria) this;
}
public Criteria andEnableGreaterThanOrEqualTo(Boolean value) {
addCriterion("`enable` >=", value, "enable");
return (Criteria) this;
}
public Criteria andEnableLessThan(Boolean value) {
addCriterion("`enable` <", value, "enable");
return (Criteria) this;
}
public Criteria andEnableLessThanOrEqualTo(Boolean value) {
addCriterion("`enable` <=", value, "enable");
return (Criteria) this;
}
public Criteria andEnableIn(List<Boolean> values) {
addCriterion("`enable` in", values, "enable");
return (Criteria) this;
}
public Criteria andEnableNotIn(List<Boolean> values) {
addCriterion("`enable` not in", values, "enable");
return (Criteria) this;
}
public Criteria andEnableBetween(Boolean value1, Boolean value2) {
addCriterion("`enable` between", value1, value2, "enable");
return (Criteria) this;
}
public Criteria andEnableNotBetween(Boolean value1, Boolean value2) {
addCriterion("`enable` not between", value1, value2, "enable");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -11,6 +11,7 @@
<result column="test_id" jdbcType="VARCHAR" property="testId" /> <result column="test_id" jdbcType="VARCHAR" property="testId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="project_id" jdbcType="VARCHAR" property="projectId" /> <result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="enable" jdbcType="BIT" property="enable" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -71,7 +72,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, `type`, event, receiver, task_type, webhook, test_id, create_time, project_id id, `type`, event, receiver, task_type, webhook, test_id, create_time, project_id,
`enable`
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.project.domain.MessageTaskExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.project.domain.MessageTaskExample" resultMap="BaseResultMap">
select select
@ -106,12 +108,12 @@
<insert id="insert" parameterType="io.metersphere.project.domain.MessageTask"> <insert id="insert" parameterType="io.metersphere.project.domain.MessageTask">
insert into message_task (id, `type`, event, insert into message_task (id, `type`, event,
receiver, task_type, webhook, receiver, task_type, webhook,
test_id, create_time, project_id test_id, create_time, project_id,
) `enable`)
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
#{receiver,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR},
#{testId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR} #{testId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR},
) #{enable,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.project.domain.MessageTask"> <insert id="insertSelective" parameterType="io.metersphere.project.domain.MessageTask">
insert into message_task insert into message_task
@ -143,6 +145,9 @@
<if test="projectId != null"> <if test="projectId != null">
project_id, project_id,
</if> </if>
<if test="enable != null">
`enable`,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -172,6 +177,9 @@
<if test="projectId != null"> <if test="projectId != null">
#{projectId,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
</if> </if>
<if test="enable != null">
#{enable,jdbcType=BIT},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.project.domain.MessageTaskExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.project.domain.MessageTaskExample" resultType="java.lang.Long">
@ -210,6 +218,9 @@
<if test="record.projectId != null"> <if test="record.projectId != null">
project_id = #{record.projectId,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR},
</if> </if>
<if test="record.enable != null">
`enable` = #{record.enable,jdbcType=BIT},
</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" />
@ -225,7 +236,8 @@
webhook = #{record.webhook,jdbcType=VARCHAR}, webhook = #{record.webhook,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR}, test_id = #{record.testId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
project_id = #{record.projectId,jdbcType=VARCHAR} project_id = #{record.projectId,jdbcType=VARCHAR},
`enable` = #{record.enable,jdbcType=BIT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -257,6 +269,9 @@
<if test="projectId != null"> <if test="projectId != null">
project_id = #{projectId,jdbcType=VARCHAR}, project_id = #{projectId,jdbcType=VARCHAR},
</if> </if>
<if test="enable != null">
`enable` = #{enable,jdbcType=BIT},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -269,19 +284,20 @@
webhook = #{webhook,jdbcType=VARCHAR}, webhook = #{webhook,jdbcType=VARCHAR},
test_id = #{testId,jdbcType=VARCHAR}, test_id = #{testId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
project_id = #{projectId,jdbcType=VARCHAR} project_id = #{projectId,jdbcType=VARCHAR},
`enable` = #{enable,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
<insert id="batchInsert" parameterType="map"> <insert id="batchInsert" parameterType="map">
insert into message_task insert into message_task
(id, `type`, event, receiver, task_type, webhook, test_id, create_time, project_id (id, `type`, event, receiver, task_type, webhook, test_id, create_time, project_id,
) `enable`)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR}, #{item.event,jdbcType=VARCHAR}, (#{item.id,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR}, #{item.event,jdbcType=VARCHAR},
#{item.receiver,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR}, #{item.webhook,jdbcType=VARCHAR}, #{item.receiver,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR}, #{item.webhook,jdbcType=VARCHAR},
#{item.testId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.projectId,jdbcType=VARCHAR} #{item.testId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.projectId,jdbcType=VARCHAR},
) #{item.enable,jdbcType=BIT})
</foreach> </foreach>
</insert> </insert>
<insert id="batchInsertSelective" parameterType="map"> <insert id="batchInsertSelective" parameterType="map">
@ -321,6 +337,9 @@
<if test="'project_id'.toString() == column.value"> <if test="'project_id'.toString() == column.value">
#{item.projectId,jdbcType=VARCHAR} #{item.projectId,jdbcType=VARCHAR}
</if> </if>
<if test="'enable'.toString() == column.value">
#{item.enable,jdbcType=BIT}
</if>
</foreach> </foreach>
) )
</foreach> </foreach>

View File

@ -696,6 +696,7 @@ CREATE TABLE IF NOT EXISTS message_task
`test_id` VARCHAR(50) NOT NULL DEFAULT 'none' COMMENT '具体测试的ID', `test_id` VARCHAR(50) NOT NULL DEFAULT 'none' COMMENT '具体测试的ID',
`create_time` BIGINT NOT NULL DEFAULT 0 COMMENT '创建时间', `create_time` BIGINT NOT NULL DEFAULT 0 COMMENT '创建时间',
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID', `project_id` VARCHAR(50) NOT NULL COMMENT '项目ID',
`enable` BIT NOT NULL DEFAULT 1 COMMENT '是否启用' ,
PRIMARY KEY (id) PRIMARY KEY (id)
) ENGINE = InnoDB ) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 DEFAULT CHARSET = utf8mb4