Search in sources :

Example 16 with MdcProductCategory

use of com.paascloud.provider.model.domain.MdcProductCategory in project paascloud-master by paascloud.

the class MdcProductServiceImpl method assembleProductDetailVo.

private ProductDetailVo assembleProductDetailVo(MdcProduct product) {
    ProductDetailVo productDetailVo = new ProductDetailVo();
    String mainImage = product.getMainImage();
    String subImages = product.getSubImages();
    if (StringUtils.isNotEmpty(mainImage)) {
        // 图片查询
        OptGetUrlRequest request = new OptGetUrlRequest();
        request.setAttachmentId(Long.valueOf(mainImage));
        request.setEncrypt(true);
        String url = opcRpcService.getFileUrl(request);
        productDetailVo.setMainImage(url);
    }
    if (StringUtils.isNotEmpty(subImages)) {
        List<String> urlList = Lists.newArrayList();
        List<String> subImageList = Splitter.on(GlobalConstant.Symbol.COMMA).trimResults().splitToList(subImages);
        for (final String subImage : subImageList) {
            OptGetUrlRequest request = new OptGetUrlRequest();
            request.setAttachmentId(Long.valueOf(subImage));
            request.setEncrypt(true);
            String url = opcRpcService.getFileUrl(request);
            urlList.add(url);
        }
        productDetailVo.setSubImages(Joiner.on(GlobalConstant.Symbol.COMMA).join(urlList));
    }
    productDetailVo.setId(product.getId());
    productDetailVo.setSubtitle(product.getSubtitle());
    productDetailVo.setPrice(product.getPrice());
    productDetailVo.setDetail(product.getDetail());
    productDetailVo.setName(product.getName());
    productDetailVo.setStatus(product.getStatus());
    productDetailVo.setStock(product.getStock());
    productDetailVo.setImageHost("");
    MdcProductCategory category = mdcProductCategoryService.getByCategoryId(product.getId());
    if (category == null) {
        // 默认根节点
        productDetailVo.setPid(0L);
    } else {
        productDetailVo.setPid(category.getPid());
    }
    return productDetailVo;
}
Also used : OptGetUrlRequest(com.paascloud.provider.model.dto.oss.OptGetUrlRequest) MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory) ProductDetailVo(com.paascloud.provider.model.vo.ProductDetailVo)

Example 17 with MdcProductCategory

use of com.paascloud.provider.model.domain.MdcProductCategory in project paascloud-master by paascloud.

the class MdcProductServiceImpl method buildCategoryIdList.

private List<Long> buildCategoryIdList(List<Long> categoryIdList, Long categoryId) {
    MdcProductCategory category = mdcProductCategoryService.getByCategoryId(categoryId);
    if (category != null) {
        categoryIdList.add(categoryId);
        buildCategoryIdList(categoryIdList, category.getPid());
    }
    return categoryIdList;
}
Also used : MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory)

Aggregations

MdcProductCategory (com.paascloud.provider.model.domain.MdcProductCategory)17 MdcBizException (com.paascloud.provider.exceptions.MdcBizException)3 ApiOperation (io.swagger.annotations.ApiOperation)2 PageInfo (com.github.pagehelper.PageInfo)1 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 LogAnnotation (com.paascloud.core.annotation.LogAnnotation)1 MdcProduct (com.paascloud.provider.model.domain.MdcProduct)1 ProductDto (com.paascloud.provider.model.dto.ProductDto)1 OptGetUrlRequest (com.paascloud.provider.model.dto.oss.OptGetUrlRequest)1 MdcCategoryVo (com.paascloud.provider.model.vo.MdcCategoryVo)1 ProductDetailVo (com.paascloud.provider.model.vo.ProductDetailVo)1 ModelMapper (org.modelmapper.ModelMapper)1