Browse Source

# 计划类型消息推送接口修改

zhongwei
haungxing 2 years ago
parent
commit
90f298bf77
  1. 6
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java
  2. 26
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessageService.java
  3. 2
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java

6
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<MessageTemplateEntity> getMsgTemplateById(@RequestParam Long id);
/** @Author hx
* @Description 计划推送类型消息推送
* @Date 2023/4/14 15:04
* @Param
* @return
**/
@PostMapping(PLAN_SEND_MESSAGE)
R<PlanMsgRecordDto> planSendMessage(@RequestBody PlanMsgRecordDto request);
}

26
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);
}
}

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

Loading…
Cancel
Save