use of com.paascloud.provider.model.dto.UpdateAttachmentDto in project paascloud-master by paascloud.
the class MdcTopicConsumer method handlerSendSmsTopic.
/**
* Handler send sms topic.
*
* @param body the body
* @param topicName the topic name
* @param tags the tags
* @param keys the keys
*/
@Transactional(rollbackFor = Exception.class)
public void handlerSendSmsTopic(String body, String topicName, String tags, String keys) throws QiniuException {
MqMessage.checkMessage(body, keys, topicName);
if (StringUtils.equals(tags, AliyunMqTopicConstants.MqTagEnum.DELETE_ATTACHMENT.getTag())) {
List<Long> idList = opcAttachmentService.queryAttachmentByRefNo(body);
for (final Long id : idList) {
opcAttachmentService.deleteFile(id);
}
} else {
UpdateAttachmentDto attachmentDto;
try {
attachmentDto = JacksonUtil.parseJson(body, UpdateAttachmentDto.class);
} catch (Exception e) {
log.error("发送短信MQ出现异常={}", e.getMessage(), e);
throw new IllegalArgumentException("JSON转换异常", e);
}
opcAttachmentService.updateAttachment(attachmentDto);
}
}
use of com.paascloud.provider.model.dto.UpdateAttachmentDto 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);
}
}
Aggregations