Search in sources :

Example 6 with MqMessageData

use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.

the class MdcProductServiceImpl method saveProduct.

@Override
public void saveProduct(final MdcEditProductDto mdcEditProductDto, final LoginAuthDto loginAuthDto) {
    String productCode = mdcEditProductDto.getProductCode();
    MdcProduct product = new MdcProduct();
    BeanUtils.copyProperties(mdcEditProductDto, product);
    List<Long> categoryIdList = mdcEditProductDto.getCategoryIdList();
    Long categoryId = categoryIdList.get(categoryIdList.size() - 1);
    product.setCategoryId(categoryId);
    List<Long> attachmentIdList = mdcEditProductDto.getAttachmentIdList();
    product.setUpdateInfo(loginAuthDto);
    if (PublicUtil.isNotEmpty(attachmentIdList)) {
        product.setMainImage(String.valueOf(attachmentIdList.get(0)));
        product.setSubImages(Joiner.on(GlobalConstant.Symbol.COMMA).join(attachmentIdList));
    }
    MqMessageData mqMessageData;
    if (product.isNew()) {
        productCode = String.valueOf(generateId());
    } else {
        Preconditions.checkArgument(StringUtils.isNotEmpty(productCode), ErrorCodeEnum.MDC10021024.msg());
    }
    product.setProductCode(productCode);
    UpdateAttachmentDto updateAttachmentDto = new UpdateAttachmentDto(productCode, attachmentIdList, loginAuthDto);
    String body = JSON.toJSONString(updateAttachmentDto);
    String topic = AliyunMqTopicConstants.MqTagEnum.UPDATE_ATTACHMENT.getTopic();
    String tag = AliyunMqTopicConstants.MqTagEnum.UPDATE_ATTACHMENT.getTag();
    String key = RedisKeyUtil.createMqKey(topic, tag, product.getProductCode(), body);
    if (product.isNew() && PublicUtil.isNotEmpty(attachmentIdList)) {
        product.setId(generateId());
        mqMessageData = new MqMessageData(body, topic, tag, key);
        mdcProductManager.saveProduct(mqMessageData, product, true);
    } else if (product.isNew() && PublicUtil.isEmpty(attachmentIdList)) {
        product.setId(generateId());
        mdcProductMapper.insertSelective(product);
    } else {
        mqMessageData = new MqMessageData(body, topic, tag, key);
        mdcProductManager.saveProduct(mqMessageData, product, false);
    }
}
Also used : UpdateAttachmentDto(com.paascloud.provider.model.dto.UpdateAttachmentDto) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) MdcProduct(com.paascloud.provider.model.domain.MdcProduct)

Example 7 with MqMessageData

use of com.paascloud.provider.model.domain.MqMessageData 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 8 with MqMessageData

use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.

the class SmsServiceImpl method sendSmsCode.

@Override
public void sendSmsCode(SmsMessage smsMessage, String ipAddr) {
    Preconditions.checkArgument(smsMessage != null, "短信参数不能为空");
    Preconditions.checkArgument(StringUtils.isNotEmpty(ipAddr), "非法的IP地址");
    String mobileNo = smsMessage.getMobileNo();
    Preconditions.checkArgument(StringUtils.isNotEmpty(mobileNo), "手机号码不能为空");
    String smsTemplateCode = smsMessage.getSmsTemplateCode();
    Preconditions.checkArgument(AliyunSmsConstants.SmsTempletEnum.isSmsTemplate(smsTemplateCode), "短信模板没有维护");
    smsMessage.setMobileNo(mobileNo);
    smsMessage.setOutId(ipAddr);
    AliyunSmsConstants.SmsTempletEnum templetEnum = AliyunSmsConstants.SmsTempletEnum.getEnum(smsTemplateCode);
    MqMessageData mqMessageData = smsProducer.sendSmsCodeMq(smsMessage, templetEnum);
    userManager.sendSmsCode(mqMessageData);
}
Also used : MqMessageData(com.paascloud.provider.model.domain.MqMessageData) AliyunSmsConstants(com.paascloud.base.constant.AliyunSmsConstants)

Example 9 with MqMessageData

use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.

the class EmailServiceImpl method submitResetPwdEmail.

@Override
public void submitResetPwdEmail(String email) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(email), ErrorCodeEnum.UAC10011018.msg());
    // 获取用户名
    UacUser uacUser = new UacUser();
    uacUser.setEmail(email);
    uacUser = uacUserService.selectOne(uacUser);
    if (uacUser == null) {
        throw new UacBizException(ErrorCodeEnum.UAC10011004, email);
    }
    String resetPwdKey = PubUtils.uuid() + UniqueIdGenerator.generateId();
    redisTemplate.opsForValue().set(RedisKeyUtil.getResetPwdTokenKey(resetPwdKey), uacUser, 7 * 24, TimeUnit.HOURS);
    Map<String, Object> param = Maps.newHashMap();
    param.put("loginName", uacUser.getLoginName());
    param.put("email", email);
    param.put("resetPwdUrl", resetPwdUrl + resetPwdKey);
    param.put("dateTime", DateUtil.formatDateTime(new Date()));
    Set<String> to = Sets.newHashSet();
    to.add(email);
    MqMessageData messageData = emailProducer.sendEmailMq(to, UacEmailTemplateEnum.RESET_PWD_SEND_MAIL, AliyunMqTopicConstants.MqTagEnum.FORGOT_PASSWORD_AUTH_CODE, param);
    userManager.submitResetPwdEmail(messageData);
}
Also used : UacUser(com.paascloud.provider.model.domain.UacUser) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) Date(java.util.Date)

Example 10 with MqMessageData

use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.

the class EmailServiceImpl method sendEmailCode.

@Override
public void sendEmailCode(SendEmailMessage sendEmailMessage, String loginName) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(loginName), "用户名不能为空");
    String email = sendEmailMessage.getEmail();
    Preconditions.checkArgument(StringUtils.isNotEmpty(email), ErrorCodeEnum.UAC10011018.msg());
    Preconditions.checkArgument(StringUtils.isNotEmpty(loginName), ErrorCodeEnum.UAC10011007.msg());
    // 解密
    email = decryptEmail(loginName, email);
    Example example = new Example(UacUser.class);
    Example.Criteria criteria = example.createCriteria();
    criteria.andEqualTo("email", email);
    criteria.andNotEqualTo("loginName", loginName);
    int result = uacUserService.selectCountByExample(example);
    if (result > 0) {
        throw new UacBizException(ErrorCodeEnum.UAC10011019);
    }
    String emailCode = RandomUtil.createNumberCode(6);
    String key = RedisKeyUtil.getSendEmailCodeKey(loginName, email);
    // 在redis中绑定验证码
    redisService.setKey(key, emailCode, 7 * 24, TimeUnit.HOURS);
    // 先写死 类型多了再抽方法
    Map<String, Object> param = Maps.newHashMap();
    param.put("loginName", loginName);
    param.put("email", email);
    param.put("emailCode", emailCode);
    param.put("dateTime", DateUtil.formatDateTime(new Date()));
    Set<String> to = Sets.newHashSet();
    to.add(email);
    MqMessageData mqMessageData = emailProducer.sendEmailMq(to, UacEmailTemplateEnum.RESET_USER_EMAIL, AliyunMqTopicConstants.MqTagEnum.RESET_LOGIN_PWD, param);
    userManager.sendEmailCode(mqMessageData);
}
Also used : Example(tk.mybatis.mapper.entity.Example) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) UacBizException(com.paascloud.provider.model.exceptions.UacBizException) Date(java.util.Date)

Aggregations

MqMessageData (com.paascloud.provider.model.domain.MqMessageData)10 UacBizException (com.paascloud.provider.model.exceptions.UacBizException)4 TpcBizException (com.paascloud.provider.exceptions.TpcBizException)2 MdcProduct (com.paascloud.provider.model.domain.MdcProduct)2 Date (java.util.Date)2 Around (org.aspectj.lang.annotation.Around)2 AliyunSmsConstants (com.paascloud.base.constant.AliyunSmsConstants)1 MqConsumerStore (com.paascloud.provider.annotation.MqConsumerStore)1 MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)1 UacUser (com.paascloud.provider.model.domain.UacUser)1 PcSendEmailRequest (com.paascloud.provider.model.dto.PcSendEmailRequest)1 PcSendSmsRequest (com.paascloud.provider.model.dto.PcSendSmsRequest)1 UpdateAttachmentDto (com.paascloud.provider.model.dto.UpdateAttachmentDto)1 DelayLevelEnum (com.paascloud.provider.model.enums.DelayLevelEnum)1 MqSendTypeEnum (com.paascloud.provider.model.enums.MqSendTypeEnum)1 List (java.util.List)1 MessageExt (org.apache.rocketmq.common.message.MessageExt)1 JoinPoint (org.aspectj.lang.JoinPoint)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Example (tk.mybatis.mapper.entity.Example)1