From 90f298bf77767b0c9200510769d2ef86347383dc Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Fri, 14 Apr 2023 15:33:23 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E8=AE=A1=E5=88=92=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81=E6=8E=A5=E5=8F=A3=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/message/fegin/IMessageClient.java | 6 +++++ .../hzims/message/service/IMessageService.java | 26 ++++++++++++++++++++++ .../service/impl/SmsMessageServiceImpl.java | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java index a84e3f9..6f22f16 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java @@ -41,6 +41,12 @@ public interface IMessageClient { @GetMapping(GET_TEMPLATE_BY_ID) R getMsgTemplateById(@RequestParam Long id); + /** @Author hx + * @Description 计划推送类型消息推送 + * @Date 2023/4/14 15:04 + * @Param + * @return + **/ @PostMapping(PLAN_SEND_MESSAGE) R planSendMessage(@RequestBody PlanMsgRecordDto request); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java index a929844..184e7c7 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java @@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import static com.hnac.hzims.message.MessageConstants.*; /** * @author hx @@ -19,4 +24,25 @@ public interface IMessageService { boolean send(MessagePushRecordEntity request); + /** @Author hx + * @Description 根据消息接受人获取推送账号 + * @Date 2023/4/14 15:09 + * @Param pusher 消息接收人 + * @return + **/ + default String getAccountByPusher(Long pusher,String type) { + User user = UserCache.getUser(pusher); + if(ObjectUtil.isNotEmpty(user)) { + switch(type) { + case MAIL_PUSH: + return Func.isNotEmpty(user.getEmail()) ? user.getEmail() : Long.toString(pusher); + case SMS_PUSH: + return Func.isNotEmpty(user.getPhone()) ? user.getPhone() : Long.toString(pusher); + default: + break; + } + } + return Long.toString(pusher); + } + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java index b4058d6..488d385 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java @@ -52,7 +52,7 @@ public class SmsMessageServiceImpl implements IMessageService { Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId(), request.getResourceCode(), request.getContent(), - request.getAccount() + this.getAccountByPusher(Long.parseLong(request.getPusher()),request.getType()) ); Assert.isTrue(response.isSuccess(),() -> { throw new ServiceException(response.getMsg());