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