refactor(消息管理): 修改消息管理执行逻辑

This commit is contained in:
guoyuqi 2023-09-18 17:16:11 +08:00 committed by fit2-zhao
parent 4e1c7f8f03
commit fb5fec0966
31 changed files with 3489 additions and 324 deletions

View File

@ -3,9 +3,11 @@ package io.metersphere.project.domain;
import io.metersphere.validation.groups.*;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import lombok.Data;
@Data
@ -16,55 +18,61 @@ public class MessageTask implements Serializable {
private String id;
@Schema(description = "通知事件类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.event.not_blank}", groups = {Created.class, Updated.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})
private String event;
@Schema(description = "接收人id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.receiver.not_blank}", groups = {Created.class, Updated.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})
private String receiver;
@Schema(description = "机器人id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.project_robot_id.not_blank}", groups = {Created.class, Updated.class})
@NotBlank(message = "{message_task.project_robot_id.not_blank}", groups = {Created.class})
@Size(min = 1, max = 50, message = "{message_task.project_robot_id.length_range}", groups = {Created.class, Updated.class})
private String projectRobotId;
@Schema(description = "任务类型", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.task_type.not_blank}", groups = {Created.class, Updated.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})
private String taskType;
@Schema(description = "具体测试的ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.test_id.not_blank}", groups = {Created.class, Updated.class})
@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;
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{message_task.project_id.not_blank}", groups = {Created.class, Updated.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})
private String projectId;
@Schema(description = "是否启用")
@NotNull(message = "{message_task.enable.not_blank}", groups = {Created.class, Updated.class})
private Boolean enable;
@Schema(description = "创建人")
@NotNull(message = "{message_task.createUser.not_blank}", groups = {Created.class, Updated.class})
private String createUser;
@Schema(description = "创建时间")
@NotNull(message = "{message_task.createTime.not_blank}", groups = {Created.class, Updated.class})
private Long createTime;
@Schema(description = "修改人")
@NotNull(message = "{message_task.updateUser.not_blank}", groups = {Created.class, Updated.class})
private String updateUser;
@Schema(description = "更新时间")
@NotNull(message = "{message_task.updateTime.not_blank}", groups = {Created.class, Updated.class})
private Long updateTime;
@Schema(description = "是否使用默认模版", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{message_task.use_default_template.not_blank}", groups = {Created.class})
private Boolean useDefaultTemplate;
@Schema(description = "是否使用默认标题(仅邮件)", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{message_task.use_default_subject.not_blank}", groups = {Created.class})
private Boolean useDefaultSubject;
@Schema(description = "邮件标题")
private String subject;
private static final long serialVersionUID = 1L;
public enum Column {
@ -79,7 +87,10 @@ public class MessageTask implements Serializable {
createUser("create_user", "createUser", "VARCHAR", false),
createTime("create_time", "createTime", "BIGINT", false),
updateUser("update_user", "updateUser", "VARCHAR", false),
updateTime("update_time", "updateTime", "BIGINT", false);
updateTime("update_time", "updateTime", "BIGINT", false),
useDefaultTemplate("use_default_template", "useDefaultTemplate", "BIT", false),
useDefaultSubject("use_default_subject", "useDefaultSubject", "BIT", false),
subject("subject", "subject", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`";
@ -124,7 +135,7 @@ public class MessageTask implements Serializable {
return this.getEscapedColumnName() + " ASC";
}
public static Column[] excludes(Column ... excludes) {
public static Column[] excludes(Column... excludes) {
ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
if (excludes != null && excludes.length > 0) {
columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));

View File

@ -913,6 +913,196 @@ public class MessageTaskExample {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateIsNull() {
addCriterion("use_default_template is null");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateIsNotNull() {
addCriterion("use_default_template is not null");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateEqualTo(Boolean value) {
addCriterion("use_default_template =", value, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateNotEqualTo(Boolean value) {
addCriterion("use_default_template <>", value, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateGreaterThan(Boolean value) {
addCriterion("use_default_template >", value, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateGreaterThanOrEqualTo(Boolean value) {
addCriterion("use_default_template >=", value, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateLessThan(Boolean value) {
addCriterion("use_default_template <", value, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateLessThanOrEqualTo(Boolean value) {
addCriterion("use_default_template <=", value, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateIn(List<Boolean> values) {
addCriterion("use_default_template in", values, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateNotIn(List<Boolean> values) {
addCriterion("use_default_template not in", values, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateBetween(Boolean value1, Boolean value2) {
addCriterion("use_default_template between", value1, value2, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultTemplateNotBetween(Boolean value1, Boolean value2) {
addCriterion("use_default_template not between", value1, value2, "useDefaultTemplate");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectIsNull() {
addCriterion("use_default_subject is null");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectIsNotNull() {
addCriterion("use_default_subject is not null");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectEqualTo(Boolean value) {
addCriterion("use_default_subject =", value, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectNotEqualTo(Boolean value) {
addCriterion("use_default_subject <>", value, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectGreaterThan(Boolean value) {
addCriterion("use_default_subject >", value, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectGreaterThanOrEqualTo(Boolean value) {
addCriterion("use_default_subject >=", value, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectLessThan(Boolean value) {
addCriterion("use_default_subject <", value, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectLessThanOrEqualTo(Boolean value) {
addCriterion("use_default_subject <=", value, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectIn(List<Boolean> values) {
addCriterion("use_default_subject in", values, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectNotIn(List<Boolean> values) {
addCriterion("use_default_subject not in", values, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectBetween(Boolean value1, Boolean value2) {
addCriterion("use_default_subject between", value1, value2, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andUseDefaultSubjectNotBetween(Boolean value1, Boolean value2) {
addCriterion("use_default_subject not between", value1, value2, "useDefaultSubject");
return (Criteria) this;
}
public Criteria andSubjectIsNull() {
addCriterion("subject is null");
return (Criteria) this;
}
public Criteria andSubjectIsNotNull() {
addCriterion("subject is not null");
return (Criteria) this;
}
public Criteria andSubjectEqualTo(String value) {
addCriterion("subject =", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotEqualTo(String value) {
addCriterion("subject <>", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThan(String value) {
addCriterion("subject >", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThanOrEqualTo(String value) {
addCriterion("subject >=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThan(String value) {
addCriterion("subject <", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThanOrEqualTo(String value) {
addCriterion("subject <=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLike(String value) {
addCriterion("subject like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotLike(String value) {
addCriterion("subject not like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectIn(List<String> values) {
addCriterion("subject in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotIn(List<String> values) {
addCriterion("subject not in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectBetween(String value1, String value2) {
addCriterion("subject between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotBetween(String value1, String value2) {
addCriterion("subject not between", value1, value2, "subject");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -14,6 +14,9 @@
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_user" jdbcType="VARCHAR" property="updateUser" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="use_default_template" jdbcType="BIT" property="useDefaultTemplate" />
<result column="use_default_subject" jdbcType="BIT" property="useDefaultSubject" />
<result column="subject" jdbcType="VARCHAR" property="subject" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -75,7 +78,8 @@
</sql>
<sql id="Base_Column_List">
id, event, receiver, project_robot_id, task_type, test_id, project_id, `enable`,
create_user, create_time, update_user, update_time
create_user, create_time, update_user, update_time, use_default_template, use_default_subject,
subject
</sql>
<select id="selectByExample" parameterType="io.metersphere.project.domain.MessageTaskExample" resultMap="BaseResultMap">
select
@ -111,12 +115,14 @@
insert into message_task (id, event, receiver,
project_robot_id, task_type, test_id,
project_id, `enable`, create_user,
create_time, update_user, update_time
create_time, update_user, update_time,
use_default_template, use_default_subject, subject
)
values (#{id,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR}, #{receiver,jdbcType=VARCHAR},
#{projectRobotId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
#{projectId,jdbcType=VARCHAR}, #{enable,jdbcType=BIT}, #{createUser,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}
#{createTime,jdbcType=BIGINT}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT},
#{useDefaultTemplate,jdbcType=BIT}, #{useDefaultSubject,jdbcType=BIT}, #{subject,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.project.domain.MessageTask">
@ -158,6 +164,15 @@
<if test="updateTime != null">
update_time,
</if>
<if test="useDefaultTemplate != null">
use_default_template,
</if>
<if test="useDefaultSubject != null">
use_default_subject,
</if>
<if test="subject != null">
subject,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -196,6 +211,15 @@
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="useDefaultTemplate != null">
#{useDefaultTemplate,jdbcType=BIT},
</if>
<if test="useDefaultSubject != null">
#{useDefaultSubject,jdbcType=BIT},
</if>
<if test="subject != null">
#{subject,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.project.domain.MessageTaskExample" resultType="java.lang.Long">
@ -243,6 +267,15 @@
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.useDefaultTemplate != null">
use_default_template = #{record.useDefaultTemplate,jdbcType=BIT},
</if>
<if test="record.useDefaultSubject != null">
use_default_subject = #{record.useDefaultSubject,jdbcType=BIT},
</if>
<if test="record.subject != null">
subject = #{record.subject,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -261,7 +294,10 @@
create_user = #{record.createUser,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_user = #{record.updateUser,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=BIGINT}
update_time = #{record.updateTime,jdbcType=BIGINT},
use_default_template = #{record.useDefaultTemplate,jdbcType=BIT},
use_default_subject = #{record.useDefaultSubject,jdbcType=BIT},
subject = #{record.subject,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -302,6 +338,15 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="useDefaultTemplate != null">
use_default_template = #{useDefaultTemplate,jdbcType=BIT},
</if>
<if test="useDefaultSubject != null">
use_default_subject = #{useDefaultSubject,jdbcType=BIT},
</if>
<if test="subject != null">
subject = #{subject,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -317,20 +362,25 @@
create_user = #{createUser,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_user = #{updateUser,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=BIGINT}
update_time = #{updateTime,jdbcType=BIGINT},
use_default_template = #{useDefaultTemplate,jdbcType=BIT},
use_default_subject = #{useDefaultSubject,jdbcType=BIT},
subject = #{subject,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
insert into message_task
(id, event, receiver, project_robot_id, task_type, test_id, project_id, `enable`,
create_user, create_time, update_user, update_time)
create_user, create_time, update_user, update_time, use_default_template, use_default_subject,
subject)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.event,jdbcType=VARCHAR}, #{item.receiver,jdbcType=VARCHAR},
#{item.projectRobotId,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR}, #{item.testId,jdbcType=VARCHAR},
#{item.projectId,jdbcType=VARCHAR}, #{item.enable,jdbcType=BIT}, #{item.createUser,jdbcType=VARCHAR},
#{item.createTime,jdbcType=BIGINT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}
)
#{item.createTime,jdbcType=BIGINT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT},
#{item.useDefaultTemplate,jdbcType=BIT}, #{item.useDefaultSubject,jdbcType=BIT},
#{item.subject,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -379,6 +429,15 @@
<if test="'update_time'.toString() == column.value">
#{item.updateTime,jdbcType=BIGINT}
</if>
<if test="'use_default_template'.toString() == column.value">
#{item.useDefaultTemplate,jdbcType=BIT}
</if>
<if test="'use_default_subject'.toString() == column.value">
#{item.useDefaultSubject,jdbcType=BIT}
</if>
<if test="'subject'.toString() == column.value">
#{item.subject,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>

View File

@ -228,8 +228,7 @@ CREATE TABLE IF NOT EXISTS custom_function_blob
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '自定义函数-代码片段大字段';
CREATE TABLE IF NOT EXISTS message_task
(
CREATE TABLE IF NOT EXISTS message_task(
`id` VARCHAR(50) NOT NULL COMMENT '' ,
`event` VARCHAR(255) NOT NULL COMMENT '通知事件类型' ,
`receiver` VARCHAR(50) NOT NULL COMMENT '接收人id' ,
@ -242,6 +241,9 @@ CREATE TABLE IF NOT EXISTS message_task
`create_time` BIGINT NOT NULL DEFAULT 0 COMMENT '创建时间' ,
`update_user` VARCHAR(50) NOT NULL COMMENT '修改人' ,
`update_time` BIGINT NOT NULL COMMENT '更新时间' ,
`use_default_template` BIT NOT NULL DEFAULT 1 COMMENT '是否使用默认模版' ,
`use_default_subject` BIT NOT NULL DEFAULT 1 COMMENT '是否使用默认标题(仅邮件)' ,
`subject` VARCHAR(64) COMMENT '邮件标题' ,
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
@ -257,6 +259,8 @@ CREATE INDEX idx_task_type ON message_task(task_type);
CREATE INDEX idx_project_robot_id ON message_task(project_robot_id);
CREATE INDEX idx_event ON message_task(event);
CREATE INDEX idx_enable ON message_task(enable);
CREATE INDEX idx_use_default_subject ON message_task(use_default_subject);
CREATE INDEX idx_use_default_template ON message_task(use_default_template);
CREATE TABLE IF NOT EXISTS message_task_blob
(

View File

@ -153,13 +153,237 @@ VALUES (uuid(), 'functional_default', '', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMES
INSERT INTO template_custom_field(id, field_id, template_id, required, pos, api_field_id, default_value)
VALUES(uuid(), (select id from custom_field where name = 'functional_priority'), (select id from template where name = 'functional_default'), 1, 0, NULL, NULL);
-- 初始化内置消息机器人
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), '100001100001', '站内信', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), '100001100001', '邮件', 'MAIL', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
-- 初始化默认项目版本
INSERT INTO project_version (id, project_id, name, description, status, latest, publish_time, start_time, end_time, create_time, create_user) VALUES (UUID_SHORT(), '100001100001', 'v1.0', NULL, 'open', 0, NULL, NULL, NULL, UNIX_TIMESTAMP() * 1000, 'admin');
-- 初始化内置消息机器人
SET @robot_in_site_id = UUID_SHORT();
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description)
VALUES (@robot_in_site_id, '100001100001', '站内信', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), '100001100001', '邮件', 'MAIL', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
-- 初始化消息设置数据
-- 初始化测试计划相关的消息数据
SET @test_plan_task_update_creator_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_update_creator_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'TEST_PLAN_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@test_plan_task_update_creator_id, 'message.test_plan_task_update');
SET @test_plan_task_update_follower_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_update_follower_id, 'UPDATE', 'FOLLOW_PEOPLE', @robot_in_site_id, 'TEST_PLAN_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@test_plan_task_update_follower_id, 'message.test_plan_task_update');
SET @test_plan_task_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'TEST_PLAN_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@test_plan_task_delete_id, 'message.test_plan_task_update');
SET @test_plan_task_execute_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_execute_id, 'EXECUTE_COMPLETED', 'OPERATOR', @robot_in_site_id, 'TEST_PLAN_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_task_execute_completed');
INSERT INTO message_task_blob(id, template) VALUES (@test_plan_task_execute_id, 'message.test_plan_task_execute_completed');
SET @test_plan_task_report_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@test_plan_task_report_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'TEST_PLAN_REPORT_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.test_plan_report_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@test_plan_task_report_id, 'message.test_plan_report_task_delete');
-- 初始化缺陷相关的消息数据
SET @bug_update_creator_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@bug_update_creator_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'BUG_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.bug_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@bug_update_creator_id, 'message.bug_task_update');
SET @bug_update_follower_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@bug_update_follower_id, 'UPDATE', 'FOLLOW_PEOPLE', @robot_in_site_id, 'BUG_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.bug_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@bug_update_follower_id, 'message.bug_task_update');
SET @bug_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@bug_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'BUG_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.bug_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@bug_delete_id, 'message.bug_task_delete');
SET @bug_comment_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@bug_comment_id, 'COMMENT', 'CREATE_USER', @robot_in_site_id, 'BUG_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.bug_task_comment');
INSERT INTO message_task_blob(id, template) VALUES (@bug_comment_id, 'message.bug_task_comment');
SET @bug_comment_at_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@bug_comment_at_id, 'COMMENT', 'CREATE_USER', @robot_in_site_id, 'BUG_TASK_AT', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.bug_task_comment');
INSERT INTO message_task_blob(id, template) VALUES (@bug_comment_at_id, 'message.bug_task_at_comment');
SET @bug_sync_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@bug_sync_id, 'EXECUTE_COMPLETED', 'OPERATOR', @robot_in_site_id, 'BUG_SYNC_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.bug_sync_task_execute_completed');
INSERT INTO message_task_blob(id, template) VALUES (@bug_sync_id, 'message.bug_sync_task_execute_completed');
-- 初始化用例管理消息设置数据
SET @functional_creator_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@functional_creator_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'FUNCTIONAL_CASE_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.functional_case_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@functional_creator_id, 'message.functional_case_task_update');
SET @functional_follower_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@functional_follower_id, 'UPDATE', 'FOLLOW_PEOPLE', @robot_in_site_id, 'FUNCTIONAL_CASE_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.functional_case_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@functional_follower_id, 'message.functional_case_task_update');
SET @functional_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@functional_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'FUNCTIONAL_CASE_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.functional_case_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@functional_delete_id, 'message.functional_case_task_delete');
SET @functional_comment_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@functional_comment_id, 'COMMENT', 'CREATE_USER', @robot_in_site_id, 'FUNCTIONAL_CASE_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.functional_case_task_comment');
INSERT INTO message_task_blob(id, template) VALUES (@functional_comment_id, 'message.functional_case_task_comment');
SET @functional_comment_at_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@functional_comment_at_id, 'COMMENT', 'CREATE_USER', @robot_in_site_id, 'FUNCTIONAL_CASE_TASK_AT', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.functional_case_task_comment');
INSERT INTO message_task_blob(id, template) VALUES (@functional_comment_at_id, 'message.functional_case_task_at_comment');
SET @case_creator_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@case_creator_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'CASE_REVIEW_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@case_creator_id, 'message.case_review_task_update');
SET @case_follower_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@case_follower_id, 'UPDATE', 'FOLLOW_PEOPLE', @robot_in_site_id, 'CASE_REVIEW_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@case_follower_id, 'message.case_review_task_update');
SET @case_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@case_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'CASE_REVIEW_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@case_delete_id, 'message.case_review_task_delete');
SET @case_execute_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@case_execute_id, 'EXECUTE_REVIEW', 'CREATE_USER', @robot_in_site_id, 'CASE_REVIEW_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_execute_review');
INSERT INTO message_task_blob(id, template) VALUES (@case_execute_id, 'message.case_review_task_execute_review');
SET @case_review_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@case_review_id, 'REVIEW_COMPLETED', 'CREATE_USER', @robot_in_site_id, 'CASE_REVIEW_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_review_completed');
INSERT INTO message_task_blob(id, template) VALUES (@case_review_id, 'message.case_review_task_review_completed');
-- 初始化接口文档消息数据
SET @api_creator_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_creator_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@api_creator_id, 'message.api_definition_task_update');
SET @api_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@api_delete_id, 'message.api_definition_task_delete');
SET @api_case_update_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_case_update_id, 'CASE_UPDATE', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_case_update');
INSERT INTO message_task_blob(id, template) VALUES (@api_case_update_id, 'message.api_definition_task_case_update');
SET @api_case_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_case_delete_id, 'CASE_DELETE', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_case_delete');
INSERT INTO message_task_blob(id, template) VALUES (@api_case_delete_id, 'message.api_definition_task_delete');
SET @api_execute_success_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_execute_success_id, 'CASE_EXECUTE_SUCCESSFUL', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_case_execute_successful');
INSERT INTO message_task_blob(id, template) VALUES (@api_execute_success_id, 'message.api_definition_task_case_execute');
SET @api_fake_error_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_fake_error_id, 'CASE_EXECUTE_FAKE_ERROR', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_case_execute_fake_error');
INSERT INTO message_task_blob(id, template) VALUES (@api_fake_error_id, 'message.api_definition_task_case_execute');
SET @api_execute_failed_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_execute_failed_id, 'CASE_EXECUTE_FAILED', 'CREATE_USER', @robot_in_site_id, 'API_DEFINITION_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_case_execute_failed');
INSERT INTO message_task_blob(id, template) VALUES (@api_execute_failed_id, 'message.api_definition_task_case_execute');
-- 初始化接口场景消息设置数据
SET @api_scenario_update_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_scenario_update_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'API_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_scenario_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@api_scenario_update_id, 'message.api_scenario_task_update');
SET @api_scenario_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_scenario_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'API_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_scenario_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@api_scenario_delete_id, 'message.api_scenario_task_delete');
SET @api_scenario_execute_success_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_scenario_execute_success_id, 'SCENARIO_EXECUTE_SUCCESSFUL', 'CREATE_USER', @robot_in_site_id, 'API_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_scenario_task_scenario_execute_successful');
INSERT INTO message_task_blob(id, template) VALUES (@api_scenario_execute_success_id, 'message.api_scenario_task_scenario_execute');
SET @api_scenario_fake_error_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_scenario_fake_error_id, 'SCENARIO_EXECUTE_FAKE_ERROR', 'CREATE_USER', @robot_in_site_id, 'API_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_scenario_task_scenario_execute_fake_error');
INSERT INTO message_task_blob(id, template) VALUES (@api_scenario_fake_error_id, 'message.api_scenario_task_scenario_execute');
SET @api_scenario_execute_failed_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_scenario_execute_failed_id, 'SCENARIO_EXECUTE_FAILED', 'CREATE_USER', @robot_in_site_id, 'API_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_scenario_task_scenario_execute_failed');
INSERT INTO message_task_blob(id, template) VALUES (@api_scenario_execute_failed_id, 'message.api_scenario_task_scenario_execute');
SET @api_scenario_report_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@api_scenario_report_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'API_REPORT_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.api_report_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@api_scenario_report_id, 'message.api_report_task_delete');
-- 初始化UI消息数据
SET @ui_update_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@ui_update_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'UI_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.ui_scenario_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@ui_update_id, 'message.ui_scenario_task_update');
SET @ui_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@ui_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'UI_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.ui_scenario_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@ui_delete_id, 'message.ui_scenario_task_delete');
SET @ui_execute_successful_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@ui_execute_successful_id, 'EXECUTE_SUCCESSFUL', 'CREATE_USER', @robot_in_site_id, 'UI_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.ui_scenario_task_execute_successful');
INSERT INTO message_task_blob(id, template) VALUES (@ui_execute_successful_id, 'message.ui_scenario_task_execute');
SET @ui_execute_failed_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@ui_execute_failed_id, 'EXECUTE_FAILED', 'CREATE_USER', @robot_in_site_id, 'UI_SCENARIO_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.ui_scenario_task_execute_failed');
INSERT INTO message_task_blob(id, template) VALUES (@ui_execute_failed_id, 'message.ui_scenario_task_execute');
SET @ui_report_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@ui_report_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'UI_REPORT_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.ui_report_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@ui_report_id, 'message.ui_report_task_delete');
-- 初始化性能测试消息数据
SET @load_create_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@load_create_id, 'UPDATE', 'CREATE_USER', @robot_in_site_id, 'LOAD_TEST_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.load_test_task_update');
INSERT INTO message_task_blob(id, template) VALUES (@load_create_id, 'message.load_test_task_update');
SET @load_delete_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@load_delete_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'LOAD_TEST_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.load_test_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@load_delete_id, 'message.load_test_task_delete');
SET @load_execute_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@load_execute_id, 'EXECUTE_COMPLETED', 'OPERATOR', @robot_in_site_id, 'LOAD_TEST_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.load_test_task_execute_completed');
INSERT INTO message_task_blob(id, template) VALUES (@load_execute_id, 'message.load_test_task_execute_completed');
SET @load_report_id = UUID_SHORT();
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES (@load_report_id, 'DELETE', 'CREATE_USER', @robot_in_site_id, 'LOAD_REPORT_TASK', 'NONE', '100001100001', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.load_report_task_delete');
INSERT INTO message_task_blob(id, template) VALUES (@load_report_id, 'message.load_report_task_delete');
-- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -38,8 +38,16 @@ public class MessageTaskRequest {
@Schema(description = "消息配置机器人是否开启")
public Boolean enable;
@Schema(description = "消息配置消息模版")
@NotBlank(message = "{message_task.template.not_blank}", groups = {Created.class, Updated.class})
@Schema(description = "消息配置企业用户自定义的消息模版")
public String template;
@Schema(description = "消息配置企业用户自定义的邮件标题")
public String subject;
@Schema(description = "是否使用默认模版")
private Boolean useDefaultTemplate;
@Schema(description = "是否使用默认邮件标题")
private Boolean useDefaultSubject;
}

View File

@ -114,6 +114,146 @@ permission.project_application_ui.read=UI测试-查询
permission.project_application_ui.update=UI测试-编辑
permission.project_base_info.name=基本信息
permission.project_log.name=日志
# message
message.test_plan_task=测试计划
message.schedule_task=定时任务
message.report_task=报告
message.bug_task=缺陷
message.bug_sync_task=同步
message.functional_case_task=功能用例
message.case_review_task=用例评审
message.api_definition_task=接口文档
message.api_scenario_task=接口场景
message.ui_scenario_task=UI自动化
message.load_test_task=测试用例
message.jenkins_task=Jenkins任务
message.test_plan_management=测试计划
message.bug_management=缺陷管理
message.case_management=用例管理
message.api_test_management=接口测试
message.ui_test_management=UI测试
message.load_test_management=性能测试
message.jenkins_task_management=Jenkins
message.create=创建
message.update=更新
message.delete=删除
message.execute_completed=执行完成
message.comment=评论
message.execute_review=执行评审
message.review_completed=评审完成
message.case_create=创建用例
message.case_update=更新用例
message.case_delete=删除用例
message.case_execute_successful=用例执行成功
message.case_execute_fake_error=用例执行误报
message.case_execute_failed=用例执行失败
message.scenario_execute_successful=场景执行成功
message.scenario_execute_fake_error=场景执行误报
message.scenario_execute_failed=场景执行失败
message.execute_successful=执行成功
message.execute_failed=执行失败
message.create_user=创建人
message.follow_people=关注人
message.operator=操作人
message.test_plan_task_create=${OPERATOR}创建了测试计划:${name}
message.test_plan_task_update=${OPERATOR}更新了测试计划:${name}
message.test_plan_task_delete=${OPERATOR}删除了测试计划:${name}
message.test_plan_task_execute_completed=${OPERATOR}执行完成了测试计划:${name}
message.schedule_execute_completed_test_plan=${OPERATOR}通过定时任务执行了测试计划:${name}
message.test_plan_report_task_delete=${OPERATOR}删除了测试计划报告:${name}
message.bug_task_create=${OPERATOR}创建了缺陷:${title}
message.bug_task_update=${OPERATOR}更新了缺陷:${title}
message.bug_task_delete=${OPERATOR}删除了缺陷:${title}
message.bug_task_comment=${OPERATOR}评论了你的缺陷:${title}
message.bug_task_at_comment=${OPERATOR}评论了缺陷:${title} 并@了你
message.bug_sync_task_execute_completed=${OPERATOR}同步了${total}条缺陷
message.bug_schedule_task_execute_completed=${OPERATOR}通过定时任务同步了${total}条缺陷
message.functional_case_task_create=${OPERATOR}创建了功能用例:${name}
message.functional_case_task_update=${OPERATOR}更新了功能用例:${name}
message.functional_case_task_delete=${OPERATOR}删除了功能用例:${name}
message.functional_case_task_comment=${OPERATOR}评论了你的功能用例:${name}
message.functional_case_task_at_comment=${OPERATOR}评论了功能用例:${name} 并@了你
message.case_review_task_create=${OPERATOR}创建了用例评审:${name}
message.case_review_task_update=${OPERATOR}更新了用例评审:${name}
message.case_review_task_delete=${OPERATOR}删除了用例评审:${name}
message.case_review_task_execute_review=${OPERATOR}评审了功能用例:${name}
message.case_review_task_review_completed=${OPERATOR}完成了用例评审:${name}
message.api_definition_task_create=${OPERATOR}创建了接口文档:${name}
message.api_definition_task_update=${OPERATOR}更新了接口文档:${name}
message.api_definition_task_delete=${OPERATOR}删除了接口文档:${name}
message.api_definition_task_case_create=${OPERATOR}创建了接口用例:${name}
message.api_definition_task_case_update=${OPERATOR}更新了接口用例:${name}
message.api_definition_task_case_delete=${OPERATOR}删除了接口用例:${name}
message.api_definition_task_case_execute=${OPERATOR}执行了接口用例:${name}
message.api_scenario_task_create=${OPERATOR}创建了接口场景:${name}
message.api_scenario_task_update=${OPERATOR}更新了接口场景:${name}
message.api_scenario_task_delete=${OPERATOR}删除了接口场景:${name}
message.api_scenario_task_scenario_execute=${OPERATOR}执行了接口场景:${name}
message.api_schedule_task_execute_completed=${OPERATOR}通过定时任务执行了接口场景:${name}
message.api_report_task_delete=${OPERATOR}删除了接口报告:${name}
message.ui_scenario_task_create=${OPERATOR}创建了UI用例:${name}
message.ui_scenario_task_update=${OPERATOR}更新了UI用例:${name}
message.ui_scenario_task_delete=${OPERATOR}删除了UI用例:${name}
message.ui_scenario_task_execute=${OPERATOR}执行了UI用例:${name}
message.ui_schedule_task_execute_completed=${OPERATOR}通过定时任务执行了UI用例:${name}
message.ui_report_task_delete=${OPERATOR}删除了UI报告:${name}
message.load_test_task_create=${OPERATOR}创建了性能用例:${name}
message.load_test_task_update=${OPERATOR}更新了性能用例:${name}
message.load_test_task_delete=${OPERATOR}删除了性能用例:${name}
message.load_test_task_execute_completed=${OPERATOR}执行了性能用例:${name}
message.load_schedule_task_execute_completed=${OPERATOR}通过定时任务执行了性能用例:${name}
message.load_report_task_delete=${OPERATOR}删除了性能报告:${name}
message.jenkins_task_execute_successful=Jenkins执行了场景用例:${name}
message.jenkins_task_execute_failed=Jenkins执行了测试计划:${name}
message.title.test_plan_task_create=测试计划创建通知
message.title.test_plan_task_update=测试计划更新通知
message.title.test_plan_task_delete=测试计划删除通知
message.title.test_plan_task_execute_completed=测试计划执行完成通知
message.title.bug_task_create=缺陷创建通知
message.title.bug_task_update=缺陷更新通知
message.title.bug_task_delete=缺陷删除通知
message.title.bug_task_comment=缺陷评论通知
message.title.bug_sync_task_execute_completed=同步缺陷执行完成通知
message.title.functional_case_task_create=功能用例创建通知
message.title.functional_case_task_update=功能用例更新通知
message.title.functional_case_task_delete=功能用例删除通知
message.title.functional_case_task_comment=功能用例评论通知
message.title.case_review_task_create=用例评审创建通知
message.title.case_review_task_update=用例评审更新通知
message.title.case_review_task_delete=用例评审删除通知
message.title.case_review_task_execute_review=用例评审执行通知
message.title.case_review_task_review_completed=用例评审评审完成通知
message.title.api_definition_task_create=接口文档创建通知
message.title.api_definition_task_update=接口文档更新通知
message.title.api_definition_task_delete=接口文档删除通知
message.title.api_definition_task_case_create=接口用例创建通知
message.title.api_definition_task_case_update=接口用例更新通知
message.title.api_definition_task_case_delete=接口用例删除通知
message.title.api_definition_task_case_execute_successful=接口用例执行成功通知
message.title.api_definition_task_case_execute_fake_error=接口用例执行误报通知
message.title.api_definition_task_case_execute_failed=接口用例执行失败通知
message.title.api_scenario_task_create=接口场景创建通知
message.title.api_scenario_task_update=接口场景更新通知
message.title.api_scenario_task_delete=接口场景删除通知
message.title.api_scenario_task_scenario_execute_successful=接口场景执行成功通知
message.title.api_scenario_task_scenario_execute_fake_error=接口场景执误报通知
message.title.api_scenario_task_scenario_execute_failed=接口场景执行失败通知
message.title.api_schedule_task_execute_completed=接口场景执行完成通知
message.title.api_report_task_delete=接口报告删除通知
message.title.ui_scenario_task_create=UI用例创建通知
message.title.ui_scenario_task_update=UI用例更新通知
message.title.ui_scenario_task_delete=UI用例删除通知
message.title.ui_scenario_task_execute_successful=UI用例执行成功通知
message.title.ui_scenario_task_execute_failed=UI用例执行失败通知
message.title.ui_schedule_task_execute_completed=UI执行完成通知
message.title.ui_report_task_delete=UI报告删除通知
message.title.load_test_task_create=性能用例创建通知
message.title.load_test_task_update=性能用例更新通知
message.title.load_test_task_delete=性能用例删除通知
message.title.load_test_task_execute_completed=性能用例执行完成通知
message.title.load_report_task_delete=性能报告删除通知
message.title.jenkins_task_execute_successful=Jenkins任务执行成功通知
message.title.jenkins_task_execute_failed=Jenkins任务执行失败通知
#file management
file_module.not.exist=文件模块不存在
upload.file.error=上传文件失败

View File

@ -148,6 +148,146 @@ environment_datasource.driverId.not_blank=Driver ID is required
environment_datasource.dbUrl.not_blank=Db Url is required
environment_name_is_null=Environment name is required
environment_config_is_null=Environment config is required
# message
message.test_plan_task=Test Plan
message.schedule_task=Scheduled tasks
message.report_task=Report
message.bug_task=Bug
message.bug_sync_task=Synchronize
message.functional_case_task=Functional case
message.case_review_task=Case review
message.api_definition_task=API documentation
message.api_scenario_task=API scenario
message.ui_scenario_task=UI automation
message.load_test_task=Test case
message.jenkins_task=Jenkins tasks
message.test_plan_management=Test Plan
message.bug_management=Bug management
message.case_management=Case management
message.api_test_management=API test
message.ui_test_management=UI test
message.load_test_management=Load test
message.jenkins_task_management=Jenkins
message.create=Create
message.update=Update
message.delete=Delete
message.execute_completed=Execution completed
message.comment=Comment
message.execute_review=Execution review
message.review_completed=Review completed
message.case_create=Create case
message.case_update=Update case
message.case_delete=Delete case
message.case_execute_successful=Case executed successfully
message.case_execute_fake_error=Case execution fake error
message.case_execute_failed=Case execution failed
message.scenario_execute_successful=Scenario executed successfully
message.scenario_execute_fake_error=Scenario execution fake error
message.scenario_execute_failed=Scenario execution failed
message.execute_successful=Executed successfully
message.execute_failed=Execution failed
message.create_user=Create user
message.follow_people=Follow people
message.operator=Operator
message.test_plan_task_create=${OPERATOR}created the test plan: ${name}
message.test_plan_task_update=${OPERATOR}updated the test plan: ${name}
message.test_plan_task_delete=${OPERATOR}deleted the test plan: ${name}
message.test_plan_task_execute_completed=${OPERATOR}executed and completed the test plan: ${name}
message.schedule_execute_completed_test_plan=${OPERATOR}executed the test plan through scheduled tasks: ${name}
message.test_plan_report_task_delete=${OPERATOR}deleted test plan report: ${name}
message.bug_task_create=${OPERATOR}created a bug: ${title}
message.bug_task_update=${OPERATOR}updated a bug: ${title}
message.bug_task_delete=${OPERATOR}deleted a bug: ${title}
message.bug_task_comment=${OPERATOR}commented on your bug: ${title}
message.bug_task_at_comment=${OPERATOR}commented on the bug: ${title} and @you
message.bug_sync_task_execute_completed=${OPERATOR}synchronized ${total} bugs
message.bug_schedule_task_execute_completed=${OPERATOR}synchronized ${total} bugs through scheduled tasks
message.functional_case_task_create=${OPERATOR}created the functional case: ${name}
message.functional_case_task_update=${OPERATOR}updated the functional case: ${name}
message.functional_case_task_delete=${OPERATOR}deleted the functional case: ${name}
message.functional_case_task_comment=${OPERATOR}commented on your functional case: ${name}
message.functional_case_task_at_comment=${OPERATOR}commented on functional case: ${name} and @you
message.case_review_task_create=${OPERATOR}created the case review: ${name}
message.case_review_task_update=${OPERATOR}updated the case review: ${name}
message.case_review_task_delete=${OPERATOR}deleted the case review: ${name}
message.case_review_task_execute_review=${OPERATOR}reviewed the functional case: ${name}
message.case_review_task_review_completed=${OPERATOR}completed the case review: ${name}
message.api_definition_task_create=${OPERATOR}created the API documentation: ${name}
message.api_definition_task_update=${OPERATOR}updated the API documentation: ${name}
message.api_definition_task_delete=${OPERATOR}deleted the API documentation: ${name}
message.api_definition_task_case_create=${OPERATOR}created the API case: ${name}
message.api_definition_task_case_update=${OPERATOR}updated the API case: ${name}
message.api_definition_task_case_delete=${OPERATOR}deleted the API case: ${name}
message.api_definition_task_case_execute=${OPERATOR}executed the API case: ${name}
message.api_scenario_task_create=${OPERATOR}created the API scenario: ${name}
message.api_scenario_task_update=${OPERATOR}updated the API scenario: ${name}
message.api_scenario_task_delete=${OPERATOR}deleted the API scenario: ${name}
message.api_scenario_task_scenario_execute=${OPERATOR}executed the API scenario: ${name}
message.api_schedule_task_execute_completed=${OPERATOR}executed the API scenario through a scheduled task: ${name}
message.api_report_task_delete=${OPERATOR}deleted API report: ${name}
message.ui_scenario_task_create=${OPERATOR}created the UI case: ${name}
message.ui_scenario_task_update=${OPERATOR}updated the UI case: ${name}
message.ui_scenario_task_delete=${OPERATOR}deleted the UI case: ${name}
message.ui_scenario_task_execute=${OPERATOR}executed the UI case: ${name}
message.ui_schedule_task_execute_completed=${OPERATOR}executed the UI case through a scheduled task: ${name}
message.ui_report_task_delete=${OPERATOR}deleted UI report: ${name}
message.load_test_task_create=${OPERATOR}created the load case: ${name}
message.load_test_task_update=${OPERATOR}updated the load case: ${name}
message.load_test_task_delete=${OPERATOR}deleted the load case: ${name}
message.load_test_task_execute_completed=${OPERATOR}executed the load case: ${name}
message.load_schedule_task_execute_completed=${OPERATOR}executed the load case through a scheduled task: ${name}
message.load_report_task_delete=${OPERATOR}deleted load report: ${name}
message.jenkins_task_execute_successful=Jenkins executed the API scenario: ${name}
message.jenkins_task_execute_failed=Jenkins executed the test plan: ${name}
message.title.test_plan_task_create=Test plan creation notification
message.title.test_plan_task_update=Test plan update notification
message.title.test_plan_task_delete=Test plan deletion notification
message.title.test_plan_task_execute_completed=Test plan execution completion notification
message.title.bug_task_create=Bug creation notification
message.title.bug_task_update=Bug update notification
message.title.bug_task_delete=Bug deletion notification
message.title.bug_task_comment=Bug comment notification
message.title.bug_sync_task_execute_completed=Synchronization bug execution completion notification
message.title.functional_case_task_create=Functional case creation notification
message.title.functional_case_task_update=Functional case update notification
message.title.functional_case_task_delete=Functional case deletion notification
message.title.functional_case_task_comment=Functional case comment notification
message.title.case_review_task_create=Case review creation notification
message.title.case_review_task_update=Case review update notification
message.title.case_review_task_delete=Case review deletion notification
message.title.case_review_task_execute_review=Case review execution notification
message.title.case_review_task_review_completed=Case review review completion notification
message.title.api_definition_task_create=API document creation notification
message.title.api_definition_task_update=API document update notification
message.title.api_definition_task_delete=API document deletion notification
message.title.api_definition_task_case_create=API case creation notification
message.title.api_definition_task_case_update=API case update notification
message.title.api_definition_task_case_delete=API case deletion notification
message.title.api_definition_task_case_execute_successful=API case execution success notification
message.title.api_definition_task_case_execute_fake_error=API case execution fake error notification
message.title.api_definition_task_case_execute_failed=API case execution failure notification
message.title.api_scenario_task_create=API scenario creation notification
message.title.api_scenario_task_update=API scenario update notification
message.title.api_scenario_task_delete=API scenario deletion notification
message.title.api_scenario_task_scenario_execute_successful=API scenario execution success notification
message.title.api_scenario_task_scenario_execute_fake_error=API scenario execution fake error notification
message.title.api_scenario_task_scenario_execute_failed=API scenario execution failure notification
message.title.api_schedule_task_execute_completed=API scenario execution completion notification
message.title.api_report_task_delete=API report deletion notification
message.title.ui_scenario_task_create=UI case creation notification
message.title.ui_scenario_task_update=UI case update notification
message.title.ui_scenario_task_delete=UI case deletion notification
message.title.ui_scenario_task_execute_successful=UI case execution success notification
message.title.ui_scenario_task_execute_failed=UI case execution failure notification
message.title.ui_schedule_task_execute_completed=UI execution completion notification
message.title.ui_report_task_delete=UI report deletion notification
message.title.load_test_task_create=Load case creation notification
message.title.load_test_task_update=Load case update notification
message.title.load_test_task_delete=Load case deletion notification
message.title.load_test_task_execute_completed=Load case execution completion notification
message.title.load_report_task_delete=Load report deletion notification
message.title.jenkins_task_execute_successful=Jenkins task execution success notification
message.title.jenkins_task_execute_failed=Jenkins task execution failure notification
resource_pool_not_exist=Resource pool does not exist

View File

@ -148,6 +148,146 @@ environment_datasource.driverId.not_blank=驱动ID不能为空
environment_datasource.dbUrl.not_blank=数据库连接不能为空
environment_name_is_null=环境名称不能为空
environment_config_is_null=环境配置不能为空
# message
message.test_plan_task=测试计划
message.schedule_task=定时任务
message.report_task=报告
message.bug_task=缺陷
message.bug_sync_task=同步
message.functional_case_task=功能用例
message.case_review_task=用例评审
message.api_definition_task=接口文档
message.api_scenario_task=接口场景
message.ui_scenario_task=UI自动化
message.load_test_task=测试用例
message.jenkins_task=Jenkins任务
message.test_plan_management=测试计划
message.bug_management=缺陷管理
message.case_management=用例管理
message.api_test_management=接口测试
message.ui_test_management=UI测试
message.load_test_management=性能测试
message.jenkins_task_management=Jenkins
message.create=创建
message.update=更新
message.delete=删除
message.execute_completed=执行完成
message.comment=评论
message.execute_review=执行评审
message.review_completed=评审完成
message.case_create=创建用例
message.case_update=更新用例
message.case_delete=删除用例
message.case_execute_successful=用例执行成功
message.case_execute_fake_error=用例执行误报
message.case_execute_failed=用例执行失败
message.scenario_execute_successful=场景执行成功
message.scenario_execute_fake_error=场景执行误报
message.scenario_execute_failed=场景执行失败
message.execute_successful=执行成功
message.execute_failed=执行失败
message.create_user=创建人
message.follow_people=关注人
message.operator=操作人
message.test_plan_task_create=${OPERATOR}创建了测试计划:${name}
message.test_plan_task_update=${OPERATOR}更新了测试计划:${name}
message.test_plan_task_delete=${OPERATOR}删除了测试计划:${name}
message.test_plan_task_execute_completed=${OPERATOR}执行完成了测试计划:${name}
message.schedule_execute_completed_test_plan=${OPERATOR}通过定时任务执行了测试计划:${name}
message.test_plan_report_task_delete=${OPERATOR}删除了测试计划报告:${name}
message.bug_task_create=${OPERATOR}创建了缺陷:${title}
message.bug_task_update=${OPERATOR}更新了缺陷:${title}
message.bug_task_delete=${OPERATOR}删除了缺陷:${title}
message.bug_task_comment=${OPERATOR}评论了你的缺陷:${title}
message.bug_task_at_comment=${OPERATOR}评论了缺陷:${title} 并@了你
message.bug_sync_task_execute_completed=${OPERATOR}同步了${total}条缺陷
message.bug_schedule_task_execute_completed=${OPERATOR}通过定时任务同步了${total}条缺陷
message.functional_case_task_create=${OPERATOR}创建了功能用例:${name}
message.functional_case_task_update=${OPERATOR}更新了功能用例:${name}
message.functional_case_task_delete=${OPERATOR}删除了功能用例:${name}
message.functional_case_task_comment=${OPERATOR}评论了你的功能用例:${name}
message.functional_case_task_at_comment=${OPERATOR}评论了功能用例:${name} 并@了你
message.case_review_task_create=${OPERATOR}创建了用例评审:${name}
message.case_review_task_update=${OPERATOR}更新了用例评审:${name}
message.case_review_task_delete=${OPERATOR}删除了用例评审:${name}
message.case_review_task_execute_review=${OPERATOR}评审了功能用例:${name}
message.case_review_task_review_completed=${OPERATOR}完成了用例评审:${name}
message.api_definition_task_create=${OPERATOR}创建了接口文档:${name}
message.api_definition_task_update=${OPERATOR}更新了接口文档:${name}
message.api_definition_task_delete=${OPERATOR}删除了接口文档:${name}
message.api_definition_task_case_create=${OPERATOR}创建了接口用例:${name}
message.api_definition_task_case_update=${OPERATOR}更新了接口用例:${name}
message.api_definition_task_case_delete=${OPERATOR}删除了接口用例:${name}
message.api_definition_task_case_execute=${OPERATOR}执行了接口用例:${name}
message.api_scenario_task_create=${OPERATOR}创建了接口场景:${name}
message.api_scenario_task_update=${OPERATOR}更新了接口场景:${name}
message.api_scenario_task_delete=${OPERATOR}删除了接口场景:${name}
message.api_scenario_task_scenario_execute=${OPERATOR}执行了接口场景:${name}
message.api_schedule_task_execute_completed=${OPERATOR}通过定时任务执行了接口场景:${name}
message.api_report_task_delete=${OPERATOR}删除了接口报告:${name}
message.ui_scenario_task_create=${OPERATOR}创建了UI用例:${name}
message.ui_scenario_task_update=${OPERATOR}更新了UI用例:${name}
message.ui_scenario_task_delete=${OPERATOR}删除了UI用例:${name}
message.ui_scenario_task_execute=${OPERATOR}执行了UI用例:${name}
message.ui_schedule_task_execute_completed=${OPERATOR}通过定时任务执行了UI用例:${name}
message.ui_report_task_delete=${OPERATOR}删除了UI报告:${name}
message.load_test_task_create=${OPERATOR}创建了性能用例:${name}
message.load_test_task_update=${OPERATOR}更新了性能用例:${name}
message.load_test_task_delete=${OPERATOR}删除了性能用例:${name}
message.load_test_task_execute_completed=${OPERATOR}执行了性能用例:${name}
message.load_schedule_task_execute_completed=${OPERATOR}通过定时任务执行了性能用例:${name}
message.load_report_task_delete=${OPERATOR}删除了性能报告:${name}
message.jenkins_task_execute_successful=Jenkins执行了场景用例:${name}
message.jenkins_task_execute_failed=Jenkins执行了测试计划:${name}
message.title.test_plan_task_create=测试计划创建通知
message.title.test_plan_task_update=测试计划更新通知
message.title.test_plan_task_delete=测试计划删除通知
message.title.test_plan_task_execute_completed=测试计划执行完成通知
message.title.bug_task_create=缺陷创建通知
message.title.bug_task_update=缺陷更新通知
message.title.bug_task_delete=缺陷删除通知
message.title.bug_task_comment=缺陷评论通知
message.title.bug_sync_task_execute_completed=同步缺陷执行完成通知
message.title.functional_case_task_create=功能用例创建通知
message.title.functional_case_task_update=功能用例更新通知
message.title.functional_case_task_delete=功能用例删除通知
message.title.functional_case_task_comment=功能用例评论通知
message.title.case_review_task_create=用例评审创建通知
message.title.case_review_task_update=用例评审更新通知
message.title.case_review_task_delete=用例评审删除通知
message.title.case_review_task_execute_review=用例评审执行通知
message.title.case_review_task_review_completed=用例评审评审完成通知
message.title.api_definition_task_create=接口文档创建通知
message.title.api_definition_task_update=接口文档更新通知
message.title.api_definition_task_delete=接口文档删除通知
message.title.api_definition_task_case_create=接口用例创建通知
message.title.api_definition_task_case_update=接口用例更新通知
message.title.api_definition_task_case_delete=接口用例删除通知
message.title.api_definition_task_case_execute_successful=接口用例执行成功通知
message.title.api_definition_task_case_execute_fake_error=接口用例执行误报通知
message.title.api_definition_task_case_execute_failed=接口用例执行失败通知
message.title.api_scenario_task_create=接口场景创建通知
message.title.api_scenario_task_update=接口场景更新通知
message.title.api_scenario_task_delete=接口场景删除通知
message.title.api_scenario_task_scenario_execute_successful=接口场景执行成功通知
message.title.api_scenario_task_scenario_execute_fake_error=接口场景执误报通知
message.title.api_scenario_task_scenario_execute_failed=接口场景执行失败通知
message.title.api_schedule_task_execute_completed=接口场景执行完成通知
message.title.api_report_task_delete=接口报告删除通知
message.title.ui_scenario_task_create=UI用例创建通知
message.title.ui_scenario_task_update=UI用例更新通知
message.title.ui_scenario_task_delete=UI用例删除通知
message.title.ui_scenario_task_execute_successful=UI用例执行成功通知
message.title.ui_scenario_task_execute_failed=UI用例执行失败通知
message.title.ui_schedule_task_execute_completed=UI执行完成通知
message.title.ui_report_task_delete=UI报告删除通知
message.title.load_test_task_create=性能用例创建通知
message.title.load_test_task_update=性能用例更新通知
message.title.load_test_task_delete=性能用例删除通知
message.title.load_test_task_execute_completed=性能用例执行完成通知
message.title.load_report_task_delete=性能报告删除通知
message.title.jenkins_task_execute_successful=Jenkins任务执行成功通知
message.title.jenkins_task_execute_failed=Jenkins任务执行失败通知
resource_pool_not_exist=资源池不存在
#file management

View File

@ -148,6 +148,146 @@ environment_datasource.driverId.not_blank=驅動ID不能為空
environment_datasource.dbUrl.not_blank=數據庫地址不能為空
environment_name_is_null=環境名稱不能為空
environment_config_is_null=環境配置不能為空
# message
message.test_plan_task=測試計劃
message.schedule_task=定時任務
message.report_task=報告
message.bug_task=缺陷
message.bug_sync_task=同步
message.functional_case_task=功能用例
message.case_review_task=用例評審
message.api_definition_task=介面文檔
message.api_scenario_task=介面場景
message.ui_scenario_task=UI自動化
message.load_test_task=測試用例
message.jenkins_task=Jenkins任務
message.test_plan_management=測試計劃
message.bug_management=缺陷管理
message.case_management=用例管理
message.api_test_management=介面測試
message.ui_test_management=UI測試
message.load_test_management=效能測試
message.jenkins_task_management=Jenkins
message.create=創建
message.update=更新
message.delete=删除
message.execute_completed=執行完成
message.comment=評論
message.execute_review=執行評審
message.review_completed=評審完成
message.case_create=創建用例
message.case_update=更新用例
message.case_delete=删除用例
message.case_execute_successful=用例執行成功
message.case_execute_fake_error=用例執行誤報
message.case_execute_failed=用例執行失敗
message.scenario_execute_successful=场景執行成功
message.scenario_execute_fake_error=场景執行誤報
message.scenario_execute_failed=场景執行失敗
message.execute_successful=執行成功
message.execute_failed=執行失敗
message.create_user=創建人
message.follow_people=關注人
message.operator=操作人
message.test_plan_task_create=${OPERATOR}創建了測試計劃:${name}
message.test_plan_task_update=${OPERATOR}更新了測試計劃:${name}
message.test_plan_task_delete=${OPERATOR}删除了測試計劃:${name}
message.test_plan_task_execute_completed=${OPERATOR}執行完成了測試計劃:${name}
message.schedule_execute_completed_test_plan=${OPERATOR}透過定時任務執行了測試計劃:${name}
message.test_plan_report_task_delete=${OPERATOR}删除了測試計劃報告:${name}
message.bug_task_create=${OPERATOR}創建了缺陷:${title}
message.bug_task_update=${OPERATOR}更新了缺陷:${title}
message.bug_task_delete=${OPERATOR}删除了缺陷:${title}
message.bug_task_comment=${OPERATOR}評論了你的缺陷:${title}
message.bug_task_at_comment=${OPERATOR}評論了缺陷:${title} 並@了你
message.bug_sync_task_execute_completed=${OPERATOR}同步了${total}条缺陷
message.bug_schedule_task_execute_completed=${OPERATOR}透過定時任務同步了${total}条缺陷
message.functional_case_task_create=${OPERATOR}創建了功能用例:${name}
message.functional_case_task_update=${OPERATOR}更新了功能用例:${name}
message.functional_case_task_delete=${OPERATOR}删除了功能用例:${name}
message.functional_case_task_comment=${OPERATOR}評論了你的功能用例:${name}
message.functional_case_task_at_comment=${OPERATOR}評論了功能用例:${name} 並@了你
message.case_review_task_create=${OPERATOR}創建了用例評審:${name}
message.case_review_task_update=${OPERATOR}更新了用例評審:${name}
message.case_review_task_delete=${OPERATOR}删除了用例評審:${name}
message.case_review_task_execute_review=${OPERATOR}評審了功能用例:${name}
message.case_review_task_review_completed=${OPERATOR}完成了用例評審:${name}
message.api_definition_task_create=${OPERATOR}創建了介面文檔:${name}
message.api_definition_task_update=${OPERATOR}更新了介面文檔:${name}
message.api_definition_task_delete=${OPERATOR}删除了介面文檔:${name}
message.api_definition_task_case_create=${OPERATOR}創建了介面用例:${name}
message.api_definition_task_case_update=${OPERATOR}更新了介面用例:${name}
message.api_definition_task_case_delete=${OPERATOR}删除了介面用例:${name}
message.api_definition_task_case_execute=${OPERATOR}執行了介面用例:${name}
message.api_scenario_task_create=${OPERATOR}創建了介面場景:${name}
message.api_scenario_task_update=${OPERATOR}更新了介面場景:${name}
message.api_scenario_task_delete=${OPERATOR}删除了介面場景:${name}
message.api_scenario_task_scenario_execute=${OPERATOR}執行了介面場景:${name}
message.api_schedule_task_execute_completed=${OPERATOR}透過定時任務執行了介面場景:${name}
message.api_report_task_delete=${OPERATOR}删除了接口報告:${name}
message.ui_scenario_task_create=${OPERATOR}創建了UI用例:${name}
message.ui_scenario_task_update=${OPERATOR}更新了UI用例:${name}
message.ui_scenario_task_delete=${OPERATOR}删除了UI用例:${name}
message.ui_scenario_task_execute=${OPERATOR}執行了UI用例:${name}
message.ui_schedule_task_execute_completed=${OPERATOR}透過定時任務執行了UI用例:${name}
message.ui_report_task_delete=${OPERATOR}删除了UI報告:${name}
message.load_test_task_create=${OPERATOR}創建了性能用例:${name}
message.load_test_task_update=${OPERATOR}更新了性能用例:${name}
message.load_test_task_delete=${OPERATOR}删除了性能用例:${name}
message.load_test_task_execute_completed=${OPERATOR}執行了性能用例:${name}
message.load_schedule_task_execute_completed=${OPERATOR}透過定時任務執行了性能用例:${name}
message.load_report_task_delete=${OPERATOR}删除了性能報告:${name}
message.jenkins_task_execute_successful=Jenkins執行了场景用例:${name}
message.jenkins_task_execute_failed=Jenkins執行了測試計劃:${name}
message.title.test_plan_task_create=測試計劃創建通知
message.title.test_plan_task_update=測試計劃更新通知
message.title.test_plan_task_delete=測試計劃删除通知
message.title.test_plan_task_execute_completed=測試計劃執行完成通知
message.title.bug_task_create=缺陷創建通知
message.title.bug_task_update=缺陷更新通知
message.title.bug_task_delete=缺陷删除通知
message.title.bug_task_comment=缺陷評論通知
message.title.bug_sync_task_execute_completed=同步缺陷執行完成通知
message.title.functional_case_task_create=功能用例創建通知
message.title.functional_case_task_update=功能用例更新通知
message.title.functional_case_task_delete=功能用例删除通知
message.title.functional_case_task_comment=功能用例評論通知
message.title.case_review_task_create=用例評審創建通知
message.title.case_review_task_update=用例評審更新通知
message.title.case_review_task_delete=用例評審删除通知
message.title.case_review_task_execute_review=用例評審執行通知
message.title.case_review_task_review_completed=用例評審評審完成通知
message.title.api_definition_task_create=介面文檔創建通知
message.title.api_definition_task_update=介面文檔更新通知
message.title.api_definition_task_delete=介面文檔删除通知
message.title.api_definition_task_case_create=介面用例創建通知
message.title.api_definition_task_case_update=介面用例更新通知
message.title.api_definition_task_case_delete=介面用例删除通知
message.title.api_definition_task_case_execute_successful=介面用例執行成功通知
message.title.api_definition_task_case_execute_fake_error=介面用例執行誤報通知
message.title.api_definition_task_case_execute_failed=介面用例執行失敗通知
message.title.api_scenario_task_create=介面場景創建通知
message.title.api_scenario_task_update=介面場景更新通知
message.title.api_scenario_task_delete=介面場景删除通知
message.title.api_scenario_task_scenario_execute_successful=介面場景執行成功通知
message.title.api_scenario_task_scenario_execute_fake_error=介面場景执誤報通知
message.title.api_scenario_task_scenario_execute_failed=介面場景執行失敗通知
message.title.api_schedule_task_execute_completed=介面場景執行完成通知
message.title.api_report_task_delete=接口報告删除通知
message.title.ui_scenario_task_create=UI用例創建通知
message.title.ui_scenario_task_update=UI用例更新通知
message.title.ui_scenario_task_delete=UI用例删除通知
message.title.ui_scenario_task_execute_successful=UI用例執行成功通知
message.title.ui_scenario_task_execute_failed=UI用例執行失敗通知
message.title.ui_schedule_task_execute_completed=UI執行完成通知
message.title.ui_report_task_delete=UI報告删除通知
message.title.load_test_task_create=性能用例創建通知
message.title.load_test_task_update=性能用例更新通知
message.title.load_test_task_delete=性能用例删除通知
message.title.load_test_task_execute_completed=性能用例執行完成通知
message.title.load_report_task_delete=性能報告删除通知
message.title.jenkins_task_execute_successful=Jenkins任務執行成功通知
message.title.jenkins_task_execute_failed=Jenkins任務執行失敗通知
resource_pool_not_exist=資源池不存在
#file management

View File

@ -2,21 +2,29 @@ package io.metersphere.project.controller;
import io.metersphere.project.dto.MessageTaskDTO;
import io.metersphere.project.service.MessageTaskLogService;
import io.metersphere.project.service.NoticeMessageTaskService;
import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.sdk.dto.request.MessageTaskRequest;
import io.metersphere.system.log.annotation.Log;
import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.utils.SessionUtils;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "项目管理-消息设置")
@Tag(name = "项目管理-项目与权限-消息管理-消息设置")
@RestController
@RequestMapping("notice/")
public class NoticeMessageTaskController {
@ -24,13 +32,16 @@ public class NoticeMessageTaskController {
private NoticeMessageTaskService noticeMessageTaskService;
@PostMapping("message/task/save")
@Operation(summary = "项目管理-消息设置-保存消息设置")
public ResultHolder saveMessage(@Validated({Created.class}) @RequestBody MessageTaskRequest messageTaskRequest) {
@Operation(summary = "项目管理-项目与权限-消息管理-消息设置-保存消息设置")
@RequiresPermissions(value = {PermissionConstants.PROJECT_MESSAGE_READ_ADD, PermissionConstants.PROJECT_MESSAGE_READ_UPDATE}, logical = Logical.OR)
@Log(type = OperationLogType.UPDATE, expression = "#msClass.addLog(#messageTaskRequest)", msClass = MessageTaskLogService.class)
public ResultHolder saveMessage(@Validated({Created.class, Updated.class}) @RequestBody MessageTaskRequest messageTaskRequest) {
return noticeMessageTaskService.saveMessageTask(messageTaskRequest, SessionUtils.getUserId());
}
@GetMapping("message/task/get/{projectId}")
@Operation(summary = "项目管理-消息设置-获取消息设置")
@Operation(summary = "项目管理-项目与权限-消息管理-消息设置-获取消息设置")
@RequiresPermissions(PermissionConstants.PROJECT_MESSAGE_READ_ADD)
public List<MessageTaskDTO> getMessageList(@PathVariable String projectId) {
return noticeMessageTaskService.getMessageList(projectId);
}

View File

@ -4,24 +4,26 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
public class MessageTaskDTO {
public class MessageTaskDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "消息配置所在项目ID")
public String projectId;
@Schema(description = "消息配置功能")
public String taskType;
public String type;
@Schema(description = "消息配置场景")
public String event;
@Schema(description = "消息配置功能名称")
public String name;
@Schema(description = "消息配置接收人")
private List<String> receiverIds;
@Schema(description = "消息配置功能展开内容")
public List<MessageTaskTypeDTO> messageTaskTypeDTOList;
@Schema(description = "消息配置机器人设置")
private List<ProjectRobotConfigDTO> projectRobotConfigList;
}

View File

@ -0,0 +1,30 @@
package io.metersphere.project.dto;
import io.metersphere.sdk.dto.OptionDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
public class MessageTaskDetailDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "消息配置场景")
public String event;
@Schema(description = "消息配置场景名称")
public String eventName;
@Schema(description = "消息配置接收人")
private List<OptionDTO> receivers;
@Schema(description = "消息配置机器人设置")
private List<ProjectRobotConfigDTO> projectRobotConfigList;
}

View File

@ -0,0 +1,27 @@
package io.metersphere.project.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
public class MessageTaskTypeDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "消息配置功能类型")
public String taskType;
@Schema(description = "消息配置功能类型名称")
public String taskTypeName;
@Schema(description = "消息配置场景详情")
public List<MessageTaskDetailDTO> messageTaskDetailDTOList;
}

View File

@ -3,17 +3,41 @@ package io.metersphere.project.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = false)
public class ProjectRobotConfigDTO {
public class ProjectRobotConfigDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "消息配置机器人id")
public String robotId;
@Schema(description = "所属平台(飞书:LARK钉钉:DING_TALK企业微信:WE_COM自定义:CUSTOM, 站内信:IN_SITE, 邮件:MAIL")
private String platform;
@Schema(description = "消息配置机器人是否开启")
public Boolean enable;
@Schema(description = "消息配置机器人发送模版")
public String template;
@Schema(description = "消息配置机器人发送模版")
public String defaultTemplate;
@Schema(description = "消息配置机器人是否使用默认模版")
public Boolean useDefaultTemplate;
@Schema(description = "机器人配置的标题")
public String subject;
@Schema(description = "机器人配置的默认标题")
public String defaultSubject;
@Schema(description = "机器人是否使用默认标题")
public Boolean useDefaultSubject;
}

View File

@ -0,0 +1,28 @@
package io.metersphere.project.service;
import io.metersphere.project.domain.MessageTaskExample;
import io.metersphere.project.mapper.MessageTaskMapper;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.service.CleanupProjectResourceService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;
@Component
public class CleanupMessageTaskService implements CleanupProjectResourceService {
@Resource
private MessageTaskMapper messageTaskMapper;
@Override
public void deleteResources(String projectId) {
MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria().andProjectIdEqualTo(projectId);
messageTaskMapper.deleteByExample(messageTaskExample);
LogUtils.info("删除当前项目[" + projectId + "]相关消息管理资源");
}
@Override
public void cleanReportResources(String projectId) {
LogUtils.info("清理当前项目[" + projectId + "]相关消息管理报告资源");
}
}

View File

@ -0,0 +1,77 @@
package io.metersphere.project.service;
import io.metersphere.project.domain.MessageTask;
import io.metersphere.project.domain.MessageTaskExample;
import io.metersphere.project.domain.ProjectRobot;
import io.metersphere.project.domain.ProjectRobotExample;
import io.metersphere.project.enums.ProjectRobotPlatform;
import io.metersphere.project.mapper.MessageTaskMapper;
import io.metersphere.project.mapper.ProjectRobotMapper;
import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.dto.LogDTO;
import io.metersphere.sdk.dto.request.MessageTaskRequest;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.log.constants.OperationLogModule;
import io.metersphere.system.log.constants.OperationLogType;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class MessageTaskLogService {
@Resource
private ProjectRobotMapper projectRobotMapper;
@Resource
private MessageTaskMapper messageTaskMapper;
/**
* 添加接口日志
*
* @param messageTaskRequest 消息配置参数
* @return LogDTO
*/
public LogDTO addLog(MessageTaskRequest messageTaskRequest) {
MessageTaskExample messageTaskExample = new MessageTaskExample();
//如果只选了用户没有选机器人默认机器人为站内信
String robotId = setDefaultRobot(messageTaskRequest.getProjectId(), messageTaskRequest.getRobotId());
messageTaskExample.createCriteria().andProjectIdEqualTo(messageTaskRequest.getProjectId())
.andProjectRobotIdEqualTo(robotId).andTaskTypeEqualTo(messageTaskRequest.getTaskType()).andEventEqualTo(messageTaskRequest.getEvent());
List<MessageTask> messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
LogDTO dto = new LogDTO(
messageTaskRequest.getProjectId(),
"",
messageTaskRequest.getTaskType()+messageTaskRequest.getEvent(),
null,
OperationLogType.UPDATE.name(),
OperationLogModule.PROJECT_MANAGEMENT_MESSAGE,
messageTaskRequest.getTaskType());
dto.setPath("/notice/message/task/save");
dto.setMethod(HttpMethodConstants.POST.name());
dto.setOriginalValue(JSON.toJSONBytes(messageTasks.get(0)));
return dto;
}
/**
* 查询默认机器人id
*
* @param projectId 项目id
* @param robotId 机器人id
* @return String
*/
private String setDefaultRobot(String projectId, String robotId) {
if (StringUtils.isBlank(robotId)) {
ProjectRobotExample projectRobotExample = new ProjectRobotExample();
projectRobotExample.createCriteria().andProjectIdEqualTo(projectId).andPlatformEqualTo(ProjectRobotPlatform.IN_SITE.toString());
List<ProjectRobot> projectRobots = projectRobotMapper.selectByExample(projectRobotExample);
robotId = projectRobots.get(0).getId();
}
return robotId;
}
}

View File

@ -3,6 +3,8 @@ package io.metersphere.project.service;
import io.metersphere.project.domain.*;
import io.metersphere.project.dto.MessageTaskDTO;
import io.metersphere.project.dto.MessageTaskDetailDTO;
import io.metersphere.project.dto.MessageTaskTypeDTO;
import io.metersphere.project.dto.ProjectRobotConfigDTO;
import io.metersphere.project.enums.ProjectRobotPlatform;
import io.metersphere.project.enums.result.ProjectResultCode;
@ -10,9 +12,14 @@ import io.metersphere.project.mapper.MessageTaskBlobMapper;
import io.metersphere.project.mapper.MessageTaskMapper;
import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.project.mapper.ProjectRobotMapper;
import io.metersphere.sdk.dto.OptionDTO;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.sdk.dto.request.MessageTaskRequest;
import io.metersphere.sdk.exception.MSException;
import io.metersphere.system.domain.UserExample;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.notice.utils.MessageTemplateUtils;
import io.metersphere.system.uid.UUID;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.User;
@ -31,6 +38,10 @@ import org.mybatis.spring.SqlSessionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;
@ -58,10 +69,6 @@ public class NoticeMessageTaskService {
public static final String NO_USER_NAMES = "no_user_names";
public static final String CREATOR = "CREATOR";
public static final String FOLLOW_PEOPLE = "FOLLOW_PEOPLE";
public ResultHolder saveMessageTask(MessageTaskRequest messageTaskRequest, String userId) {
String projectId = messageTaskRequest.getProjectId();
@ -98,6 +105,7 @@ public class NoticeMessageTaskService {
/**
* 新增MessageTask
*
* @param messageTaskRequest 入参
* @param userId 当前用户i的
* @param mapper MessageTaskMapper
@ -105,25 +113,29 @@ public class NoticeMessageTaskService {
* @param existUserIds 系统中还存在的入参传过来的接收人
* @param messageTaskReceivers 更新过后还有多少接收人需要保存
*/
private static void insertMessageTask(MessageTaskRequest messageTaskRequest, String userId, MessageTaskMapper mapper, MessageTaskBlobMapper blobMapper, List<String> existUserIds, List<String> messageTaskReceivers) {
String testId = messageTaskRequest.getTestId() == null ? "NONE" : messageTaskRequest.getTestId();
boolean enable = messageTaskRequest.getEnable() != null && messageTaskRequest.getEnable();
private void insertMessageTask(MessageTaskRequest messageTaskRequest, String userId, MessageTaskMapper mapper, MessageTaskBlobMapper blobMapper, List<String> existUserIds, List<String> messageTaskReceivers) {
List<MessageTask> messageTasks = new ArrayList<>();
for (String receiverId : existUserIds) {
if (CollectionUtils.isNotEmpty(messageTaskReceivers) && messageTaskReceivers.contains(receiverId)) {
continue;
}
MessageTask messageTask = new MessageTask();
buildMessageTask(messageTaskRequest, userId, messageTaskRequest.getRobotId(), testId, enable, receiverId, messageTask);
buildMessageTask(messageTaskRequest, userId, receiverId, messageTask);
mapper.insert(messageTask);
MessageTaskBlob messageTaskBlob = new MessageTaskBlob();
messageTaskBlob.setId(messageTask.getId());
if (!messageTask.getUseDefaultTemplate()) {
messageTaskBlob.setTemplate(messageTaskRequest.getTemplate());
}
messageTaskBlob.setTemplate(messageTaskRequest.getTemplate());
messageTasks.add(messageTask);
blobMapper.insert(messageTaskBlob);
}
}
/**
* 查询默认机器人id
*
* @param projectId 项目id
* @param robotId 机器人id
* @return String
@ -140,6 +152,7 @@ public class NoticeMessageTaskService {
/**
* 检查数据库是否有同类型数据有则更新
*
* @param messageTaskRequest 入参
* @param userId 当前用户ID
* @param mapper MessageTaskMapper
@ -149,6 +162,9 @@ public class NoticeMessageTaskService {
*/
private List<MessageTask> updateMessageTasks(MessageTaskRequest messageTaskRequest, String userId, MessageTaskMapper mapper, MessageTaskBlobMapper blobMapper, List<String> existUserIds) {
boolean enable = messageTaskRequest.getEnable() != null && messageTaskRequest.getEnable();
boolean useDefaultSubject = messageTaskRequest.getUseDefaultSubject() == null || messageTaskRequest.getUseDefaultSubject();
boolean useDefaultTemplate = messageTaskRequest.getUseDefaultTemplate() == null || messageTaskRequest.getUseDefaultTemplate();
MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria().andReceiverIn(existUserIds).andProjectIdEqualTo(messageTaskRequest.getProjectId())
.andProjectRobotIdEqualTo(messageTaskRequest.getRobotId()).andTaskTypeEqualTo(messageTaskRequest.getTaskType()).andEventEqualTo(messageTaskRequest.getEvent());
@ -160,6 +176,11 @@ public class NoticeMessageTaskService {
messageTask.setUpdateTime(System.currentTimeMillis());
messageTask.setUpdateUser(userId);
messageTask.setEnable(enable);
messageTask.setUseDefaultSubject(useDefaultSubject);
messageTask.setUseDefaultTemplate(useDefaultTemplate);
if (!useDefaultSubject) {
messageTask.setSubject(messageTaskRequest.getSubject());
}
mapper.updateByPrimaryKeySelective(messageTask);
}
List<String> messageTaskIds = messageTasks.stream().map(MessageTask::getId).toList();
@ -167,38 +188,52 @@ public class NoticeMessageTaskService {
messageTaskBlobExample.createCriteria().andIdIn(messageTaskIds);
List<MessageTaskBlob> messageTaskBlobs = messageTaskBlobMapper.selectByExample(messageTaskBlobExample);
for (MessageTaskBlob messageTaskBlob : messageTaskBlobs) {
if (!useDefaultTemplate) {
messageTaskBlob.setTemplate(messageTaskRequest.getTemplate());
blobMapper.updateByPrimaryKeySelective(messageTaskBlob);
}
}
return messageTasks;
}
private static void buildMessageTask(MessageTaskRequest messageTaskRequest, String userId, String robotId, String testId, boolean enable, String receiverId, MessageTask messageTask) {
private static void buildMessageTask(MessageTaskRequest messageTaskRequest, String userId, String receiverId, MessageTask messageTask) {
String testId = messageTaskRequest.getTestId() == null ? "NONE" : messageTaskRequest.getTestId();
boolean enable = messageTaskRequest.getEnable() != null && messageTaskRequest.getEnable();
boolean useDefaultSubject = messageTaskRequest.getUseDefaultSubject() == null || messageTaskRequest.getUseDefaultSubject();
boolean useDefaultTemplate = messageTaskRequest.getUseDefaultTemplate() == null || messageTaskRequest.getUseDefaultTemplate();
String insertId = UUID.randomUUID().toString();
messageTask.setId(insertId);
messageTask.setTaskType(messageTaskRequest.getTaskType());
messageTask.setEvent(messageTaskRequest.getEvent());
messageTask.setReceiver(receiverId);
messageTask.setProjectId(messageTaskRequest.getProjectId());
messageTask.setProjectRobotId(robotId);
messageTask.setProjectRobotId(messageTaskRequest.getRobotId());
messageTask.setTestId(testId);
messageTask.setCreateUser(userId);
messageTask.setCreateTime(System.currentTimeMillis());
messageTask.setUpdateUser(userId);
messageTask.setUpdateTime(System.currentTimeMillis());
messageTask.setEnable(enable);
messageTask.setUseDefaultTemplate(useDefaultTemplate);
messageTask.setUseDefaultSubject(useDefaultSubject);
if (!useDefaultSubject) {
messageTask.setSubject(messageTaskRequest.getSubject());
}
}
/**
* 检查用户是否存在
*
* @param receiverIds 接收人ids
* @param projectId 项目id
* @return Map<String, List<String>>
* @return Map<String, List < String>>
*/
private Map<String, List<String>> checkUserExistProject(List<String> receiverIds, String projectId) {
List<String>normalUserIds = new ArrayList<>();
List<String> normalUserIds = new ArrayList<>();
List<String> defaultRelatedUser = MessageTemplateUtils.getDefaultRelatedUser();
for (String receiverId : receiverIds) {
if (!StringUtils.equalsIgnoreCase(receiverId, CREATOR) && !StringUtils.equalsIgnoreCase(receiverId, FOLLOW_PEOPLE)) {
if (!defaultRelatedUser.contains(receiverId)) {
normalUserIds.add(receiverId);
}
}
@ -209,19 +244,26 @@ public class NoticeMessageTaskService {
List<UserRoleRelation> userRoleRelations = userRoleRelationMapper.selectByExample(userRoleRelationExample);
userIds = new ArrayList<>(userRoleRelations.stream().map(UserRoleRelation::getUserId).distinct().toList());
}
if (receiverIds.contains(CREATOR)) {
userIds.add(CREATOR);
if (receiverIds.contains(NoticeConstants.RelatedUser.CREATE_USER)) {
userIds.add(NoticeConstants.RelatedUser.CREATE_USER);
}
if (receiverIds.contains(FOLLOW_PEOPLE)) {
userIds.add(FOLLOW_PEOPLE);
if (receiverIds.contains(NoticeConstants.RelatedUser.FOLLOW_PEOPLE)) {
userIds.add(NoticeConstants.RelatedUser.FOLLOW_PEOPLE);
}
if (receiverIds.contains(NoticeConstants.RelatedUser.OPERATOR)) {
userIds.add(NoticeConstants.RelatedUser.OPERATOR);
}
Map<String, List<String>> map = new HashMap<>();
List<String> noUserNames = new ArrayList<>();
if (userIds.size() < receiverIds.size()) {
for (String receiverId : receiverIds) {
if (!StringUtils.equalsIgnoreCase(receiverId, CREATOR) && !StringUtils.equalsIgnoreCase(receiverId, FOLLOW_PEOPLE) && !userIds.contains(receiverId)) {
if (!defaultRelatedUser.contains(receiverId) && !userIds.contains(receiverId)) {
User user = userMapper.selectByPrimaryKey(receiverId);
if (user == null) {
noUserNames.add(receiverId);
} else {
noUserNames.add(user.getName());
}
break;
}
}
@ -231,44 +273,136 @@ public class NoticeMessageTaskService {
return map;
}
/**
* 根据项目id 获取当前项目的消息设置
*
* @param projectId 项目ID
* @return List<MessageTaskDTO>
*/
public List<MessageTaskDTO> getMessageList(String projectId) {
checkProjectExist(projectId);
//获取返回数据结构
StringBuilder jsonStr = new StringBuilder();
InputStream inputStream = getClass().getResourceAsStream("/message_task.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
try {
while ((line = reader.readLine()) != null) {
jsonStr.append(line);
}
reader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
List<MessageTaskDTO> messageTaskDTOList = JSON.parseArray(jsonStr.toString(), MessageTaskDTO.class);
//查询数据
MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria().andProjectIdEqualTo(projectId);
List<MessageTask> messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
if (CollectionUtils.isEmpty(messageTasks)) {
return new ArrayList<>();
return messageTaskDTOList;
}
List<String> messageTaskIds = messageTasks.stream().map(MessageTask::getId).toList();
MessageTaskBlobExample messageTaskBlobExample = new MessageTaskBlobExample();
messageTaskBlobExample.createCriteria().andIdIn(messageTaskIds);
List<MessageTaskBlob> messageTaskBlobs = messageTaskBlobMapper.selectByExample(messageTaskBlobExample);
List<String> robotIds = messageTasks.stream().map(MessageTask::getProjectRobotId).toList();
ProjectRobotExample projectRobotExample = new ProjectRobotExample();
projectRobotExample.createCriteria().andIdIn(robotIds);
List<ProjectRobot> projectRobots = projectRobotMapper.selectByExample(projectRobotExample);
Map<String, ProjectRobot> robotMap = projectRobots.stream().collect(Collectors.toMap(ProjectRobot::getId, item -> item));
List<String> userIds = messageTasks.stream().map(MessageTask::getReceiver).toList();
UserExample userExample = new UserExample();
userExample.createCriteria().andIdIn(userIds).andDeletedEqualTo(false);
List<User> users = userMapper.selectByExample(userExample);
Map<String, String> userNameMap = users.stream().collect(Collectors.toMap(User::getId, User::getName));
Map<String, String> defaultRelatedUserMap = MessageTemplateUtils.getDefaultRelatedUserMap();
userNameMap.putAll(defaultRelatedUserMap);
//开始准备数据
Map<String, MessageTaskBlob> messageTaskBlobMap = messageTaskBlobs.stream().collect(Collectors.toMap(MessageTaskBlob::getId, item -> item));
Map<String, List<MessageTask>> messageMap = messageTasks.stream().collect(Collectors.groupingBy(t -> (t.getTaskType() + "-" + t.getEvent())));
List<MessageTaskDTO> list = new ArrayList<>();
messageMap.forEach((key, messageTaskList) -> {
MessageTaskDTO messageTaskDTO = new MessageTaskDTO();
int i = key.indexOf("-");
String taskType = key.substring(0, i);
String event = key.substring(i+1);
Map<String, List<MessageTask>> messageMap = messageTasks.stream().collect(Collectors.groupingBy(MessageTask::getTaskType));
//获取默认数据
Map<String, String> moduleMap = MessageTemplateUtils.getModuleMap();
Map<String, String> taskTypeMap = MessageTemplateUtils.getTaskTypeMap();
Map<String, String> eventMap = MessageTemplateUtils.getEventMap();
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
Map<String, String> defaultTemplateTitleMap = MessageTemplateUtils.getDefaultTemplateTitleMap();
String robotId = setDefaultRobot(projectId, null);
for (MessageTaskDTO messageTaskDTO : messageTaskDTOList) {
messageTaskDTO.setProjectId(projectId);
messageTaskDTO.setTaskType(taskType);
messageTaskDTO.setEvent(event);
Set<String>receiverIds = new HashSet<>();
List<ProjectRobotConfigDTO>projectRobotConfigList = new ArrayList<>();
messageTaskDTO.setName(moduleMap.get(messageTaskDTO.getType()));
for (MessageTaskTypeDTO messageTaskTypeDTO : messageTaskDTO.getMessageTaskTypeDTOList()) {
List<MessageTask> messageTaskTypeList = messageMap.get(messageTaskTypeDTO.getTaskType());
if (CollectionUtils.isEmpty(messageTaskTypeList)) {
continue;
}
Map<String, List<MessageTask>> messageEventMap = messageTaskTypeList.stream().collect(Collectors.groupingBy(MessageTask::getEvent));
messageTaskTypeDTO.setTaskTypeName(taskTypeMap.get(messageTaskTypeDTO.getTaskType()));
for (MessageTaskDetailDTO messageTaskDetailDTO : messageTaskTypeDTO.getMessageTaskDetailDTOList()) {
messageTaskDetailDTO.setEventName(eventMap.get(messageTaskDetailDTO.getEvent()));
List<MessageTask> messageTaskList = messageEventMap.get(messageTaskDetailDTO.getEvent());
List<OptionDTO> receivers = new ArrayList<>();
List<ProjectRobotConfigDTO> projectRobotConfigList = new ArrayList<>();
String defaultTemplate = defaultTemplateMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
if (CollectionUtils.isEmpty(messageTaskList)) {
String defaultSubject = defaultTemplateTitleMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
ProjectRobotConfigDTO projectRobotConfigDTO = getDefaultProjectRobotConfigDTO(defaultTemplate, defaultSubject, robotId);
projectRobotConfigList.add(projectRobotConfigDTO);
} else {
for (MessageTask messageTask : messageTaskList) {
MessageTaskBlob messageTaskBlob = messageTaskBlobMap.get(messageTask.getId());
receiverIds.add(messageTask.getReceiver());
ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO();
projectRobotConfigDTO.setRobotId(messageTask.getProjectRobotId());
projectRobotConfigDTO.setEnable(messageTask.getEnable());
projectRobotConfigDTO.setTemplate(messageTaskBlob.getTemplate());
OptionDTO optionDTO = new OptionDTO();
optionDTO.setId(messageTask.getReceiver());
optionDTO.setName(userNameMap.get(messageTask.getReceiver()));
receivers.add(optionDTO);
String platform = robotMap.get(messageTask.getProjectRobotId()).getPlatform();
String defaultSubject;
if (StringUtils.equalsIgnoreCase(platform, ProjectRobotPlatform.MAIL.toString())) {
defaultSubject = "MeterSphere " + defaultTemplateTitleMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
} else {
defaultSubject = defaultTemplateTitleMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
}
ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, platform, messageTask, messageTaskBlob);
projectRobotConfigList.add(projectRobotConfigDTO);
}
messageTaskDTO.setReceiverIds(new ArrayList<>(receiverIds));
messageTaskDTO.setProjectRobotConfigList(projectRobotConfigList);
list.add(messageTaskDTO);
});
return list;
}
List<OptionDTO> distinctReceivers = receivers.stream().distinct().toList();
messageTaskDetailDTO.setReceivers(distinctReceivers);
messageTaskDetailDTO.setProjectRobotConfigList(projectRobotConfigList);
}
}
}
return messageTaskDTOList;
}
private static ProjectRobotConfigDTO getProjectRobotConfigDTO(String defaultTemplate, String defaultSubject, String robotPlatForm, MessageTask messageTask, MessageTaskBlob messageTaskBlob) {
ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO();
projectRobotConfigDTO.setRobotId(messageTask.getProjectRobotId());
projectRobotConfigDTO.setPlatform(robotPlatForm);
projectRobotConfigDTO.setEnable(messageTask.getEnable());
projectRobotConfigDTO.setTemplate(messageTaskBlob.getTemplate());
projectRobotConfigDTO.setDefaultTemplate(defaultTemplate);
projectRobotConfigDTO.setSubject(messageTask.getSubject());
projectRobotConfigDTO.setDefaultSubject(defaultSubject);
projectRobotConfigDTO.setUseDefaultSubject(messageTask.getUseDefaultSubject());
projectRobotConfigDTO.setUseDefaultTemplate(messageTask.getUseDefaultTemplate());
return projectRobotConfigDTO;
}
private static ProjectRobotConfigDTO getDefaultProjectRobotConfigDTO(String defaultTemplate, String defaultSubject, String robotId) {
ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO();
projectRobotConfigDTO.setRobotId(robotId);
projectRobotConfigDTO.setPlatform(ProjectRobotPlatform.IN_SITE.toString());
projectRobotConfigDTO.setEnable(false);
projectRobotConfigDTO.setTemplate("");
projectRobotConfigDTO.setDefaultTemplate(defaultTemplate);
projectRobotConfigDTO.setSubject("");
projectRobotConfigDTO.setDefaultSubject(defaultSubject);
projectRobotConfigDTO.setUseDefaultSubject(true);
projectRobotConfigDTO.setUseDefaultTemplate(true);
return projectRobotConfigDTO;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,11 @@ package io.metersphere.project.controller;
import io.metersphere.project.domain.MessageTask;
import io.metersphere.project.domain.MessageTaskBlob;
import io.metersphere.project.domain.MessageTaskExample;
import io.metersphere.project.dto.MessageTaskDTO;
import io.metersphere.project.mapper.MessageTaskBlobMapper;
import io.metersphere.project.mapper.MessageTaskMapper;
import io.metersphere.sdk.constants.SessionConstants;
import io.metersphere.sdk.dto.request.MessageTaskRequest;
@ -12,8 +15,8 @@ import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.notice.constants.NoticeConstants;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.junit.jupiter.api.*;
import org.junit.platform.commons.util.StringUtils;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
@ -23,8 +26,7 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -38,10 +40,14 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
@Resource
private MessageTaskMapper messageTaskMapper;
@Resource
private MessageTaskBlobMapper messageTaskBlobMapper;
@Test
@Order(1)
@Sql(scripts = {"/dml/init_project_message.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void addMessageTaskUserNoExistSuccess() throws Exception {
//projectId 存在 用户有部分被删除的测试
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
@ -53,7 +59,6 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -69,6 +74,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
@Test
@Order(2)
public void addMessageTaskCheckUserSuccess() throws Exception {
//projectId存在 user都存在没有被删除
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-1");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
@ -95,6 +101,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
@Test
@Order(3)
public void addMessageTaskCheckUserFile() throws Exception {
//用户都不存在
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-1");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
@ -105,7 +112,6 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -121,6 +127,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
@Test
@Order(4)
public void addMessageTaskCheckRobotSuccess() throws Exception {
//使用默认机器人 使用默认模版
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-1");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
@ -131,7 +138,6 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setEnable(null);
messageTaskRequest.setTestId("testId");
messageTaskRequest.setTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -154,6 +160,8 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
@Test
@Order(5)
public void addMessageTaskCheckOldExistSuccess() throws Exception {
//更新使用默认模版
//使用默认机器人 使用默认模版
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-1");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
@ -162,9 +170,8 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
userIds.add("project-message-user-7");
userIds.add("project-message-user-8");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot1");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("发送消息测试");
messageTaskRequest.setEnable(null);
messageTaskRequest.setTestId("testId");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -179,13 +186,51 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
messageTaskExample.createCriteria().andTaskTypeEqualTo(NoticeConstants.TaskType.API_DEFINITION_TASK)
.andEventEqualTo(NoticeConstants.Event.CREATE).andReceiverEqualTo("project-message-user-8").andProjectIdEqualTo("project-message-test-1");
List<MessageTask> messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
Assertions.assertEquals(1, messageTasks.size());
Assertions.assertEquals(true, messageTasks.get(0).getEnable());
Assertions.assertEquals("test_message_robot1", messageTasks.get(0).getProjectRobotId());
Assertions.assertEquals(false, messageTasks.get(0).getEnable());
}
@Test
@Order(6)
public void addMessageTaskWithTemplateAndSubject() throws Exception {
//项目不存在
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-1");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
messageTaskRequest.setEvent(NoticeConstants.Event.CREATE);
List<String> userIds = new ArrayList<>();
userIds.add("project-message-user-9");
userIds.add("project-message-user-10");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot1");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("测试新加数据模版生效");
messageTaskRequest.setUseDefaultTemplate(false);
messageTaskRequest.setSubject("测试新加数据模版标题生效");
messageTaskRequest.setUseDefaultSubject(false);
MvcResult mvcResult =mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.content(JSON.toJSONString(messageTaskRequest))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
Assertions.assertEquals(100200, resultHolder.getCode());
MessageTaskExample messageTaskExample = new MessageTaskExample();
messageTaskExample.createCriteria().andTaskTypeEqualTo(NoticeConstants.TaskType.API_DEFINITION_TASK)
.andEventEqualTo(NoticeConstants.Event.CREATE).andReceiverEqualTo("project-message-user-9").andProjectIdEqualTo("project-message-test-1");
List<MessageTask> messageTasks = messageTaskMapper.selectByExample(messageTaskExample);
MessageTaskBlob messageTaskBlob = messageTaskBlobMapper.selectByPrimaryKey(messageTasks.get(0).getId());
Assertions.assertEquals("测试新加数据模版生效", messageTaskBlob.getTemplate());
Assertions.assertEquals("测试新加数据模版标题生效", messageTasks.get(0).getSubject());
}
@Test
@Order(7)
public void addMessageTaskCheckProjectExistFail() throws Exception {
//项目不存在
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-3");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
@ -196,7 +241,6 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot1");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("发送消息测试");
mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -207,7 +251,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
}
@Test
@Order(7)
@Order(8)
public void getMessageListSuccess() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/project-message-test-1")
.header(SessionConstants.HEADER_TOKEN, sessionId)
@ -216,13 +260,14 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
List<MessageTaskDTO> messageTaskDTOList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), MessageTaskDTO.class);
Assertions.assertTrue(CollectionUtils.isNotEmpty(messageTaskDTOList));
Assertions.assertEquals(messageTaskDTOList.get(0).getTaskType(), NoticeConstants.TaskType.API_DEFINITION_TASK);
List<MessageTaskDTO> messageTaskDetailDTOList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), MessageTaskDTO.class);
// String robotId = messageTaskDetailDTOList.get(0).getMessageTaskTypeDTOList().get(0).getMessageTaskDetailDTOList().get(0).getProjectRobotConfigList().get(0).getRobotId();
// Assertions.assertTrue(StringUtils.isNotBlank(robotId));
System.out.println(messageTaskDetailDTOList);
}
@Test
@Order(8)
@Order(9)
public void getMessageListProjectFail() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/project-message-test-3")
.header(SessionConstants.HEADER_TOKEN, sessionId)
@ -232,7 +277,7 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
}
@Test
@Order(9)
@Order(10)
public void getMessageListEmpty() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/project-message-test-2")
.header(SessionConstants.HEADER_TOKEN, sessionId)
@ -241,51 +286,26 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
List<MessageTaskDTO> messageTaskDTOList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), MessageTaskDTO.class);
Assertions.assertTrue(CollectionUtils.isEmpty(messageTaskDTOList));
List<MessageTaskDTO> messageTaskDetailDTOList = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), MessageTaskDTO.class);
String robotId = messageTaskDetailDTOList.get(0).getMessageTaskTypeDTOList().get(0).getMessageTaskDetailDTOList().get(0).getProjectRobotConfigList().get(0).getRobotId();
Assertions.assertTrue(StringUtils.isBlank(robotId));
}
@Test
@Order(10)
@Order(11)
public void addMessageTaskCheckSpecialUserSuccess() throws Exception {
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test-1");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
messageTaskRequest.setEvent(NoticeConstants.Event.CREATE);
List<String> userIds = new ArrayList<>();
userIds.add("CREATOR");
userIds.add("CREATE_USER");
userIds.add("FOLLOW_PEOPLE");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.content(JSON.toJSONString(messageTaskRequest))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
Assertions.assertEquals(100200, resultHolder.getCode());
}
@Test
@Order(11)
public void addMessageTaskCheckSpecialUserTwoSuccess() throws Exception {
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
messageTaskRequest.setEvent(NoticeConstants.Event.CREATE);
List<String> userIds = new ArrayList<>();
userIds.add("CREATOR");
userIds.add("FOLLOW_PEOPLE");
userIds.add("project-message-user-5");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(true);
messageTaskRequest.setTemplate("发送消息测试");
//messageTaskRequest.setDefaultTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -300,20 +320,47 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
@Test
@Order(12)
public void addMessageTaskCheckSpecialUserTwoSuccess() throws Exception {
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
messageTaskRequest.setEvent(NoticeConstants.Event.CREATE);
List<String> userIds = new ArrayList<>();
userIds.add("CREATE_USER");
userIds.add("FOLLOW_PEOPLE");
userIds.add("project-message-user-5");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(true);
// messageTaskRequest.setDefaultTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.content(JSON.toJSONString(messageTaskRequest))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
Assertions.assertEquals(100200, resultHolder.getCode());
}
@Test
@Order(13)
public void addMessageTaskCheckSpecialUserThreeSuccess() throws Exception {
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
messageTaskRequest.setEvent(NoticeConstants.Event.CREATE);
List<String> userIds = new ArrayList<>();
userIds.add("CREATOR");
userIds.add("CREATE_USER");
userIds.add("FOLLOW_PEOPLE");
userIds.add("project-message-user-6");
userIds.add("project-message-user-del");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(false);
messageTaskRequest.setTemplate("发送消息测试");
//messageTaskRequest.setDefaultTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -327,19 +374,19 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
}
@Test
@Order(13)
@Order(14)
public void closeMessageTaskSuccess() throws Exception {
MessageTaskRequest messageTaskRequest = new MessageTaskRequest();
messageTaskRequest.setProjectId("project-message-test");
messageTaskRequest.setTaskType(NoticeConstants.TaskType.API_DEFINITION_TASK);
messageTaskRequest.setEvent(NoticeConstants.Event.CREATE);
List<String> userIds = new ArrayList<>();
userIds.add("CREATOR");
userIds.add("CREATE_USER");
userIds.add("FOLLOW_PEOPLE");
messageTaskRequest.setReceiverIds(userIds);
messageTaskRequest.setRobotId("test_message_robot2");
messageTaskRequest.setEnable(false);
messageTaskRequest.setTemplate("发送消息测试");
//messageTaskRequest.setDefaultTemplate("发送消息测试");
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/notice/message/task/save")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
@ -351,4 +398,5 @@ public class NoticeMessageTaskControllerTests extends BaseTest {
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
Assertions.assertEquals(100200, resultHolder.getCode());
}
}

View File

@ -0,0 +1,60 @@
package io.metersphere.project.controller.param;
import io.metersphere.project.dto.MessageTaskDTO;
import io.metersphere.project.service.CleanupMessageTaskService;
import io.metersphere.sdk.constants.SessionConstants;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.junit.jupiter.api.*;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@AutoConfigureMockMvc
public class CleanupMessageTaskResourceTests extends BaseTest {
@Resource
private CleanupMessageTaskService resourceService;
@Test
@Order(1)
@Sql(scripts = {"/dml/init_message_task.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void testCleanupResource() throws Exception {
List<MessageTaskDTO> list = getList();
if (CollectionUtils.isNotEmpty(list)) {
resourceService.deleteResources("test");
}
}
@Test
@Order(2)
public void testCleanupReportResource() throws Exception {
resourceService.cleanReportResources("test");
}
private List<MessageTaskDTO> getList() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/test")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), MessageTaskDTO.class);
}
}

View File

@ -0,0 +1,16 @@
# 插入测试数据
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES
('test1', null, 'organization-message-test', '默认项目1', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES
('test', null, 'organization-message-test', '默认项目', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);
replace INTO project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) values ('message_task_robot1', 'test', '测试机器人1', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
replace INTO message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
VALUES ('message_task_id1', 'CASE_EXECUTE_FAKE_ERROR', 'FOLLOW_PEOPLE', 'message_task_robot1', 'API_DEFINITION_TASK', 'NONE', 'test', true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, true, true, 'message.title.api_definition_task_case_delete');
replace INTO message_task_blob(id, template) VALUES ('message_task_id1', 'message.api_definition_task_case_execute');

View File

@ -16,6 +16,8 @@ INSERT INTO user(id, name, email, password, create_time, update_time, language,
('project-message-user-6', 'project-message-user-6', 'project-message-member6@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', 0),
('project-message-user-7', 'project-message-user-7', 'project-message-member7@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', 0),
('project-message-user-8', 'project-message-user-8', 'project-message-member8@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', 0),
('project-message-user-9', 'project-message-user-9', 'project-message-member9@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', 0),
('project-message-user-10', 'project-message-user-10', 'project-message-member10@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', 0),
('project-message-user-del', 'project-message-user-del', 'project-message-member-del@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', 1);
INSERT INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user) VALUES
@ -26,8 +28,9 @@ INSERT INTO user_role_relation (id, user_id, role_id, source_id, organization_id
(UUID(), 'project-message-user-5', 'project_member', 'project-message-test', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin'),
(UUID(), 'project-message-user-6', 'project_member', 'project-message-test', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin'),
(UUID(), 'project-message-user-7', 'project_member', 'project-message-test-1', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin'),
(UUID(), 'project-message-user-8', 'project_member', 'project-message-test-1', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin');
(UUID(), 'project-message-user-8', 'project_member', 'project-message-test-1', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin'),
(UUID(), 'project-message-user-9', 'project_member', 'project-message-test-1', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin'),
(UUID(), 'project-message-user-10', 'project_member', 'project-message-test-1', 'organization-message-test', UNIX_TIMESTAMP() * 1000, 'admin');

View File

@ -88,6 +88,9 @@ public class OperationLogModule {
public static final String PROJECT_MANAGEMENT_ENVIRONMENT = "PROJECT_MANAGEMENT_ENVIRONMENT";
// 项目管理-版本管理
public static final String PROJECT_MANAGEMENT_PERMISSION_VERSION = "PROJECT_MANAGEMENT_PERMISSION_VERSION";
//项目管理-消息设置
public static final String PROJECT_MANAGEMENT_MESSAGE = "PROJECT_MANAGEMENT_MESSAGE";
}

View File

@ -16,6 +16,7 @@ public class MessageDetail implements Serializable {
private String type;
private String testId;
private Long createTime;
private String subject;
private String template;
private String appKey;
private String appSecret;

View File

@ -1,36 +1,95 @@
package io.metersphere.system.notice.constants;
import io.swagger.v3.oas.annotations.media.Schema;
public interface NoticeConstants {
interface TaskType {
String JENKINS_TASK = "JENKINS_TASK";
//测试计划模块的任务
@Schema(description = "message.test_plan_task")
String TEST_PLAN_TASK = "TEST_PLAN_TASK";
String CASE_REVIEW_TASK = "CASE_REVIEW_TASK";
String FUNCTIONAL_CASE_TASK = "FUNCTIONAL_CASE_TASK";
@Schema(description = "message.schedule_task")
String TEST_PLAN_SCHEDULE_TASK = "TEST_PLAN_SCHEDULE_TASK";
@Schema(description = "message.report_task")
String TEST_PLAN_REPORT_TASK = "TEST_PLAN_REPORT_TASK";
//缺陷管理模块的任务
@Schema(description = "message.bug_task")
String BUG_TASK = "BUG_TASK";
String TRACK_HOME_TASK = "TRACK_HOME_TASK";
String TRACK_REPORT_TASK = "TRACK_REPORT_TASK";
String DEFECT_TASK = "DEFECT_TASK";
String SWAGGER_TASK = "SWAGGER_TASK";
String API_SCENARIO_TASK = "API_SCENARIO_TASK";
@Schema(description = "message.bug_task")
String BUG_TASK_AT = "BUG_TASK_AT";
@Schema(description = "message.bug_sync_task")
String BUG_SYNC_TASK = "BUG_SYNC_TASK";
@Schema(description = "message.schedule_task")
String BUG_SCHEDULE_TASK = "BUG_SCHEDULE_TASK";
//用例管理模块的任务
@Schema(description = "message.functional_case_task")
String FUNCTIONAL_CASE_TASK = "FUNCTIONAL_CASE_TASK";
@Schema(description = "message.functional_case_task")
String FUNCTIONAL_CASE_TASK_AT = "FUNCTIONAL_CASE_TASK_AT";
@Schema(description = "message.case_review_task")
String CASE_REVIEW_TASK = "CASE_REVIEW_TASK";
//接口测试模块的任务
@Schema(description = "message.api_definition_task")
String API_DEFINITION_TASK = "API_DEFINITION_TASK";
@Schema(description = "message.api_scenario_task")
String API_SCENARIO_TASK = "API_SCENARIO_TASK";
@Schema(description = "message.schedule_task")
String API_SCHEDULE_TASK = "API_SCHEDULE_TASK";
String API_HOME_TASK = "API_HOME_TASK";
@Schema(description = "message.report_task")
String API_REPORT_TASK = "API_REPORT_TASK";
String LOAD_REPORT_TASK = "LOAD_REPORT_TASK";
String LOAD_TEST_TASK = "LOAD_TEST_TASK";
//UI测试模块的任务
@Schema(description = "message.ui_scenario_task")
String UI_SCENARIO_TASK = "UI_SCENARIO_TASK";
String UI_DEFINITION_TASK = "UI_DEFINITION_TASK";
String UI_HOME_TASK = "UI_HOME_TASK";
@Schema(description = "message.report_task")
String UI_REPORT_TASK = "UI_REPORT_TASK";
String ENV_TASK = "ENV_TASK";
@Schema(description = "message.schedule_task")
String UI_SCHEDULE_TASK = "UI_SCHEDULE_TASK";
//性能测试模块的任务
@Schema(description = "message.load_test_task")
String LOAD_TEST_TASK = "LOAD_TEST_TASK";
@Schema(description = "message.report_task")
String LOAD_REPORT_TASK = "LOAD_REPORT_TASK";
@Schema(description = "message.schedule_task")
String LOAD_SCHEDULE_TASK = "LOAD_SCHEDULE_TASK";
//jenkins任务
@Schema(description = "message.jenkins_task")
String JENKINS_TASK = "JENKINS_TASK";
}
interface Mode {
String API = "API";
String SCHEDULE = "SCHEDULE";
}
interface Module {
@Schema(description = "message.test_plan_management")
String TEST_PLAN_MANAGEMENT = "TEST_PLAN_MANAGEMENT";
@Schema(description = "message.bug_management")
String BUG_MANAGEMENT = "BUG_MANAGEMENT";
@Schema(description = "message.case_management")
String CASE_MANAGEMENT = "CASE_MANAGEMENT";
@Schema(description = "message.api_test_management")
String API_TEST_MANAGEMENT = "API_TEST_MANAGEMENT";
@Schema(description = "message.ui_test_management")
String UI_TEST_MANAGEMENT = "UI_TEST_MANAGEMENT";
@Schema(description = "message.load_test_management")
String LOAD_TEST_MANAGEMENT = "LOAD_TEST_MANAGEMENT";
@Schema(description = "message.jenkins_task_management")
String JENKINS_TASK_MANAGEMENT = "JENKINS_TASK_MANAGEMENT";
}
interface Type {
String MAIL = "MAIL";
String IN_SITE = "IN_SITE";
@ -42,34 +101,310 @@ public interface NoticeConstants {
}
interface Event {
String EXECUTE_SUCCESSFUL = "EXECUTE_SUCCESSFUL";
String EXECUTE_FAILED = "EXECUTE_FAILED";
String EXECUTE_COMPLETED = "EXECUTE_COMPLETED";
@Schema(description = "message.create")
String CREATE = "CREATE";
String UPDATE = "UPDATE";
String DELETE = "DELETE";
String COMPLETE = "COMPLETE";
String REVIEW = "REVIEW";
@Schema(description = "message.update")
String UPDATE = "UPDATE";
@Schema(description = "message.delete")
String DELETE = "DELETE";
@Schema(description = "message.execute_completed")
String EXECUTE_COMPLETED = "EXECUTE_COMPLETED";
@Schema(description = "message.comment")
String COMMENT = "COMMENT";
@Schema(description = "message.execute_review")
String EXECUTE_REVIEW = "EXECUTE_REVIEW";
@Schema(description = "message.review_completed")
String REVIEW_COMPLETED = "REVIEW_COMPLETED";
@Schema(description = "message.case_create")
String CASE_CREATE = "CASE_CREATE";
@Schema(description = "message.case_update")
String CASE_UPDATE = "CASE_UPDATE";
@Schema(description = "message.case_delete")
String CASE_DELETE = "CASE_DELETE";
String MOCK_CREATE = "MOCK_CREATE";
String MOCK_UPDATE = "MOCK_UPDATE";
String MOCK_DELETE = "MOCK_DELETE";
@Schema(description = "message.case_execute_successful")
String CASE_EXECUTE_SUCCESSFUL = "CASE_EXECUTE_SUCCESSFUL";
String COMMENT = "COMMENT";
String IMPORT = "IMPORT";
@Schema(description = "message.case_execute_fake_error")
String CASE_EXECUTE_FAKE_ERROR = "CASE_EXECUTE_FAKE_ERROR";
String CLOSE_SCHEDULE = "CLOSE_SCHEDULE";
@Schema(description = "message.case_execute_failed")
String CASE_EXECUTE_FAILED = "CASE_EXECUTE_FAILED";
@Schema(description = "message.scenario_execute_successful")
String SCENARIO_EXECUTE_SUCCESSFUL = "SCENARIO_EXECUTE_SUCCESSFUL";
@Schema(description = "message.scenario_execute_fake_error")
String SCENARIO_EXECUTE_FAKE_ERROR = "SCENARIO_EXECUTE_FAKE_ERROR";
@Schema(description = "message.scenario_execute_failed")
String SCENARIO_EXECUTE_FAILED = "SCENARIO_EXECUTE_FAILED";
@Schema(description = "message.execute_successful")
String EXECUTE_SUCCESSFUL = "EXECUTE_SUCCESSFUL";
@Schema(description = "message.execute_failed")
String EXECUTE_FAILED = "EXECUTE_FAILED";
}
interface RelatedUser {
@Schema(description = "message.create_user")
String CREATE_USER = "CREATE_USER";//创建人
String EXECUTOR = "EXECUTOR";//负责人(评审人
String MAINTAINER = "MAINTAINER";//维护人
@Schema(description = "message.follow_people")
String FOLLOW_PEOPLE = "FOLLOW_PEOPLE";//关注人
String PROCESSOR = "PROCESSOR";//处理人
@Schema(description = "message.operator")
String OPERATOR = "OPERATOR"; //操作人
}
interface TemplateText {
@Schema(description = "message.test_plan_task_create")
String TEST_PLAN_TASK_CREATE = "TEST_PLAN_TASK_CREATE"; // ${OPERATOR}创建了测试计划:${name}
@Schema(description = "message.test_plan_task_update")
String TEST_PLAN_TASK_UPDATE = "TEST_PLAN_TASK_UPDATE";// ${OPERATOR}更新了测试计划:${name}
@Schema(description = "message.test_plan_task_delete")
String TEST_PLAN_TASK_DELETE = "TEST_PLAN_TASK_DELETE";//${OPERATOR}删除了测试计划:${name}
@Schema(description = "message.test_plan_task_execute_completed")
String TEST_PLAN_TASK_EXECUTE_COMPLETED = "TEST_PLAN_TASK_EXECUTE_COMPLETED";//${OPERATOR}执行完成了测试计划:${name}
@Schema(description = "message.schedule_execute_completed_test_plan")
String TEST_PLAN_SCHEDULE_TASK_EXECUTE_COMPLETED = "TEST_PLAN_SCHEDULE_TASK_EXECUTE_COMPLETED";//${OPERATOR}通过定时任务执行了测试计划:${name}
@Schema(description = "message.test_plan_report_task_delete")
String TEST_PLAN_REPORT_TASK_DELETE = "TEST_PLAN_REPORT_TASK_DELETE";//${OPERATOR}删除了测试计划报告:${name}
@Schema(description = "message.bug_task_create")
String BUG_TASK_CREATE = "BUG_TASK_CREATE"; // ${OPERATOR}创建了缺陷:${title}
@Schema(description = "message.bug_task_update")
String BUG_TASK_UPDATE = "BUG_TASK_UPDATE";//${OPERATOR}更新了缺陷:${title}
@Schema(description = "message.bug_task_delete")
String BUG_TASK_DELETE = "BUG_TASK_DELETE";//${OPERATOR}删除了缺陷:${title}
@Schema(description = "message.bug_task_comment")
String BUG_TASK_COMMENT = "BUG_TASK_COMMENT";//${OPERATOR}评论了你的缺陷:${title}
@Schema(description = "message.bug_task_at_comment")
String BUG_TASK_AT_COMMENT = "BUG_TASK_AT_COMMENT";//${OPERATOR}评论了缺陷:${title} @了你
@Schema(description = "message.bug_sync_task_execute_completed")
String BUG_SYNC_TASK_EXECUTE_COMPLETED = "BUG_SYNC_TASK_EXECUTE_COMPLETED";//${OPERATOR}同步了${total}条缺陷
@Schema(description = "message.bug_schedule_task_execute_completed")
String BUG_SCHEDULE_TASK_EXECUTE_COMPLETED = "BUG_SCHEDULE_TASK_EXECUTE_COMPLETED";//${OPERATOR}通过定时任务同步了${total}条缺陷
@Schema(description = "message.functional_case_task_create")
String FUNCTIONAL_CASE_TASK_CREATE = "FUNCTIONAL_CASE_TASK_CREATE"; // ${OPERATOR}创建了功能用例:${name}
@Schema(description = "message.functional_case_task_update")
String FUNCTIONAL_CASE_TASK_UPDATE = "FUNCTIONAL_CASE_TASK_UPDATE";//${OPERATOR}更新了功能用例:${name}
@Schema(description = "message.functional_case_task_delete")
String FUNCTIONAL_CASE_TASK_DELETE = "FUNCTIONAL_CASE_TASK_DELETE";//${OPERATOR}删除了功能用例:${name}
@Schema(description = "message.functional_case_task_comment")
String FUNCTIONAL_CASE_TASK_COMMENT = "FUNCTIONAL_CASE_TASK_COMMENT";//${OPERATOR}评论了你的功能用例:${name}
@Schema(description = "message.functional_case_task_at_comment")
String FUNCTIONAL_CASE_TASK_AT_COMMENT = "FUNCTIONAL_CASE_TASK_AT_COMMENT";//${OPERATOR}评论了功能用例:${name} @了你
@Schema(description = "message.case_review_task_create")
String CASE_REVIEW_TASK_CREATE = "CASE_REVIEW_TASK_CREATE"; // ${OPERATOR}创建了用例评审:${name}
@Schema(description = "message.case_review_task_update")
String CASE_REVIEW_TASK_UPDATE = "CASE_REVIEW_TASK_UPDATE";//${OPERATOR}更新了用例评审:${name}
@Schema(description = "message.case_review_task_delete")
String CASE_REVIEW_TASK_DELETE = "CASE_REVIEW_TASK_DELETE";//${OPERATOR}删除了用例评审:${name}
@Schema(description = "message.case_review_task_execute_review")
String CASE_REVIEW_TASK_EXECUTE_REVIEW = "CASE_REVIEW_TASK_EXECUTE_REVIEW";//${OPERATOR}评审了功能用例:${name}
@Schema(description = "message.case_review_task_review_completed")
String CASE_REVIEW_TASK_REVIEW_COMPLETED = "CASE_REVIEW_TASK_REVIEW_COMPLETED";//${OPERATOR}完成了用例评审:${name}
@Schema(description = "message.api_definition_task_create")
String API_DEFINITION_TASK_CREATE = "API_DEFINITION_TASK_CREATE";//${OPERATOR}创建了接口文档:${name}
@Schema(description = "message.api_definition_task_update")
String API_DEFINITION_TASK_UPDATE = "API_DEFINITION_TASK_UPDATE";//${OPERATOR}更新了接口文档:${name}
@Schema(description = "message.api_definition_task_delete")
String API_DEFINITION_TASK_DELETE = "API_DEFINITION_TASK_DELETE";//${OPERATOR}删除了接口文档:${name}
@Schema(description = "message.api_definition_task_case_create")
String API_DEFINITION_TASK_CASE_CREATE = "API_DEFINITION_TASK_CASE_CREATE";//${OPERATOR}创建了接口用例:${name}
@Schema(description = "message.api_definition_task_case_update")
String API_DEFINITION_TASK_CASE_UPDATE = "API_DEFINITION_TASK_CASE_UPDATE";//${OPERATOR}更新了接口用例:${name}
@Schema(description = "message.api_definition_task_case_delete")
String API_DEFINITION_TASK_CASE_DELETE = "API_DEFINITION_TASK_CASE_DELETE";//${OPERATOR}删除了接口用例:${name}
@Schema(description = "message.api_definition_task_case_execute")
String API_DEFINITION_TASK_CASE_EXECUTE_SUCCESSFUL = "API_DEFINITION_TASK_CASE_EXECUTE_SUCCESSFUL";//${OPERATOR}执行了接口用例:${name}
@Schema(description = "message.api_definition_task_case_execute")
String API_DEFINITION_TASK_CASE_EXECUTE_FAKE_ERROR = "API_DEFINITION_TASK_CASE_EXECUTE_FAKE_ERROR";//${OPERATOR}执行了接口用例:${name}
@Schema(description = "message.api_definition_task_case_execute")
String API_DEFINITION_TASK_CASE_EXECUTE_FAILED = "API_DEFINITION_TASK_CASE_EXECUTE_FAILED";//${OPERATOR}执行了接口用例:${name}
@Schema(description = "message.api_scenario_task_create")
String API_SCENARIO_TASK_CREATE = "API_SCENARIO_TASK_CREATE";//${OPERATOR}创建了接口场景:${name}
@Schema(description = "message.api_scenario_task_update")
String API_SCENARIO_TASK_UPDATE = "API_SCENARIO_TASK_UPDATE";//${OPERATOR}更新了接口场景:${name}
@Schema(description = "message.api_scenario_task_delete")
String API_SCENARIO_TASK_DELETE = "API_SCENARIO_TASK_DELETE";//${OPERATOR}删除了接口场景:${name}
@Schema(description = "message.api_scenario_task_scenario_execute")
String API_SCENARIO_TASK_SCENARIO_EXECUTE_SUCCESSFUL = "API_SCENARIO_TASK_SCENARIO_EXECUTE_SUCCESSFUL";//${OPERATOR}执行了接口场景:${name}
@Schema(description = "message.api_scenario_task_scenario_execute")
String API_SCENARIO_TASK_SCENARIO_EXECUTE_FAKE_ERROR = "API_SCENARIO_TASK_SCENARIO_EXECUTE_FAKE_ERROR";//${OPERATOR}执行了接口场景:${name}
@Schema(description = "message.api_scenario_task_scenario_execute")
String API_SCENARIO_TASK_SCENARIO_EXECUTE_FAILED = "API_SCENARIO_TASK_SCENARIO_EXECUTE_FAILED";//${OPERATOR}执行了接口场景:${name}
@Schema(description = "message.api_schedule_task_execute_completed")
String API_SCHEDULE_TASK_EXECUTE_COMPLETED = "API_SCHEDULE_TASK_EXECUTE_COMPLETED";//${OPERATOR}通过定时任务执行了接口场景:${name}
@Schema(description = "message.api_report_task_delete")
String API_REPORT_TASK_DELETE = "API_REPORT_TASK_DELETE";//${OPERATOR}删除了接口报告:${name}
@Schema(description = "message.ui_scenario_task_create")
String UI_SCENARIO_TASK_CREATE = "UI_SCENARIO_TASK_CREATE";//${OPERATOR}创建了UI用例:${name}
@Schema(description = "message.ui_scenario_task_update")
String UI_SCENARIO_TASK_UPDATE = "UI_SCENARIO_TASK_UPDATE";//${OPERATOR}更新了UI用例:${name}
@Schema(description = "message.ui_scenario_task_delete")
String UI_SCENARIO_TASK_DELETE = "UI_SCENARIO_TASK_DELETE";//${OPERATOR}删除了UI用例:${name}
@Schema(description = "message.ui_scenario_task_execute")
String UI_SCENARIO_TASK_EXECUTE_SUCCESSFUL = "UI_SCENARIO_TASK_EXECUTE_SUCCESSFUL";//${OPERATOR}执行了UI用例:${name}
@Schema(description = "message.ui_scenario_task_execute")
String UI_SCENARIO_TASK_EXECUTE_FAILED = "UI_SCENARIO_TASK_EXECUTE_FAILED";//${OPERATOR}执行了UI用例:${name}
@Schema(description = "message.ui_schedule_task_execute_completed")
String UI_SCHEDULE_TASK_EXECUTE_COMPLETED = "UI_SCHEDULE_TASK_EXECUTE_COMPLETED";//${OPERATOR}通过定时任务执行了UI用例:${name}
@Schema(description = "message.ui_report_task_delete")
String UI_REPORT_TASK_DELETE = "UI_REPORT_TASK_DELETE";//${OPERATOR}删除了UI报告:${name}
@Schema(description = "message.load_test_task_create")
String LOAD_TEST_TASK_CREATE = "LOAD_TEST_TASK_CREATE";//${OPERATOR}创建了性能用例:${name}
@Schema(description = "message.load_test_task_update")
String LOAD_TEST_TASK_UPDATE = "LOAD_TEST_TASK_UPDATE";//${OPERATOR}更新了性能用例:${name}
@Schema(description = "message.load_test_task_delete")
String LOAD_TEST_TASK_DELETE = "LOAD_TEST_TASK_DELETE";//${OPERATOR}删除了性能用例:${name}
@Schema(description = "message.load_test_task_execute_completed")
String LOAD_TEST_TASK_EXECUTE_COMPLETED = "LOAD_TEST_TASK_EXECUTE_COMPLETED";//${OPERATOR}执行了性能用例:${name}
@Schema(description = "message.load_schedule_task_execute_completed")
String LOAD_SCHEDULE_TASK_EXECUTE_COMPLETED = "LOAD_SCHEDULE_TASK_EXECUTE_COMPLETED";//${OPERATOR}通过定时任务执行了性能用例:${name}
@Schema(description = "message.load_report_task_delete")
String LOAD_REPORT_TASK_DELETE = "LOAD_REPORT_TASK_DELETE";//${OPERATOR}删除了性能报告:${name}
@Schema(description = "message.jenkins_task_execute_successful")
String JENKINS_TASK_EXECUTE_SUCCESSFUL = "JENKINS_TASK_EXECUTE_SUCCESSFUL";//Jenkins执行了场景用例:${name}
@Schema(description = "message.jenkins_task_execute_failed")
String JENKINS_TASK_EXECUTE_FAILED = "JENKINS_TASK_EXECUTE_FAILED";//Jenkins执行了测试计划:${name}
}
interface TemplateTitle {
@Schema(description = "message.title.test_plan_task_create")
String TEST_PLAN_TASK_CREATE = "TEST_PLAN_TASK_CREATE"; // 测试计划创建通知
@Schema(description = "message.title.test_plan_task_update")
String TEST_PLAN_TASK_UPDATE = "TEST_PLAN_TASK_UPDATE";// 测试计划更新通知
@Schema(description = "message.title.test_plan_task_delete")
String TEST_PLAN_TASK_DELETE = "TEST_PLAN_TASK_DELETE";//测试计划删除通知
@Schema(description = "message.title.test_plan_task_execute_completed")//测试计划执行完成通知
String TEST_PLAN_TASK_EXECUTE_COMPLETED = "TEST_PLAN_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.test_plan_task_execute_completed")//测试计划执行完成通知
String TEST_PLAN_SCHEDULE_TASK_EXECUTE_COMPLETED = "TEST_PLAN_SCHEDULE_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.test_plan_report_task_delete")//测试计划报告删除通知
String TEST_PLAN_REPORT_TASK_DELETE = "TEST_PLAN_REPORT_TASK_DELETE";
@Schema(description = "message.title.bug_task_create") //缺陷创建通知
String BUG_TASK_CREATE = "BUG_TASK_CREATE";
@Schema(description = "message.title.bug_task_update")//缺陷更新通知
String BUG_TASK_UPDATE = "BUG_TASK_UPDATE";
@Schema(description = "message.title.bug_task_delete")//缺陷删除通知
String BUG_TASK_DELETE = "BUG_TASK_DELETE";
@Schema(description = "message.title.bug_task_comment")//缺陷评论通知
String BUG_TASK_COMMENT = "BUG_TASK_COMMENT";
@Schema(description = "message.title.bug_task_comment")//缺陷评论通知
String BUG_TASK_AT_COMMENT = "BUG_TASK_AT_COMMENT";
@Schema(description = "message.title.bug_sync_task_execute_completed")//同步缺陷执行完成通知
String BUG_SYNC_TASK_EXECUTE_COMPLETED = "BUG_SYNC_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.bug_sync_task_execute_completed")//同步缺陷执行完成通知
String BUG_SCHEDULE_TASK_EXECUTE_COMPLETED = "BUG_SCHEDULE_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.functional_case_task_create")//功能用例创建通知
String FUNCTIONAL_CASE_TASK_CREATE = "FUNCTIONAL_CASE_TASK_CREATE";
@Schema(description = "message.title.functional_case_task_update")//功能用例更新通知
String FUNCTIONAL_CASE_TASK_UPDATE = "FUNCTIONAL_CASE_TASK_UPDATE";
@Schema(description = "message.title.functional_case_task_delete")//功能用例删除通知
String FUNCTIONAL_CASE_TASK_DELETE = "FUNCTIONAL_CASE_TASK_DELETE";
@Schema(description = "message.title.functional_case_task_comment")//功能用例评论通知
String FUNCTIONAL_CASE_TASK_COMMENT = "FUNCTIONAL_CASE_TASK_COMMENT";
@Schema(description = "message.title.functional_case_task_comment")//功能用例评论通知
String FUNCTIONAL_CASE_TASK_AT_COMMENT = "FUNCTIONAL_CASE_TASK_AT_COMMENT";
@Schema(description = "message.title.case_review_task_create")//用例评审创建通知
String CASE_REVIEW_TASK_CREATE = "CASE_REVIEW_TASK_CREATE";
@Schema(description = "message.title.case_review_task_update")//用例评审更新通知
String CASE_REVIEW_TASK_UPDATE = "CASE_REVIEW_TASK_UPDATE";
@Schema(description = "message.title.case_review_task_delete")//用例评审删除通知
String CASE_REVIEW_TASK_DELETE = "CASE_REVIEW_TASK_DELETE";
@Schema(description = "message.title.case_review_task_execute_review")//用例评审执行通知
String CASE_REVIEW_TASK_EXECUTE_REVIEW = "CASE_REVIEW_TASK_EXECUTE_REVIEW";
@Schema(description = "message.title.case_review_task_review_completed")//用例评审评审完成通知
String CASE_REVIEW_TASK_REVIEW_COMPLETED = "CASE_REVIEW_TASK_REVIEW_COMPLETED";
@Schema(description = "message.title.api_definition_task_create")//接口文档创建通知
String API_DEFINITION_TASK_CREATE = "API_DEFINITION_TASK_CREATE";
@Schema(description = "message.title.api_definition_task_update")//接口文档更新通知
String API_DEFINITION_TASK_UPDATE = "API_DEFINITION_TASK_UPDATE";
@Schema(description = "message.title.api_definition_task_delete")//接口文档删除通知
String API_DEFINITION_TASK_DELETE = "API_DEFINITION_TASK_DELETE";
@Schema(description = "message.title.api_definition_task_case_create")//接口用例创建通知
String API_DEFINITION_TASK_CASE_CREATE = "API_DEFINITION_TASK_CASE_CREATE";
@Schema(description = "message.title.api_definition_task_case_update")//接口用例更新通知
String API_DEFINITION_TASK_CASE_UPDATE = "API_DEFINITION_TASK_CASE_UPDATE";
@Schema(description = "message.title.api_definition_task_case_delete")//接口用例删除通知
String API_DEFINITION_TASK_CASE_DELETE = "API_DEFINITION_TASK_CASE_DELETE";
@Schema(description = "message.title.api_definition_task_case_execute_successful")//接口用例执行成功通知
String API_DEFINITION_TASK_CASE_EXECUTE_SUCCESSFUL = "API_DEFINITION_TASK_CASE_EXECUTE_SUCCESSFUL";
@Schema(description = "message.title.api_definition_task_case_execute_fake_error")//接口用例执行误报通知
String API_DEFINITION_TASK_CASE_EXECUTE_FAKE_ERROR = "API_DEFINITION_TASK_CASE_EXECUTE_FAKE_ERROR";
@Schema(description = "message.title.api_definition_task_case_execute_failed")//接口用例执行失败通知
String API_DEFINITION_TASK_CASE_EXECUTE_FAILED = "API_DEFINITION_TASK_CASE_EXECUTE_FAILED";
@Schema(description = "message.title.api_scenario_task_create")//接口场景创建通知
String API_SCENARIO_TASK_CREATE = "API_SCENARIO_TASK_CREATE";
@Schema(description = "message.title.api_scenario_task_update")//接口场景更新通知
String API_SCENARIO_TASK_UPDATE = "API_SCENARIO_TASK_UPDATE";
@Schema(description = "message.title.api_scenario_task_delete")//接口场景删除通知
String API_SCENARIO_TASK_DELETE = "API_SCENARIO_TASK_DELETE";
@Schema(description = "message.title.api_scenario_task_scenario_execute_successful")//接口场景执行成功通知
String API_SCENARIO_TASK_SCENARIO_EXECUTE_SUCCESSFUL = "API_SCENARIO_TASK_SCENARIO_EXECUTE_SUCCESSFUL";
@Schema(description = "message.title.api_scenario_task_scenario_execute_fake_error")//接口场景执误报通知
String API_SCENARIO_TASK_SCENARIO_EXECUTE_FAKE_ERROR = "API_SCENARIO_TASK_SCENARIO_EXECUTE_FAKE_ERROR";
@Schema(description = "message.title.api_scenario_task_scenario_execute_failed")//接口场景执行失败通知
String API_SCENARIO_TASK_SCENARIO_EXECUTE_FAILED = "API_SCENARIO_TASK_SCENARIO_EXECUTE_FAILED";
@Schema(description = "message.title.api_schedule_task_execute_completed")//接口场景执行完成通知
String API_SCHEDULE_TASK_EXECUTE_COMPLETED = "API_SCHEDULE_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.api_report_task_delete")//接口报告删除通知
String API_REPORT_TASK_DELETE = "API_REPORT_TASK_DELETE";
@Schema(description = "message.title.ui_scenario_task_create")//UI用例创建通知
String UI_SCENARIO_TASK_CREATE = "UI_SCENARIO_TASK_CREATE";
@Schema(description = "message.title.ui_scenario_task_update")//UI用例更新通知
String UI_SCENARIO_TASK_UPDATE = "UI_SCENARIO_TASK_UPDATE";
@Schema(description = "message.title.ui_scenario_task_delete")//UI用例删除通知
String UI_SCENARIO_TASK_DELETE = "UI_SCENARIO_TASK_DELETE";
@Schema(description = "message.title.ui_scenario_task_execute_successful")//UI用例执行成功通知
String UI_SCENARIO_TASK_EXECUTE_SUCCESSFUL = "UI_SCENARIO_TASK_EXECUTE_SUCCESSFUL";
@Schema(description = "message.title.ui_scenario_task_execute_failed")//UI用例执行失败通知
String UI_SCENARIO_TASK_EXECUTE_FAILED = "UI_SCENARIO_TASK_EXECUTE_FAILED";
@Schema(description = "message.title.ui_schedule_task_execute_completed")//UI执行完成通知
String UI_SCHEDULE_TASK_EXECUTE_COMPLETED = "UI_SCHEDULE_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.ui_report_task_delete")//UI报告删除通知
String UI_REPORT_TASK_DELETE = "UI_REPORT_TASK_DELETE";
@Schema(description = "message.title.load_test_task_create")//性能用例创建通知
String LOAD_TEST_TASK_CREATE = "LOAD_TEST_TASK_CREATE";
@Schema(description = "message.title.load_test_task_update")//性能用例更新通知
String LOAD_TEST_TASK_UPDATE = "LOAD_TEST_TASK_UPDATE";
@Schema(description = "message.title.load_test_task_delete")//性能用例删除通知
String LOAD_TEST_TASK_DELETE = "LOAD_TEST_TASK_DELETE";
@Schema(description = "message.title.load_test_task_execute_completed")//性能用例执行完成通知
String LOAD_TEST_TASK_EXECUTE_COMPLETED = "LOAD_TEST_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.load_test_task_execute_completed")//性能用例执行完成通知
String LOAD_SCHEDULE_TASK_EXECUTE_COMPLETED = "LOAD_SCHEDULE_TASK_EXECUTE_COMPLETED";
@Schema(description = "message.title.load_report_task_delete")//性能报告删除通知
String LOAD_REPORT_TASK_DELETE = "LOAD_REPORT_TASK_DELETE";
@Schema(description = "message.title.jenkins_task_execute_successful")//Jenkins任务执行成功通知
String JENKINS_TASK_EXECUTE_SUCCESSFUL = "JENKINS_TASK_EXECUTE_SUCCESSFUL";
@Schema(description = "message.title.jenkins_task_execute_failed")//Jenkins任务执行失败通知
String JENKINS_TASK_EXECUTE_FAILED = "JENKINS_TASK_EXECUTE_FAILED";
}
}

View File

@ -35,7 +35,6 @@ import org.apache.commons.text.StringSubstitutor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
public abstract class AbstractNoticeSender implements NoticeSender {
@ -62,17 +61,6 @@ public abstract class AbstractNoticeSender implements NoticeSender {
handleCustomFields(noticeModel);
// 处理 userIds 中包含的特殊值
noticeModel.setReceivers(getRealUserIds(messageDetail, noticeModel, messageDetail.getEvent()));
//TODOapiReceiver特殊处理v2接口同步的通知v3这里待讨论
/*String apiSpecialType = (String) noticeModel.getParamMap().get("apiSpecialType");
if (apiSpecialType != null && apiSpecialType.equals("API_SPECIAL")) {
String specialReceivers = (String) noticeModel.getParamMap().get("specialReceivers");
List list = JSON.parseArray(specialReceivers);
if (CollectionUtils.isNotEmpty(list)) {
for (Object o : list) {
noticeModel.getReceivers().add(new Receiver(o.toString(), NotificationConstants.Type.MENTIONED_ME.name()));
}
}
}*/
// 如果配置了模版就直接使用模版
if (StringUtils.isNotBlank(messageDetail.getTemplate())) {
return getContent(messageDetail.getTemplate(), noticeModel.getParamMap());
@ -108,9 +96,6 @@ public abstract class AbstractNoticeSender implements NoticeSender {
if (value instanceof String && StringUtils.isNotEmpty((String) value)) {
String v = StringUtils.unwrap((String) value, "\"");
noticeModel.getParamMap().put(customField.getName(), v); // 处理人
if (StringUtils.equals(customField.getName(), "处理人")) {
noticeModel.getParamMap().put(NoticeConstants.RelatedUser.PROCESSOR, v); // 处理人
}
}
}
}
@ -152,27 +137,16 @@ public abstract class AbstractNoticeSender implements NoticeSender {
Map<String, Object> paramMap = noticeModel.getParamMap();
for (String userId : messageDetail.getReceiverIds()) {
switch (userId) {
case NoticeConstants.RelatedUser.EXECUTOR -> {
if (StringUtils.equals(NoticeConstants.Event.CREATE, event)) {
getRelateUsers(toUsers, paramMap);
}
if (paramMap.containsKey(NoticeConstants.RelatedUser.EXECUTOR)) {
toUsers.add(new Receiver((String) paramMap.get(NoticeConstants.RelatedUser.EXECUTOR), NotificationConstants.Type.SYSTEM_NOTICE.name()));
}
}
case NoticeConstants.RelatedUser.CREATE_USER -> {
String createUser = (String) paramMap.get(NoticeConstants.RelatedUser.CREATE_USER);
if (StringUtils.isNotBlank(createUser)) {
toUsers.add(new Receiver(createUser, NotificationConstants.Type.SYSTEM_NOTICE.name()));
}
}
case NoticeConstants.RelatedUser.MAINTAINER -> {
if (StringUtils.equals(NoticeConstants.Event.COMMENT, event)) {
getRelateUsers(toUsers, paramMap);
if (paramMap.containsKey(NoticeConstants.RelatedUser.MAINTAINER)) {
toUsers.add(new Receiver((String) paramMap.get(NoticeConstants.RelatedUser.MAINTAINER), NotificationConstants.Type.SYSTEM_NOTICE.name()));
}
case NoticeConstants.RelatedUser.OPERATOR -> {
String operator = (String) paramMap.get(NoticeConstants.RelatedUser.OPERATOR);
if (StringUtils.isNotBlank(operator)) {
toUsers.add(new Receiver(operator, NotificationConstants.Type.SYSTEM_NOTICE.name()));
}
}
case NoticeConstants.RelatedUser.FOLLOW_PEOPLE -> {
@ -183,14 +157,17 @@ public abstract class AbstractNoticeSender implements NoticeSender {
LogUtils.error("查询关注人失败: ", e);
}
}
case NoticeConstants.RelatedUser.PROCESSOR -> {
Object value = paramMap.get(NoticeConstants.RelatedUser.PROCESSOR); // 处理人
if (!Objects.isNull(value)) {
toUsers.add(new Receiver(value.toString(), NotificationConstants.Type.SYSTEM_NOTICE.name()));
}
}
default -> toUsers.add(new Receiver(userId, NotificationConstants.Type.MENTIONED_ME.name()));
}
//TODO接口同步时通知的接收人特殊处理v2接口同步的通知v3这里待讨论
//处理评论人
if (messageDetail.getTaskType().contains("AT_COMMENT")) {
if (CollectionUtils.isNotEmpty(noticeModel.getRelatedUsers())) {
for (String relatedUser : noticeModel.getRelatedUsers()) {
toUsers.add(new Receiver(relatedUser, NotificationConstants.Type.MENTIONED_ME.name()));
}
}
}
}
// 去重复
return toUsers.stream()
@ -198,22 +175,12 @@ public abstract class AbstractNoticeSender implements NoticeSender {
.collect(Collectors.toList());
}
private void getRelateUsers(List<Receiver> toUsers, Map<String, Object> paramMap) {
List<String> relatedUsers = (List<String>) paramMap.get("userIds");
if (CollectionUtils.isNotEmpty(relatedUsers)) {
List<Receiver> receivers = relatedUsers.stream()
.map(u -> new Receiver(u, NotificationConstants.Type.SYSTEM_NOTICE.name()))
.toList();
toUsers.addAll(receivers);
}
}
private List<Receiver> handleFollows(MessageDetail messageDetail, NoticeModel noticeModel) {
List<Receiver> receivers = new ArrayList<>();
String id = (String) noticeModel.getParamMap().get("id");
String taskType = messageDetail.getTaskType();
switch (taskType) {
case NoticeConstants.TaskType.TEST_PLAN_TASK:
case NoticeConstants.TaskType.TEST_PLAN_TASK -> {
TestPlanFollowerExample testPlanFollowerExample = new TestPlanFollowerExample();
testPlanFollowerExample.createCriteria().andTestPlanIdEqualTo(id);
List<TestPlanFollower> testPlanFollowers = testPlanFollowerMapper.selectByExample(testPlanFollowerExample);
@ -221,8 +188,8 @@ public abstract class AbstractNoticeSender implements NoticeSender {
.stream()
.map(t -> new Receiver(t.getUserId(), NotificationConstants.Type.SYSTEM_NOTICE.name()))
.collect(Collectors.toList());
break;
case NoticeConstants.TaskType.CASE_REVIEW_TASK:
}
case NoticeConstants.TaskType.CASE_REVIEW_TASK -> {
CaseReviewFollowerExample caseReviewFollowerExample = new CaseReviewFollowerExample();
caseReviewFollowerExample.createCriteria().andReviewIdEqualTo(id);
List<CaseReviewFollower> caseReviewFollowers = caseReviewFollowerMapper.selectByExample(caseReviewFollowerExample);
@ -230,8 +197,8 @@ public abstract class AbstractNoticeSender implements NoticeSender {
.stream()
.map(t -> new Receiver(t.getUserId(), NotificationConstants.Type.SYSTEM_NOTICE.name()))
.collect(Collectors.toList());
break;
case NoticeConstants.TaskType.API_SCENARIO_TASK:
}
case NoticeConstants.TaskType.API_SCENARIO_TASK -> {
ApiScenarioFollowerExample apiScenarioFollowerExample = new ApiScenarioFollowerExample();
apiScenarioFollowerExample.createCriteria().andApiScenarioIdEqualTo(id);
List<ApiScenarioFollower> apiScenarioFollowers = apiScenarioFollowerMapper.selectByExample(apiScenarioFollowerExample);
@ -239,26 +206,26 @@ public abstract class AbstractNoticeSender implements NoticeSender {
.stream()
.map(t -> new Receiver(t.getUserId(), NotificationConstants.Type.SYSTEM_NOTICE.name()))
.collect(Collectors.toList());
break;
case NoticeConstants.TaskType.API_DEFINITION_TASK:
}
case NoticeConstants.TaskType.API_DEFINITION_TASK -> {
ApiDefinitionFollowerExample apiDefinitionFollowerExample = new ApiDefinitionFollowerExample();
apiDefinitionFollowerExample.createCriteria().andApiDefinitionIdEqualTo(id);
List<ApiDefinitionFollower> apiDefinitionFollowers= apiDefinitionFollowerMapper.selectByExample(apiDefinitionFollowerExample);
List<ApiDefinitionFollower> apiDefinitionFollowers = apiDefinitionFollowerMapper.selectByExample(apiDefinitionFollowerExample);
receivers = apiDefinitionFollowers
.stream()
.map(t -> new Receiver(t.getUserId(), NotificationConstants.Type.SYSTEM_NOTICE.name()))
.collect(Collectors.toList());
break;
case NoticeConstants.TaskType.LOAD_TEST_TASK:
}
case NoticeConstants.TaskType.LOAD_TEST_TASK -> {
LoadTestFollowerExample loadTestFollowerExample = new LoadTestFollowerExample();
loadTestFollowerExample.createCriteria().andTestIdEqualTo(id);
List<LoadTestFollower> loadTestFollowers= loadTestFollowerMapper.selectByExample(loadTestFollowerExample);
List<LoadTestFollower> loadTestFollowers = loadTestFollowerMapper.selectByExample(loadTestFollowerExample);
receivers = loadTestFollowers
.stream()
.map(t -> new Receiver(t.getUserId(), NotificationConstants.Type.SYSTEM_NOTICE.name()))
.collect(Collectors.toList());
break;
case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK:
}
case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> {
FunctionalCaseFollowerExample functionalCaseFollowerExample = new FunctionalCaseFollowerExample();
functionalCaseFollowerExample.createCriteria().andCaseIdEqualTo(id);
List<FunctionalCaseFollower> functionalCaseFollowers = functionalCaseFollowerMapper.selectByExample(functionalCaseFollowerExample);
@ -266,9 +233,9 @@ public abstract class AbstractNoticeSender implements NoticeSender {
.stream()
.map(t -> new Receiver(t.getUserId(), NotificationConstants.Type.SYSTEM_NOTICE.name()))
.collect(Collectors.toList());
break;
default:
break;
}
default -> {
}
}
LogUtils.info("FOLLOW_PEOPLE: {}", receivers);
return receivers;

View File

@ -4,8 +4,8 @@ package io.metersphere.system.notice.sender;
import io.metersphere.sdk.dto.BaseSystemConfigDTO;
import io.metersphere.sdk.dto.SessionUser;
import io.metersphere.system.notice.annotation.SendNotice;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.notice.NoticeModel;
import io.metersphere.system.notice.utils.MessageTemplateUtils;
import io.metersphere.system.service.NoticeSendService;
import io.metersphere.system.service.SystemParameterService;
import jakarta.annotation.Resource;
@ -38,12 +38,14 @@ public class AfterReturningNoticeSendService {
// 占位符
handleDefaultValues(paramMap);
String context = getContext(sendNotice, paramMap);
String context = getContext(sendNotice);
String subject = getSubject(sendNotice);
NoticeModel noticeModel = NoticeModel.builder()
.operator(sessionUser.getId())
.context(context)
.subject(sendNotice.subject())
.subject(subject)
.paramMap(paramMap)
.event(sendNotice.event())
.status((String) paramMap.get("status"))
@ -53,6 +55,11 @@ public class AfterReturningNoticeSendService {
}
}
private String getSubject(SendNotice sendNotice) {
Map<String, String> defaultTemplateTitleMap = MessageTemplateUtils.getDefaultTemplateTitleMap();
return defaultTemplateTitleMap.get(sendNotice.taskType() + "_" + sendNotice.event());
}
/**
* 有些默认的值避免通知里出现 ${key}
*/
@ -60,46 +67,8 @@ public class AfterReturningNoticeSendService {
paramMap.put("planShareUrl", StringUtils.EMPTY); // 占位符
}
private String getContext(SendNotice sendNotice, Map<String, Object> paramMap) {
String operation = "";
switch (sendNotice.event()) {
case NoticeConstants.Event.CREATE:
case NoticeConstants.Event.CASE_CREATE:
case NoticeConstants.Event.MOCK_CREATE:
operation = "创建了";
break;
case NoticeConstants.Event.UPDATE:
case NoticeConstants.Event.CASE_UPDATE:
case NoticeConstants.Event.MOCK_UPDATE:
operation = "更新了";
break;
case NoticeConstants.Event.DELETE:
case NoticeConstants.Event.CASE_DELETE:
case NoticeConstants.Event.MOCK_DELETE:
operation = "删除了";
break;
case NoticeConstants.Event.COMMENT:
operation = "评论了";
break;
case NoticeConstants.Event.COMPLETE:
operation = "完成了";
break;
case NoticeConstants.Event.CLOSE_SCHEDULE:
operation = "关闭了定时任务";
break;
default:
break;
}
String subject = sendNotice.subject();
String resource = StringUtils.removeEnd(subject, "通知");
String name = "";
if (paramMap.containsKey("name")) {
name = ": ${name}";
}
if (paramMap.containsKey("title")) {
name = ": ${title}";
}
return "${operator}" + operation + resource + name;
private String getContext(SendNotice sendNotice) {
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
return defaultTemplateMap.get(sendNotice.taskType() + "_" + sendNotice.event());
}
}

View File

@ -0,0 +1,111 @@
package io.metersphere.system.notice.utils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.notice.constants.NoticeConstants;
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.commons.lang3.reflect.FieldUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MessageTemplateUtils {
private static void setFieldNameMap(Field[] moduleFields, Map<String, String> moduleMap) {
for (Field moduleField : moduleFields) {
Schema annotation = moduleField.getAnnotation(Schema.class);
String name = "";
if (annotation != null) {
name = Translator.get(annotation.description());
}
moduleMap.put(moduleField.getName(), name);
}
}
/**
* 获取模块翻译后的名称map
*
* @return Map<String, String> moduleMap
*/
public static Map<String, String> getModuleMap() {
Field[] moduleFields = FieldUtils.getAllFields(NoticeConstants.Module.class);
Map<String, String> moduleMap = new HashMap<>();
setFieldNameMap(moduleFields, moduleMap);
return moduleMap;
}
/**
* 获取任务类型翻译后的名称map
*
* @return Map<String, String> taskTypeMap
*/
public static Map<String, String> getTaskTypeMap() {
Map<String, String> taskTypeMap = new HashMap<>();
Field[] taskTypeFields = FieldUtils.getAllFields(NoticeConstants.TaskType.class);
setFieldNameMap(taskTypeFields, taskTypeMap);
return taskTypeMap;
}
/**
* 获取事件翻译后的名称map
*
* @return Map<String, String> eventMap
*/
public static Map<String, String> getEventMap() {
Map<String, String> eventMap = new HashMap<>();
Field[] eventFields = FieldUtils.getAllFields(NoticeConstants.Event.class);
setFieldNameMap(eventFields, eventMap);
return eventMap;
}
/**
* 获取事件的默认模版
*
* @return Map<String, String> defaultTemplateMap
*/
public static Map<String, String> getDefaultTemplateMap() {
Map<String, String> defaultTemplateMap = new HashMap<>();
Field[] defaultTemplateFields = FieldUtils.getAllFields(NoticeConstants.TemplateText.class);
setFieldNameMap(defaultTemplateFields, defaultTemplateMap);
return defaultTemplateMap;
}
/**
* 获取事件的默认模版标题
*
* @return Map<String, String> defaultTemplateTitleMap
*/
public static Map<String, String> getDefaultTemplateTitleMap() {
Map<String, String> defaultTemplateTitleMap = new HashMap<>();
Field[] defaultTemplateTitleFields = FieldUtils.getAllFields(NoticeConstants.TemplateTitle.class);
MessageTemplateUtils.setFieldNameMap(defaultTemplateTitleFields, defaultTemplateTitleMap);
return defaultTemplateTitleMap;
}
/**
* 获取接收人的特殊值
* @return List<String> defaultRelatedUsers
*/
public static List<String> getDefaultRelatedUser() {
Field[] defaultRelatedUserFields = FieldUtils.getAllFields(NoticeConstants.RelatedUser.class);
List<String> defaultRelatedUsers = new ArrayList<>();
for (Field defaultRelatedUserField : defaultRelatedUserFields) {
defaultRelatedUsers.add(defaultRelatedUserField.getName());
}
return defaultRelatedUsers;
}
/**
* 获取接收人的特殊值
* @return List<String> defaultRelatedUsers
*/
public static Map<String, String> getDefaultRelatedUserMap() {
Map<String, String> defaultRelatedUserMap = new HashMap<>();
Field[] defaultRelatedUserFields = FieldUtils.getAllFields(NoticeConstants.RelatedUser.class);
MessageTemplateUtils.setFieldNameMap(defaultRelatedUserFields, defaultRelatedUserMap);
return defaultRelatedUserMap;
}
}

View File

@ -6,6 +6,7 @@ import io.metersphere.project.mapper.MessageTaskMapper;
import io.metersphere.project.mapper.ProjectRobotMapper;
import io.metersphere.system.notice.MessageDetail;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.notice.utils.MessageTemplateUtils;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -30,6 +31,7 @@ public class MessageDetailService {
/**
* 获取唯一的消息任务
*
* @param taskType 任务类型
* @param projectId 项目ID
* @return List<MessageDetail>list
@ -45,10 +47,8 @@ public class MessageDetailService {
private List<MessageDetail> getMessageDetails(String type, String projectId) {
List<MessageDetail> messageDetails = new ArrayList<>();
//根据项目id找到所有开启的消息通知任务 以及模版配置机器人配置
MessageTaskExample example = new MessageTaskExample();
example.createCriteria()
.andTaskTypeEqualTo(type)
.andProjectIdEqualTo(projectId).andEnableEqualTo(true);
@ -57,21 +57,19 @@ public class MessageDetailService {
getMessageDetails(messageDetails, messageTaskLists);
return messageDetails.stream()
.sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed())
.toList()
.stream()
.distinct()
.collect(Collectors.toList());
}
private void getMessageDetails(List<MessageDetail> messageDetails, List<MessageTask> messageTaskLists) {
List<String> messageTaskIds = messageTaskLists.stream().map(MessageTask::getId).toList();
List<String> messageTaskIds = messageTaskLists.stream().map(MessageTask::getId).collect(Collectors.toList());
MessageTaskBlobExample blobExample = new MessageTaskBlobExample();
blobExample.createCriteria()
.andIdIn(messageTaskIds);
List<MessageTaskBlob> messageTaskBlobs = messageTaskBlobMapper.selectByExample(blobExample);
Map<String, MessageTaskBlob> messageTaskBlobMap = messageTaskBlobs.stream().collect(Collectors.toMap(MessageTaskBlob::getId, item -> item));
List<String> robotIds = messageTaskLists.stream().map(MessageTask::getProjectRobotId).distinct().toList();
List<String> robotIds = messageTaskLists.stream().map(MessageTask::getProjectRobotId).distinct().collect(Collectors.toList());
ProjectRobotExample projectRobotExample = new ProjectRobotExample();
projectRobotExample.createCriteria().andIdIn(robotIds).andEnableEqualTo(true);
List<ProjectRobot> projectRobots = projectRobotMapper.selectByExample(projectRobotExample);
@ -105,15 +103,38 @@ public class MessageDetailService {
if (StringUtils.isNotBlank(projectRobot.getAppSecret())) {
messageDetail.setAppSecret(projectRobot.getAppSecret());
}
if (!messageTask.getUseDefaultSubject() && StringUtils.isNotBlank(messageTask.getSubject())) {
messageDetail.setSubject(messageTask.getSubject());
} else {
String subject = getSubject(messageTask.getTaskType(), messageTask.getEvent());
messageDetail.setSubject(subject);
}
MessageTaskBlob messageTaskBlob = messageTaskBlobMap.get(messageTask.getId());
if (!messageTask.getUseDefaultTemplate() && StringUtils.isNotBlank(messageTaskBlob.getTemplate())) {
messageDetail.setTemplate(messageTaskBlob.getTemplate());
} else {
String template = getTemplate(messageTask.getTaskType(), messageTask.getEvent());
messageDetail.setTemplate(template);
}
messageDetails.add(messageDetail);
});
}
private String getTemplate(String taskType, String event) {
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
return defaultTemplateMap.get(taskType + "_" + event);
}
private String getSubject(String taskType, String event) {
Map<String, String> defaultTemplateTitleMap = MessageTemplateUtils.getDefaultTemplateTitleMap();
return "MeterSphere " + defaultTemplateTitleMap.get(taskType + "_" + event);
}
/**
* 根据用例ID获取所有该用例的定时任务的任务通知
*
* @param testId 用例id
* @return List<MessageDetail>
*/

View File

@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
import io.metersphere.system.notice.NoticeModel;
import java.util.ArrayList;
import java.util.List;
@Component
@ -39,17 +38,15 @@ public class NoticeSendService {
private AbstractNoticeSender getNoticeSender(MessageDetail messageDetail) {
AbstractNoticeSender noticeSender = null;
AbstractNoticeSender noticeSender;
switch (messageDetail.getType()) {
case NoticeConstants.Type.MAIL -> noticeSender = mailNoticeSender;
case NoticeConstants.Type.WECOM_ROBOT -> noticeSender = weComNoticeSender;
case NoticeConstants.Type.DING_CUSTOM_ROBOT -> noticeSender = dingCustomNoticeSender;
case NoticeConstants.Type.DING_ENTERPRISE_ROBOT -> noticeSender = dingEnterPriseNoticeSender;
case NoticeConstants.Type.LARK_ROBOT -> noticeSender = larkNoticeSender;
case NoticeConstants.Type.IN_SITE -> noticeSender = inSiteNoticeSender;
case NoticeConstants.Type.CUSTOM_WEBHOOK_ROBOT -> noticeSender = webhookNoticeSender;
default -> {
}
default -> noticeSender = inSiteNoticeSender;
}
return noticeSender;
@ -85,13 +82,11 @@ public class NoticeSendService {
// api和定时任务调用不排除自己
noticeModel.setExcludeSelf(false);
try {
List<MessageDetail> messageDetails = new ArrayList<>();
List<MessageDetail> messageDetails;
if (StringUtils.equals(triggerMode, NoticeConstants.Mode.SCHEDULE)) {
messageDetails = messageDetailService.searchMessageByTestId(noticeModel.getTestId());
}
if (StringUtils.equals(triggerMode, NoticeConstants.Mode.API)) {
} else {
String projectId = (String) noticeModel.getParamMap().get("projectId");
messageDetails = messageDetailService.searchMessageByTypeAndProjectId(NoticeConstants.TaskType.JENKINS_TASK, projectId);
}