use of com.paascloud.provider.model.dto.PcSendEmailRequest in project paascloud-master by paascloud.
the class EmailProducer method sendEmailMq.
/**
* Send email mq.
*
* @param emailSet the email set
* @param emailTemplateEnum the email template enum
* @param param the param
*/
public MqMessageData sendEmailMq(Set<String> emailSet, UacEmailTemplateEnum emailTemplateEnum, AliyunMqTopicConstants.MqTagEnum tagEnum, Map<String, Object> param) {
log.info("pcSendEmailRequest - 发送邮件MQ. emailSet={}, param={}", emailSet, param);
String msgBody;
try {
Preconditions.checkArgument(emailTemplateEnum != null, "邮箱模板信息不存在");
PcSendEmailRequest request = new PcSendEmailRequest();
String templateLocation = emailTemplateEnum.getLocation();
String text = uacFreeMarkerService.getTemplate(param, templateLocation);
request.setText(text);
request.setTo(emailSet);
request.setSubject(emailTemplateEnum.getSubject());
msgBody = JSON.toJSONString(request);
} catch (Exception e) {
log.error("发送邮件验证码 smsMessage转换为json字符串失败", e);
throw new UacBizException(ErrorCodeEnum.UAC10011021);
}
String topic = tagEnum.getTopic();
String tag = tagEnum.getTag();
String key = RedisKeyUtil.createMqKey(topic, tag, emailSet.toString(), msgBody);
return new MqMessageData(msgBody, topic, tag, key);
}
use of com.paascloud.provider.model.dto.PcSendEmailRequest in project paascloud-master by paascloud.
the class OptSendEmailTopicConsumer method handlerSendEmailTopic.
/**
* Handler send email topic.
*
* @param body the body
* @param topicName the topic name
* @param tags the tags
* @param keys the keys
*/
public void handlerSendEmailTopic(String body, String topicName, String tags, String keys) {
MqMessage.checkMessage(body, keys, topicName);
PcSendEmailRequest request;
try {
request = JacksonUtil.parseJson(body, PcSendEmailRequest.class);
} catch (Exception e) {
log.error("发送短信MQ出现异常={}", e.getMessage(), e);
throw new IllegalArgumentException("处理MQ信息,JSON转换异常");
}
String subject = request.getSubject();
String text = request.getText();
Set<String> to = request.getTo();
optSendMailService.sendTemplateMail(subject, text, to);
}
Aggregations