use of com.paascloud.provider.model.domain.MdcProduct 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.MdcProduct in project paascloud-master by paascloud.
the class MdcProductServiceImpl method getProductVo.
@Override
public ProductVo getProductVo(final Long id) {
MdcProduct mdcProduct = mdcProductMapper.selectByPrimaryKey(id);
ProductVo productVo = new ModelMapper().map(mdcProduct, ProductVo.class);
List<Long> categoryIdList = Lists.newArrayList();
buildCategoryIdList(categoryIdList, mdcProduct.getCategoryId());
// 获取分类节点集合
Collections.reverse(categoryIdList);
productVo.setCategoryIdList(categoryIdList);
// 获取图片集合
final OptBatchGetUrlRequest request = new OptBatchGetUrlRequest(mdcProduct.getProductCode());
request.setEncrypt(true);
List<ElementImgUrlDto> imgUrlList = opcRpcService.listFileUrl(request);
productVo.setImgUrlList(imgUrlList);
return productVo;
}
Aggregations