Search in sources :

Example 1 with MdcProduct

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);
}
Also used : ProductDto(com.paascloud.provider.model.dto.ProductDto) MdcProduct(com.paascloud.provider.model.domain.MdcProduct) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with MdcProduct

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);
    }
}
Also used : MqMessageData(com.paascloud.provider.model.domain.MqMessageData) MdcProduct(com.paascloud.provider.model.domain.MdcProduct)

Example 3 with MdcProduct

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;
}
Also used : OptGetUrlRequest(com.paascloud.provider.model.dto.oss.OptGetUrlRequest) MdcProduct(com.paascloud.provider.model.domain.MdcProduct)

Example 4 with MdcProduct

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);
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcProduct(com.paascloud.provider.model.domain.MdcProduct)

Example 5 with MdcProduct

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();
}
Also used : PageInfo(com.github.pagehelper.PageInfo) MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory) MdcProduct(com.paascloud.provider.model.domain.MdcProduct) ProductDto(com.paascloud.provider.model.dto.ProductDto) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

MdcProduct (com.paascloud.provider.model.domain.MdcProduct)7 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)2 ProductDto (com.paascloud.provider.model.dto.ProductDto)2 ApiOperation (io.swagger.annotations.ApiOperation)2 PageInfo (com.github.pagehelper.PageInfo)1 MdcBizException (com.paascloud.provider.exceptions.MdcBizException)1 MdcProductCategory (com.paascloud.provider.model.domain.MdcProductCategory)1 UpdateAttachmentDto (com.paascloud.provider.model.dto.UpdateAttachmentDto)1 ElementImgUrlDto (com.paascloud.provider.model.dto.oss.ElementImgUrlDto)1 OptBatchGetUrlRequest (com.paascloud.provider.model.dto.oss.OptBatchGetUrlRequest)1 OptGetUrlRequest (com.paascloud.provider.model.dto.oss.OptGetUrlRequest)1 ProductVo (com.paascloud.provider.model.vo.ProductVo)1 ModelMapper (org.modelmapper.ModelMapper)1