use of com.paascloud.provider.model.domain.MdcProduct in project paascloud-master by paascloud.
the class MdcProductQueryFeignClient method selectById.
@Override
@ApiOperation(httpMethod = "POST", value = "根据商品ID查询商品信息")
public Wrapper<ProductDto> selectById(@PathVariable("productId") Long productId) {
logger.info("根据商品ID查询商品信息. productId={}", productId);
ProductDto productDto = null;
MdcProduct mdcProduct = mdcProductService.selectByKey(productId);
if (PublicUtil.isNotEmpty(mdcProduct)) {
productDto = new ProductDto();
BeanUtils.copyProperties(mdcProduct, productDto);
}
return WrapMapper.ok(productDto);
}
use of com.paascloud.provider.model.domain.MdcProduct in project paascloud-master by paascloud.
the class MdcProductServiceImpl method deleteProductById.
@Override
public void deleteProductById(final Long id) {
MdcProduct product = mdcProductMapper.selectByPrimaryKey(id);
if (product != null) {
String body = product.getProductCode();
String topic = AliyunMqTopicConstants.MqTagEnum.DELETE_ATTACHMENT.getTopic();
String tag = AliyunMqTopicConstants.MqTagEnum.DELETE_ATTACHMENT.getTag();
String key = RedisKeyUtil.createMqKey(topic, tag, product.getProductCode(), body);
MqMessageData mqMessageData = new MqMessageData(body, topic, tag, key);
mdcProductManager.deleteProduct(mqMessageData, id);
}
}
use of com.paascloud.provider.model.domain.MdcProduct in project paascloud-master by paascloud.
the class MdcProductServiceImpl method getMainImage.
@Override
public String getMainImage(final Long productId) {
MdcProduct product = mdcProductMapper.selectByPrimaryKey(productId);
String url = null;
if (product != null) {
final OptGetUrlRequest request = new OptGetUrlRequest();
request.setEncrypt(true);
request.setAttachmentId(Long.valueOf(product.getMainImage()));
request.setExpires(3600 * 12 * 7L);
url = opcRpcService.getFileUrl(request);
}
return url;
}
use of com.paascloud.provider.model.domain.MdcProduct in project paascloud-master by paascloud.
the class MdcProductServiceImpl method getProductDetail.
@Override
public ProductDetailVo getProductDetail(Long productId) {
logger.info("获取商品明细信息, productId={}", productId);
Preconditions.checkArgument(productId != null, ErrorCodeEnum.MDC10021021.msg());
MdcProduct product = mdcProductMapper.selectByPrimaryKey(productId);
if (product == null) {
throw new MdcBizException(ErrorCodeEnum.MDC10021017, productId);
}
if (product.getStatus() != MallConstant.ProductStatusEnum.ON_SALE.getCode()) {
throw new MdcBizException(ErrorCodeEnum.MDC10021017, productId);
}
return assembleProductDetailVo(product);
}
use of com.paascloud.provider.model.domain.MdcProduct in project paascloud-master by paascloud.
the class MdcProductCategoryQueryFeignClient method getProductList.
/**
* 获取商品列表信息.
*
* @param productReqDto the product req dto
*
* @return the product list
*/
@Override
@ApiOperation(httpMethod = "POST", value = "获取商品列表信息")
public Wrapper<PageInfo> getProductList(@RequestBody ProductReqDto productReqDto) {
logger.info("获取商品列表信息. productReqDto={}", productReqDto);
Long categoryId = productReqDto.getCategoryId();
String keyword = productReqDto.getKeyword();
Integer pageNum = productReqDto.getPageNum();
Integer pageSize = productReqDto.getPageSize();
String orderBy = productReqDto.getOrderBy();
if (StringUtils.isBlank(keyword) && null == categoryId) {
return WrapMapper.ok(new PageInfo());
}
List<Long> categoryIdList = Lists.newArrayList();
if (categoryId != null) {
MdcProductCategory category = mdcProductCategoryService.selectByKey(categoryId);
if (category == null && StringUtils.isBlank(keyword)) {
// 没有该分类,并且还没有关键字,这个时候返回一个空的结果集,不报错
PageHelper.startPage(pageNum, pageSize);
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, new PageInfo());
}
categoryIdList = mdcProductCategoryService.selectCategoryAndChildrenById(categoryId);
}
PageHelper.startPage(pageNum, pageSize);
// 排序处理
List<MdcProduct> productList = mdcProductService.selectByNameAndCategoryIds(StringUtils.isBlank(keyword) ? null : keyword, PublicUtil.isEmpty(categoryIdList) ? null : categoryIdList, orderBy);
List<ProductDto> productListVoList = Lists.newArrayList();
for (MdcProduct product : productList) {
ProductDto productListVo = assembleProductListVo(product);
String url = mdcProductService.getMainImage(product.getId());
productListVo.setMainImage(url);
productListVoList.add(productListVo);
}
return PublicUtil.isNotEmpty(productListVoList) ? WrapMapper.ok(new PageInfo<>(productListVoList)) : WrapMapper.ok();
}
Aggregations