refactor: 接口用例执行失败发送通知

This commit is contained in:
Captain.B 2021-08-25 11:06:41 +08:00 committed by 刘瑞斌
parent 0110fd84c6
commit 56d1dc8a35
7 changed files with 12 additions and 10 deletions

View File

@ -156,7 +156,8 @@ public class ApiDefinitionExecResultService {
.operator(SessionUtils.getUserId())
.context(context)
.subject("接口用例通知")
.mailTemplate("api/CaseResult")
.successMailTemplate("api/CaseResult")
.failedMailTemplate("api/CaseResult")
.paramMap(paramMap)
.event(event)
.build();

View File

@ -623,7 +623,8 @@ public class ApiScenarioReportService {
.operator(SessionUtils.getUserId())
.context(context)
.subject("接口自动化通知")
.mailTemplate("api/ScenarioResult")
.successMailTemplate("api/ScenarioResult")
.failedMailTemplate("api/ScenarioResult")
.paramMap(paramMap)
.event(event)
.build();

View File

@ -114,7 +114,6 @@ public abstract class AbstractNoticeSender implements NoticeSender {
List<UserDetail> list = userService.queryTypeByIds(userIds);
List<String> phoneList = new ArrayList<>();
list.forEach(u -> phoneList.add(u.getPhone()));
LogUtil.info("收件人地址: " + phoneList);
return phoneList.stream().distinct().collect(Collectors.toList());
}
@ -122,7 +121,6 @@ public abstract class AbstractNoticeSender implements NoticeSender {
List<UserDetail> list = userService.queryTypeByIds(userIds);
List<String> phoneList = new ArrayList<>();
list.forEach(u -> phoneList.add(u.getEmail()));
LogUtil.info("收件人地址: " + phoneList);
return phoneList.stream().distinct().collect(Collectors.toList());
}

View File

@ -34,7 +34,7 @@ public class DingNoticeSender extends AbstractNoticeSender {
.map(Receiver::getUserId)
.distinct()
.collect(Collectors.toList()));
LogUtil.info("收件人地址: " + phoneList);
LogUtil.info("钉钉收件人地址: " + phoneList);
at.setAtMobiles(phoneList);
request.setAt(at);
try {

View File

@ -1,5 +1,6 @@
package io.metersphere.notice.sender.impl;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.notice.domain.MessageDetail;
import io.metersphere.notice.domain.Receiver;
import io.metersphere.notice.domain.UserDetail;
@ -31,7 +32,7 @@ public class LarkNoticeSender extends AbstractNoticeSender {
if (CollectionUtils.isEmpty(collect)) {
return;
}
LogUtil.info("飞书收件人: ", userIds);
context += StringUtils.join(collect, " ");
LarkClient.send(messageDetail.getWebhook(), context);
}

View File

@ -22,7 +22,7 @@ public class MailNoticeSender extends AbstractNoticeSender {
private MailService mailService;
private void sendMail(String context, NoticeModel noticeModel) throws MessagingException {
LogUtil.info("发送邮件开始 ");
LogUtil.debug("发送邮件开始 ");
JavaMailSenderImpl javaMailSender = mailService.getMailSender();
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
@ -34,8 +34,8 @@ public class MailNoticeSender extends AbstractNoticeSender {
String domainName = mailHost.substring(mailHost.indexOf(".") + 1, mailHost.length());
helper.setFrom(javaMailSender.getUsername() + "@" + domainName);
}
LogUtil.info("发件人地址" + javaMailSender.getUsername());
LogUtil.info("helper" + helper);
LogUtil.debug("发件人地址" + javaMailSender.getUsername());
LogUtil.debug("helper" + helper);
helper.setSubject("MeterSphere " + noticeModel.getSubject());
List<String> userIds = noticeModel.getReceivers().stream()
.map(Receiver::getUserId)
@ -54,7 +54,7 @@ public class MailNoticeSender extends AbstractNoticeSender {
String context = super.getHtmlContext(messageDetail, noticeModel);
try {
sendMail(context, noticeModel);
LogUtil.info("发送邮件结束");
LogUtil.debug("发送邮件结束");
} catch (Exception e) {
LogUtil.error(e);
}

View File

@ -29,6 +29,7 @@ public class WeComNoticeSender extends AbstractNoticeSender {
.distinct()
.collect(Collectors.toList()));
message.setMentionedMobileList(phoneLists);
LogUtil.info("企业微信收件人: ", phoneLists);
try {
WxChatbotClient.send(messageDetail.getWebhook(), message);
} catch (IOException e) {