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());