Search in sources :

Example 11 with MdcProductCategory

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

the class MdcProductCategoryServiceImpl method findChildCategory.

/**
 * 递归算法,算出子节点
 */
private Set<MdcProductCategory> findChildCategory(Set<MdcProductCategory> categorySet, Long categoryId) {
    MdcProductCategory category = mdcProductCategoryMapper.selectByPrimaryKey(categoryId);
    if (category != null) {
        categorySet.add(category);
    }
    // 查找子节点,递归算法一定要有一个退出的条件
    List<MdcProductCategory> categoryList = this.getProductCategoryListByPid(categoryId);
    for (MdcProductCategory categoryItem : categoryList) {
        findChildCategory(categorySet, categoryItem.getId());
    }
    return categorySet;
}
Also used : MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory)

Example 12 with MdcProductCategory

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

the class MdcProductCategoryServiceImpl method buildParentNote.

/**
 * 递归获取菜单的父菜单
 */
private List<MdcProductCategory> buildParentNote(List<MdcProductCategory> mdcCategoryList, MdcProductCategory mdcCategory) {
    List<MdcProductCategory> mdcCategoryQueryList = mapper.select(mdcCategory);
    MdcProductCategory uacMenuQuery;
    for (MdcProductCategory category : mdcCategoryQueryList) {
        if (MdcCategoryStatusEnum.DISABLE.getType() == category.getStatus()) {
            mdcCategoryList.add(category);
        }
        uacMenuQuery = new MdcProductCategory();
        uacMenuQuery.setId(category.getPid());
        buildParentNote(mdcCategoryList, uacMenuQuery);
    }
    return mdcCategoryList;
}
Also used : MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory)

Example 13 with MdcProductCategory

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

the class MdcProductCategoryServiceImpl method updateCategoryStatus.

private void updateCategoryStatus(List<MdcProductCategory> mdcCategoryList, LoginAuthDto loginAuthDto, int status) {
    MdcProductCategory update = new MdcProductCategory();
    for (MdcProductCategory category : mdcCategoryList) {
        update.setId(category.getId());
        update.setVersion(category.getVersion() + 1);
        update.setStatus(status);
        update.setUpdateInfo(loginAuthDto);
        int result = mapper.updateByPrimaryKeySelective(update);
        if (result < 1) {
            throw new MdcBizException(ErrorCodeEnum.MDC10023003, category.getId());
        }
    }
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory)

Example 14 with MdcProductCategory

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

the class MdcProductCategoryMainController method saveCategory.

@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "编辑商品分类")
@LogAnnotation
public Wrapper saveCategory(@ApiParam(name = "saveCategory", value = "编辑商品分类") @RequestBody MdcEditCategoryDto mdcCategoryAddDto) {
    MdcProductCategory mdcCategory = new MdcProductCategory();
    LoginAuthDto loginAuthDto = getLoginAuthDto();
    BeanUtils.copyProperties(mdcCategoryAddDto, mdcCategory);
    mdcProductCategoryService.saveMdcCategory(mdcCategory, loginAuthDto);
    return WrapMapper.ok();
}
Also used : MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) LogAnnotation(com.paascloud.core.annotation.LogAnnotation) ApiOperation(io.swagger.annotations.ApiOperation)

Example 15 with MdcProductCategory

use of com.paascloud.provider.model.domain.MdcProductCategory 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

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