|
@@ -18,17 +18,16 @@ import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
|
|
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
|
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
|
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
|
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
+import jakarta.annotation.Resource;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
-import jakarta.annotation.Resource;
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
-import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue;
|
|
|
|
-import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
|
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
|
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
@@ -215,9 +214,15 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
Set<Long> categoryIds = new HashSet<>();
|
|
Set<Long> categoryIds = new HashSet<>();
|
|
if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) {
|
|
if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) {
|
|
categoryIds.add(pageReqVO.getCategoryId());
|
|
categoryIds.add(pageReqVO.getCategoryId());
|
|
- List<ProductCategoryDO> categoryChildren = categoryService.getEnableCategoryList(new ProductCategoryListReqVO()
|
|
|
|
- .setParentId(pageReqVO.getCategoryId()).setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
|
|
|
- categoryIds.addAll(CollectionUtils.convertList(categoryChildren, ProductCategoryDO::getId));
|
|
|
|
|
|
+ List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
|
|
|
|
+ .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentId(pageReqVO.getCategoryId()));
|
|
|
|
+ categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(pageReqVO.getCategoryIds())) {
|
|
|
|
+ categoryIds.addAll(pageReqVO.getCategoryIds());
|
|
|
|
+ List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
|
|
|
|
+ .setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentIds(pageReqVO.getCategoryIds()));
|
|
|
|
+ categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
|
|
}
|
|
}
|
|
// 分页查询
|
|
// 分页查询
|
|
return productSpuMapper.selectPage(pageReqVO, categoryIds);
|
|
return productSpuMapper.selectPage(pageReqVO, categoryIds);
|