feat: 消息设置内容修改,排序
This commit is contained in:
parent
32fff6a239
commit
2fd79fdd5c
|
@ -158,9 +158,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
sendTask(report, testResult);
|
||||
} catch (Exception e) {
|
||||
|
@ -185,13 +183,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
if (StringUtils.equals(NoticeConstants.API, report.getTriggerMode())) {
|
||||
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
|
||||
taskList = messageSettingDetail.getJenkinsTask();
|
||||
successContext = "jenkins任务通知:" + report.getName() + "执行成功" + "请点击下面链接进入测试报告页面" + url;
|
||||
failedContext = "jenkins任务通知:" + report.getName() + "执行失败" + "请点击下面链接进入测试报告页面" + url;
|
||||
successContext = "jenkins任务通知:'" + report.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
failedContext = "jenkins任务通知:'" + report.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
}
|
||||
if (StringUtils.equals(NoticeConstants.SCHEDULE, report.getTriggerMode())) {
|
||||
taskList = noticeService.searchMessageSchedule(testResult.getTestId());
|
||||
successContext = "定时任务通知:" + report.getName() + "执行成功" + "请点击下面链接进入测试报告页面" + url;
|
||||
failedContext = "定时任务通知:" + report.getName() + "执行失败" + "请点击下面链接进入测试报告页面" + url;
|
||||
successContext = "定时任务通知:'" + report.getName() + "'执行成功" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
failedContext = "定时任务通知:'" + report.getName() + "'执行失败" + "\n" + "请点击下面链接进入测试报告页面" + "\n" + url;
|
||||
}
|
||||
String finalSuccessContext = successContext;
|
||||
String finalFailedContext = failedContext;
|
||||
|
|
|
@ -26,5 +26,7 @@ public class MessageTask implements Serializable {
|
|||
|
||||
private String testId;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -793,6 +793,66 @@ public class MessageTaskExample {
|
|||
addCriterion("test_id not between", value1, value2, "testId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.MessageTaskMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.MessageTask">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="event" jdbcType="VARCHAR" property="event" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
|
||||
<result column="webhook" jdbcType="VARCHAR" property="webhook" />
|
||||
<result column="identification" jdbcType="VARCHAR" property="identification" />
|
||||
<result column="is_set" jdbcType="BIT" property="isSet" />
|
||||
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="type" jdbcType="VARCHAR" property="type"/>
|
||||
<result column="event" jdbcType="VARCHAR" property="event"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="task_type" jdbcType="VARCHAR" property="taskType"/>
|
||||
<result column="webhook" jdbcType="VARCHAR" property="webhook"/>
|
||||
<result column="identification" jdbcType="VARCHAR" property="identification"/>
|
||||
<result column="is_set" jdbcType="BIT" property="isSet"/>
|
||||
<result column="organization_id" jdbcType="VARCHAR" property="organizationId"/>
|
||||
<result column="test_id" jdbcType="VARCHAR" property="testId"/>
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime"/>
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -73,7 +74,7 @@
|
|||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `type`, event, user_id, task_type, webhook, identification, is_set, organization_id,
|
||||
test_id
|
||||
test_id, create_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -109,11 +110,11 @@
|
|||
insert into message_task (id, `type`, event,
|
||||
user_id, task_type, webhook,
|
||||
identification, is_set, organization_id,
|
||||
test_id)
|
||||
test_id, create_time)
|
||||
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
|
||||
#{userId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR},
|
||||
#{identification,jdbcType=VARCHAR}, #{isSet,jdbcType=BIT}, #{organizationId,jdbcType=VARCHAR},
|
||||
#{testId,jdbcType=VARCHAR})
|
||||
#{testId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MessageTask">
|
||||
insert into message_task
|
||||
|
@ -148,6 +149,9 @@
|
|||
<if test="testId != null">
|
||||
test_id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
|
@ -180,6 +184,9 @@
|
|||
<if test="testId != null">
|
||||
#{testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultType="java.lang.Long">
|
||||
|
@ -221,6 +228,9 @@
|
|||
<if test="record.testId != null">
|
||||
test_id = #{record.testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
|
@ -237,7 +247,8 @@
|
|||
identification = #{record.identification,jdbcType=VARCHAR},
|
||||
is_set = #{record.isSet,jdbcType=BIT},
|
||||
organization_id = #{record.organizationId,jdbcType=VARCHAR},
|
||||
test_id = #{record.testId,jdbcType=VARCHAR}
|
||||
test_id = #{record.testId,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -272,6 +283,9 @@
|
|||
<if test="testId != null">
|
||||
test_id = #{testId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
@ -285,7 +299,8 @@
|
|||
identification = #{identification,jdbcType=VARCHAR},
|
||||
is_set = #{isSet,jdbcType=BIT},
|
||||
organization_id = #{organizationId,jdbcType=VARCHAR},
|
||||
test_id = #{testId,jdbcType=VARCHAR}
|
||||
test_id = #{testId,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.base.domain.MessageTask;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtMessageMapper {
|
||||
List<MessageTask> searchMessageByTestId(@Param("testId") String testId);
|
||||
|
||||
List<MessageTask> searchMessageByOrganizationId(@Param("organizationId") String organizationId);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtMessageMapper">
|
||||
<select id="searchMessageByTestId" resultType="io.metersphere.base.domain.MessageTask">
|
||||
select m.* from message_task m
|
||||
<where>
|
||||
<if test="testId!=null">
|
||||
and m.test_id=#{testId}
|
||||
</if>
|
||||
</where>
|
||||
order by m.create_time DESC
|
||||
</select>
|
||||
<select id="searchMessageByOrganizationId" resultType="io.metersphere.base.domain.MessageTask">
|
||||
select m.* from message_task m
|
||||
<where>
|
||||
<if test="organizationId!=null">
|
||||
and m.organization_id=#{organizationId}
|
||||
</if>
|
||||
</where>
|
||||
order by m.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -16,4 +16,5 @@ public class MessageDetail {
|
|||
private String organizationId;
|
||||
private Boolean isSet;
|
||||
private String testId;
|
||||
private Long createTime;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ public class MailService {
|
|||
List<String> userIds = new ArrayList<>();
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
Map<String, String> context = new HashMap<>();
|
||||
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
|
||||
context.put("testName", loadTestReport.getName());
|
||||
context.put("id", loadTestReport.getId());
|
||||
context.put("type", "performance");
|
||||
|
@ -103,7 +102,7 @@ public class MailService {
|
|||
helper.setSubject("MeterSphere平台" + Translator.get("task_notification"));
|
||||
}
|
||||
if (StringUtils.equals(type, NoticeConstants.SCHEDULE)) {
|
||||
helper.setSubject("MeterSphere平台" + Translator.get("timing_task_notification"));
|
||||
helper.setSubject("MeterSphere平台" + Translator.get("task_notification_"));
|
||||
}
|
||||
String[] users;
|
||||
List<String> emails = new ArrayList<>();
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.notice.service;
|
|||
import io.metersphere.base.domain.MessageTask;
|
||||
import io.metersphere.base.domain.MessageTaskExample;
|
||||
import io.metersphere.base.mapper.MessageTaskMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtMessageMapper;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
|
@ -21,10 +22,14 @@ import java.util.stream.Collectors;
|
|||
public class NoticeService {
|
||||
@Resource
|
||||
private MessageTaskMapper messageTaskMapper;
|
||||
@Resource
|
||||
private ExtMessageMapper extMessageMapper;
|
||||
|
||||
|
||||
public void saveMessageTask(MessageRequest messageRequest) {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
String orgId = user.getLastOrganizationId();
|
||||
long time = System.currentTimeMillis();
|
||||
messageRequest.getMessageDetail().forEach(list -> {
|
||||
MessageTaskExample example = new MessageTaskExample();
|
||||
example.createCriteria().andIdentificationEqualTo(list.getIdentification());
|
||||
|
@ -44,6 +49,7 @@ public class NoticeService {
|
|||
message.setIsSet(list.getIsSet());
|
||||
message.setOrganizationId(orgId);
|
||||
message.setTestId(list.getTestId());
|
||||
message.setCreateTime(time);
|
||||
messageTaskMapper.insert(message);
|
||||
});
|
||||
} else {
|
||||
|
@ -60,6 +66,7 @@ public class NoticeService {
|
|||
message.setIsSet(list.getIsSet());
|
||||
message.setOrganizationId(orgId);
|
||||
message.setTestId(list.getTestId());
|
||||
message.setCreateTime(time);
|
||||
messageTaskMapper.insert(message);
|
||||
});
|
||||
}
|
||||
|
@ -68,9 +75,7 @@ public class NoticeService {
|
|||
}
|
||||
|
||||
public List<MessageDetail> searchMessageSchedule(String testId) {
|
||||
MessageTaskExample example = new MessageTaskExample();
|
||||
example.createCriteria().andTestIdEqualTo(testId);
|
||||
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExample(example);
|
||||
List<MessageTask> messageTaskLists = extMessageMapper.searchMessageByTestId(testId);
|
||||
List<MessageDetail> scheduleMessageTask = new ArrayList<>();
|
||||
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> e.getIdentification()));
|
||||
MessageTaskMap.forEach((k, v) -> {
|
||||
|
@ -84,22 +89,22 @@ public class NoticeService {
|
|||
messageDetail.setIdentification(m.getIdentification());
|
||||
messageDetail.setType(m.getType());
|
||||
messageDetail.setIsSet(m.getIsSet());
|
||||
messageDetail.setCreateTime(m.getCreateTime());
|
||||
}
|
||||
messageDetail.setUserIds(new ArrayList(userIds));
|
||||
scheduleMessageTask.add(messageDetail);
|
||||
});
|
||||
scheduleMessageTask.sort(Comparator.comparing(MessageDetail::getCreateTime).reversed());
|
||||
return scheduleMessageTask;
|
||||
}
|
||||
|
||||
public MessageSettingDetail searchMessage() {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
String orgId = user.getLastOrganizationId();
|
||||
MessageTaskExample messageTaskExample = new MessageTaskExample();
|
||||
messageTaskExample.createCriteria().andOrganizationIdEqualTo(orgId);
|
||||
List<MessageTask> messageTaskLists = new ArrayList<>();
|
||||
MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
|
||||
List<MessageDetail> MessageDetailList = new ArrayList<>();
|
||||
messageTaskLists = messageTaskMapper.selectByExample(messageTaskExample);
|
||||
messageTaskLists = extMessageMapper.searchMessageByOrganizationId(orgId);
|
||||
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e)));
|
||||
MessageTaskMap.forEach((k, v) -> {
|
||||
Set userIds = new HashSet();
|
||||
|
@ -112,14 +117,19 @@ public class NoticeService {
|
|||
messageDetail.setIdentification(m.getIdentification());
|
||||
messageDetail.setType(m.getType());
|
||||
messageDetail.setIsSet(m.getIsSet());
|
||||
messageDetail.setCreateTime(m.getCreateTime());
|
||||
}
|
||||
messageDetail.setUserIds(new ArrayList(userIds));
|
||||
MessageDetailList.add(messageDetail);
|
||||
});
|
||||
List<MessageDetail> jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).collect(Collectors.toList());
|
||||
jenkinsTask.sort(Comparator.comparing(MessageDetail::getCreateTime).reversed());
|
||||
List<MessageDetail> testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).collect(Collectors.toList());
|
||||
testCasePlanTask.sort(Comparator.comparing(MessageDetail::getCreateTime).reversed());
|
||||
List<MessageDetail> reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).collect(Collectors.toList());
|
||||
reviewTask.sort(Comparator.comparing(MessageDetail::getCreateTime).reversed());
|
||||
List<MessageDetail> defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).collect(Collectors.toList());
|
||||
defectTask.sort(Comparator.comparing(MessageDetail::getCreateTime).reversed());
|
||||
messageSettingDetail.setJenkinsTask(jenkinsTask);
|
||||
messageSettingDetail.setTestCasePlanTask(testCasePlanTask);
|
||||
messageSettingDetail.setReviewTask(reviewTask);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
alter table message_task
|
||||
add create_time bigint(13) null;
|
|
@ -151,7 +151,6 @@ quota_max_threads_excess_workspace=The maximum number of concurrent threads exce
|
|||
quota_max_threads_excess_organization=The maximum number of concurrent threads exceeds the organization quota
|
||||
quota_duration_excess_workspace=The stress test duration exceeds the work space quota
|
||||
quota_duration_excess_organization=The stress test duration exceeds the organization quota
|
||||
email_subject=Metersphere timing task result notification
|
||||
import_xmind_count_error=The number of use cases imported into the mind map cannot exceed 500
|
||||
import_xmind_not_found=Test case not found
|
||||
license_valid_license_error=Authorization authentication failed
|
||||
|
@ -168,7 +167,7 @@ upload_content_is_null=Imported content is empty
|
|||
test_plan_notification=Test plan notification
|
||||
task_defect_notification=Task defect notification
|
||||
task_notification=Jenkins Task notification
|
||||
timing_task_notification=Timing task result notification
|
||||
task_notification_=Timing task result notification
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -151,7 +151,6 @@ quota_max_threads_excess_workspace=最大并发数超过工作空间限额
|
|||
quota_max_threads_excess_organization=最大并发数超过组织限额
|
||||
quota_duration_excess_workspace=压测时长超过工作空间限额
|
||||
quota_duration_excess_organization=压测时长超过组织限额
|
||||
email_subject=MeterSphere定时任务结果通知
|
||||
import_xmind_count_error=思维导图导入用例数量不能超过 500 条
|
||||
license_valid_license_error=授权认证失败
|
||||
import_xmind_not_found=未找到测试用例
|
||||
|
@ -169,4 +168,4 @@ upload_content_is_null=导入内容为空
|
|||
test_plan_notification=测试计划通知
|
||||
task_defect_notification=缺陷任务通知
|
||||
task_notification=jenkins任务通知
|
||||
timing_task_notification=定时任务结果通知
|
||||
task_notification_=定时任务结果通知
|
|
@ -153,7 +153,6 @@ quota_duration_excess_workspace=壓測時長超過工作空間限額
|
|||
quota_duration_excess_organization=壓測時長超過組織限額
|
||||
license_valid_license_error=授權驗證失敗
|
||||
license_valid_license_code=授權碼已經存在
|
||||
email_subject=MeterSphere定時任務結果通知
|
||||
import_xmind_count_error=思維導圖導入用例數量不能超過 500 條
|
||||
import_xmind_not_found=未找到测试用例
|
||||
|
||||
|
@ -170,5 +169,5 @@ upload_content_is_null=導入內容為空
|
|||
test_plan_notification=測試計畫通知
|
||||
task_defect_notification=缺陷任務通知
|
||||
task_notification=jenkins任務通知
|
||||
timing_task_notification=定時任務通知
|
||||
task_notification_=定時任務通知
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>MeterSphere</title>
|
||||
</head>
|
||||
<body style="text-align: left">
|
||||
<div style="text-align: left">
|
||||
<h3>${title}</h3>
|
||||
</div>
|
||||
<body>
|
||||
<div style="text-align: left">
|
||||
<p>尊敬的用户:</p>
|
||||
<p style="margin-left: 60px">您好:
|
||||
|
|
Loading…
Reference in New Issue