refactor: 接口用例执行失败发送通知
This commit is contained in:
parent
0110fd84c6
commit
56d1dc8a35
|
@ -156,7 +156,8 @@ public class ApiDefinitionExecResultService {
|
||||||
.operator(SessionUtils.getUserId())
|
.operator(SessionUtils.getUserId())
|
||||||
.context(context)
|
.context(context)
|
||||||
.subject("接口用例通知")
|
.subject("接口用例通知")
|
||||||
.mailTemplate("api/CaseResult")
|
.successMailTemplate("api/CaseResult")
|
||||||
|
.failedMailTemplate("api/CaseResult")
|
||||||
.paramMap(paramMap)
|
.paramMap(paramMap)
|
||||||
.event(event)
|
.event(event)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -623,7 +623,8 @@ public class ApiScenarioReportService {
|
||||||
.operator(SessionUtils.getUserId())
|
.operator(SessionUtils.getUserId())
|
||||||
.context(context)
|
.context(context)
|
||||||
.subject("接口自动化通知")
|
.subject("接口自动化通知")
|
||||||
.mailTemplate("api/ScenarioResult")
|
.successMailTemplate("api/ScenarioResult")
|
||||||
|
.failedMailTemplate("api/ScenarioResult")
|
||||||
.paramMap(paramMap)
|
.paramMap(paramMap)
|
||||||
.event(event)
|
.event(event)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -114,7 +114,6 @@ public abstract class AbstractNoticeSender implements NoticeSender {
|
||||||
List<UserDetail> list = userService.queryTypeByIds(userIds);
|
List<UserDetail> list = userService.queryTypeByIds(userIds);
|
||||||
List<String> phoneList = new ArrayList<>();
|
List<String> phoneList = new ArrayList<>();
|
||||||
list.forEach(u -> phoneList.add(u.getPhone()));
|
list.forEach(u -> phoneList.add(u.getPhone()));
|
||||||
LogUtil.info("收件人地址: " + phoneList);
|
|
||||||
return phoneList.stream().distinct().collect(Collectors.toList());
|
return phoneList.stream().distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +121,6 @@ public abstract class AbstractNoticeSender implements NoticeSender {
|
||||||
List<UserDetail> list = userService.queryTypeByIds(userIds);
|
List<UserDetail> list = userService.queryTypeByIds(userIds);
|
||||||
List<String> phoneList = new ArrayList<>();
|
List<String> phoneList = new ArrayList<>();
|
||||||
list.forEach(u -> phoneList.add(u.getEmail()));
|
list.forEach(u -> phoneList.add(u.getEmail()));
|
||||||
LogUtil.info("收件人地址: " + phoneList);
|
|
||||||
return phoneList.stream().distinct().collect(Collectors.toList());
|
return phoneList.stream().distinct().collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class DingNoticeSender extends AbstractNoticeSender {
|
||||||
.map(Receiver::getUserId)
|
.map(Receiver::getUserId)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
LogUtil.info("收件人地址: " + phoneList);
|
LogUtil.info("钉钉收件人地址: " + phoneList);
|
||||||
at.setAtMobiles(phoneList);
|
at.setAtMobiles(phoneList);
|
||||||
request.setAt(at);
|
request.setAt(at);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.notice.sender.impl;
|
package io.metersphere.notice.sender.impl;
|
||||||
|
|
||||||
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.notice.domain.MessageDetail;
|
import io.metersphere.notice.domain.MessageDetail;
|
||||||
import io.metersphere.notice.domain.Receiver;
|
import io.metersphere.notice.domain.Receiver;
|
||||||
import io.metersphere.notice.domain.UserDetail;
|
import io.metersphere.notice.domain.UserDetail;
|
||||||
|
@ -31,7 +32,7 @@ public class LarkNoticeSender extends AbstractNoticeSender {
|
||||||
if (CollectionUtils.isEmpty(collect)) {
|
if (CollectionUtils.isEmpty(collect)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LogUtil.info("飞书收件人: ", userIds);
|
||||||
context += StringUtils.join(collect, " ");
|
context += StringUtils.join(collect, " ");
|
||||||
LarkClient.send(messageDetail.getWebhook(), context);
|
LarkClient.send(messageDetail.getWebhook(), context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class MailNoticeSender extends AbstractNoticeSender {
|
||||||
private MailService mailService;
|
private MailService mailService;
|
||||||
|
|
||||||
private void sendMail(String context, NoticeModel noticeModel) throws MessagingException {
|
private void sendMail(String context, NoticeModel noticeModel) throws MessagingException {
|
||||||
LogUtil.info("发送邮件开始 ");
|
LogUtil.debug("发送邮件开始 ");
|
||||||
JavaMailSenderImpl javaMailSender = mailService.getMailSender();
|
JavaMailSenderImpl javaMailSender = mailService.getMailSender();
|
||||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||||
|
@ -34,8 +34,8 @@ public class MailNoticeSender extends AbstractNoticeSender {
|
||||||
String domainName = mailHost.substring(mailHost.indexOf(".") + 1, mailHost.length());
|
String domainName = mailHost.substring(mailHost.indexOf(".") + 1, mailHost.length());
|
||||||
helper.setFrom(javaMailSender.getUsername() + "@" + domainName);
|
helper.setFrom(javaMailSender.getUsername() + "@" + domainName);
|
||||||
}
|
}
|
||||||
LogUtil.info("发件人地址" + javaMailSender.getUsername());
|
LogUtil.debug("发件人地址" + javaMailSender.getUsername());
|
||||||
LogUtil.info("helper" + helper);
|
LogUtil.debug("helper" + helper);
|
||||||
helper.setSubject("MeterSphere " + noticeModel.getSubject());
|
helper.setSubject("MeterSphere " + noticeModel.getSubject());
|
||||||
List<String> userIds = noticeModel.getReceivers().stream()
|
List<String> userIds = noticeModel.getReceivers().stream()
|
||||||
.map(Receiver::getUserId)
|
.map(Receiver::getUserId)
|
||||||
|
@ -54,7 +54,7 @@ public class MailNoticeSender extends AbstractNoticeSender {
|
||||||
String context = super.getHtmlContext(messageDetail, noticeModel);
|
String context = super.getHtmlContext(messageDetail, noticeModel);
|
||||||
try {
|
try {
|
||||||
sendMail(context, noticeModel);
|
sendMail(context, noticeModel);
|
||||||
LogUtil.info("发送邮件结束");
|
LogUtil.debug("发送邮件结束");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class WeComNoticeSender extends AbstractNoticeSender {
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
message.setMentionedMobileList(phoneLists);
|
message.setMentionedMobileList(phoneLists);
|
||||||
|
LogUtil.info("企业微信收件人: ", phoneLists);
|
||||||
try {
|
try {
|
||||||
WxChatbotClient.send(messageDetail.getWebhook(), message);
|
WxChatbotClient.send(messageDetail.getWebhook(), message);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in New Issue