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;
}
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;
}
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());
}
}
}
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();
}
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();
}
Aggregations