From 56d1dc8a3599cc540c78a35d9d2cb3d156c72b35 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 25 Aug 2021 11:06:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8E=A5=E5=8F=A3=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiDefinitionExecResultService.java | 3 ++- .../metersphere/api/service/ApiScenarioReportService.java | 3 ++- .../metersphere/notice/sender/AbstractNoticeSender.java | 2 -- .../metersphere/notice/sender/impl/DingNoticeSender.java | 2 +- .../metersphere/notice/sender/impl/LarkNoticeSender.java | 3 ++- .../metersphere/notice/sender/impl/MailNoticeSender.java | 8 ++++---- .../metersphere/notice/sender/impl/WeComNoticeSender.java | 1 + 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 027df22ce1..0b84543d1f 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -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(); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 79b1308dc7..e4e337d031 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -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(); diff --git a/backend/src/main/java/io/metersphere/notice/sender/AbstractNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/AbstractNoticeSender.java index 5d68fa2b48..039a99edd2 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/AbstractNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/AbstractNoticeSender.java @@ -114,7 +114,6 @@ public abstract class AbstractNoticeSender implements NoticeSender { List list = userService.queryTypeByIds(userIds); List 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 list = userService.queryTypeByIds(userIds); List phoneList = new ArrayList<>(); list.forEach(u -> phoneList.add(u.getEmail())); - LogUtil.info("收件人地址: " + phoneList); return phoneList.stream().distinct().collect(Collectors.toList()); } diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java index 04d401f5ea..fe1327af69 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/DingNoticeSender.java @@ -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 { diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java index 2b44e98258..689e4fc4b8 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/LarkNoticeSender.java @@ -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); } diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java index f92896c31f..791216f32e 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/MailNoticeSender.java @@ -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 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); } diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java index bb7dd07f84..3e56cb294d 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/WeComNoticeSender.java @@ -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) {