From fe6d5b3310014455eb09d674c5f02481ed551527 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 23 Aug 2021 18:42:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A4=84=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E4=BA=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/sender/AbstractNoticeSender.java | 30 +++++++++---------- .../sender/impl/InSiteNoticeSender.java | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) 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 e2c1950cb7..3d5482074b 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/AbstractNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/AbstractNoticeSender.java @@ -131,19 +131,19 @@ public abstract class AbstractNoticeSender implements NoticeSender { } break; case NoticeConstants.RelatedUser.CREATOR: - Object creator = paramMap.get("creator"); - Object createUser = paramMap.get("createUser"); - Object createUserId = paramMap.get("createUserId"); - Object userId1 = paramMap.get("userId"); + String creator = (String) paramMap.get("creator"); + String createUser = (String) paramMap.get("createUser"); + String createUserId = (String) paramMap.get("createUserId"); + String userId1 = (String) paramMap.get("userId"); - if (userId1 != null) { - toUsers.add(new Receiver(userId1.toString(), NotificationConstants.Type.SYSTEM_NOTICE.name())); - } else if (creator != null) { - toUsers.add(new Receiver(creator.toString(), NotificationConstants.Type.SYSTEM_NOTICE.name())); - } else if (createUser != null) { - toUsers.add(new Receiver(createUser.toString(), NotificationConstants.Type.SYSTEM_NOTICE.name())); - } else if (createUserId != null) { - toUsers.add(new Receiver(createUserId.toString(), NotificationConstants.Type.SYSTEM_NOTICE.name())); + if (StringUtils.isNotBlank(userId1)) { + toUsers.add(new Receiver(userId1, NotificationConstants.Type.SYSTEM_NOTICE.name())); + } else if (StringUtils.isNotBlank(creator)) { + toUsers.add(new Receiver(creator, NotificationConstants.Type.SYSTEM_NOTICE.name())); + } else if (StringUtils.isNotBlank(createUser)) { + toUsers.add(new Receiver(createUser, NotificationConstants.Type.SYSTEM_NOTICE.name())); + } else if (StringUtils.isNotBlank(createUserId)) { + toUsers.add(new Receiver(createUserId, NotificationConstants.Type.SYSTEM_NOTICE.name())); } break; case NoticeConstants.RelatedUser.MAINTAINER: @@ -156,9 +156,9 @@ public abstract class AbstractNoticeSender implements NoticeSender { } break; case NoticeConstants.RelatedUser.FOLLOW_PEOPLE: - Object followPeople = paramMap.get("followPeople"); - if (followPeople != null) { - toUsers.add(new Receiver(followPeople.toString(), NotificationConstants.Type.SYSTEM_NOTICE.name())); + String followPeople = (String) paramMap.get("followPeople"); + if (StringUtils.isNotBlank(followPeople)) { + toUsers.add(new Receiver(followPeople, NotificationConstants.Type.SYSTEM_NOTICE.name())); } break; default: diff --git a/backend/src/main/java/io/metersphere/notice/sender/impl/InSiteNoticeSender.java b/backend/src/main/java/io/metersphere/notice/sender/impl/InSiteNoticeSender.java index ab6c86fc28..fd085bb5a9 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/impl/InSiteNoticeSender.java +++ b/backend/src/main/java/io/metersphere/notice/sender/impl/InSiteNoticeSender.java @@ -27,7 +27,7 @@ public class InSiteNoticeSender extends AbstractNoticeSender { return; } - LogUtil.info("发送站内通知: {}", messageDetail.getUserIds()); + LogUtil.info("发送站内通知: {}", receivers); receivers.forEach(receiver -> { Map paramMap = noticeModel.getParamMap();