Search in sources :

Example 1 with PcSendEmailRequest

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);
}
Also used : PcSendEmailRequest(com.paascloud.provider.model.dto.PcSendEmailRequest) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) UacBizException(com.paascloud.provider.model.exceptions.UacBizException)

Example 2 with PcSendEmailRequest

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);
}
Also used : PcSendEmailRequest(com.paascloud.provider.model.dto.PcSendEmailRequest)

Aggregations

PcSendEmailRequest (com.paascloud.provider.model.dto.PcSendEmailRequest)2 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)1 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)1