|
@@ -1,14 +1,22 @@
|
|
|
package com.citu.module.menduner.system.util;
|
|
|
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import com.citu.framework.common.enums.UserTypeEnum;
|
|
|
+import com.citu.framework.common.pojo.CommonResult;
|
|
|
+import com.citu.module.menduner.common.CommonConstants;
|
|
|
import com.citu.module.menduner.im.api.ImCollectMessageReqVo;
|
|
|
import com.citu.module.menduner.im.api.ImCollectUserReqVo;
|
|
|
import com.citu.module.menduner.im.api.ImMessageApi;
|
|
|
-import com.citu.module.menduner.common.CommonConstants;
|
|
|
+import com.citu.module.system.api.mail.MailSendApi;
|
|
|
+import com.citu.module.system.api.mail.dto.MailSendSingleToUserReqDTO;
|
|
|
import com.citu.module.system.api.notify.NotifyMessageSendApi;
|
|
|
import com.citu.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
|
|
|
+import com.citu.module.system.api.sms.SmsSendApi;
|
|
|
+import com.citu.module.system.api.sms.dto.send.SmsSendSingleToUserReqDTO;
|
|
|
import com.citu.module.system.api.social.SocialClientApi;
|
|
|
import com.citu.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
|
|
+import com.citu.module.system.api.user.AdminUserApi;
|
|
|
+import com.citu.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -17,6 +25,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.citu.module.menduner.common.CommonConstants.WX_SUBSCRIBE_TEMPLATE_PAGE;
|
|
|
+import static com.citu.module.menduner.common.CommonConstants.notifySysStrMap;
|
|
|
|
|
|
/**
|
|
|
* 消息通知
|
|
@@ -30,9 +39,18 @@ public class MessageUtils {
|
|
|
@Resource
|
|
|
private ImMessageApi imMessageApi;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MailSendApi mailSendApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SmsSendApi smsSendApi;
|
|
|
+
|
|
|
@Resource
|
|
|
private SocialClientApi socialClientApi;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 发送后台管理系统消息通知
|
|
@@ -49,6 +67,43 @@ public class MessageUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发送后台管理系统消息通知、短信、邮箱
|
|
|
+ *
|
|
|
+ * @param reqDTO 请求参数
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public void sendPlatformSystemNotifyAndSmsAndEmailMessage(NotifySendSingleToUserReqDTO reqDTO) {
|
|
|
+ // 参数不变,更改方法
|
|
|
+ // 发送系统消息
|
|
|
+ for (Long userId : CommonConstants.notifySysUserId) {
|
|
|
+ reqDTO.setUserId(userId);
|
|
|
+ CommonResult<AdminUserRespDTO> result = adminUserApi.getUser(userId);
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ AdminUserRespDTO data = result.getData();
|
|
|
+ if (data != null) {
|
|
|
+ // 发送短信
|
|
|
+ SmsSendSingleToUserReqDTO smsReqDTO = new SmsSendSingleToUserReqDTO();
|
|
|
+ smsReqDTO.setUserId(data.getId());
|
|
|
+ smsReqDTO.setMobile(data.getMobile());
|
|
|
+ smsReqDTO.setTemplateCode(CommonConstants.SMS_SYS_NOTIFY_TEMPLATE);
|
|
|
+ reqDTO.setTemplateParams(MapUtil.<String, Object>builder()
|
|
|
+ .put("1", notifySysStrMap.get(reqDTO.getTemplateCode()))
|
|
|
+ .build());
|
|
|
+ smsSendApi.sendSingleSmsToAdmin(smsReqDTO);
|
|
|
+ // 发送邮件
|
|
|
+ MailSendSingleToUserReqDTO emailReqDTO = new MailSendSingleToUserReqDTO();
|
|
|
+ emailReqDTO.setMail(data.getEmail());
|
|
|
+ emailReqDTO.setTemplateCode(CommonConstants.EMAIL_SYS_NOTIFY_TEMPLATE);
|
|
|
+ reqDTO.setTemplateParams(reqDTO.getTemplateParams());
|
|
|
+ mailSendApi.sendSingleMailToAdmin(emailReqDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 发送系统消息通知
|
|
|
+ notifyMessageSendApi.sendSingleMessageToAdmin(reqDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 发送im系统消息通知
|
|
|
*
|
|
@@ -69,6 +124,14 @@ public class MessageUtils {
|
|
|
imMessageApi.systemMessage(reqVo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发送im系统消息和微信订阅消息
|
|
|
+ *
|
|
|
+ * @param userId 用户id
|
|
|
+ * @param enterpriseId 企业id
|
|
|
+ * @param message 消息内容
|
|
|
+ * @param wxReq 微信订阅消息参数
|
|
|
+ */
|
|
|
@Async
|
|
|
public void sendSystemImAndWxSubscribeMessage(Long userId,
|
|
|
Long enterpriseId,
|