|
@@ -7,8 +7,10 @@ import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
|
|
import cn.newfeifan.mall.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
|
import cn.newfeifan.mall.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
|
|
import cn.newfeifan.mall.module.product.controller.admin.category.vo.ProductCategorySaveReqVO;
|
|
import cn.newfeifan.mall.module.product.controller.admin.category.vo.ProductCategorySaveReqVO;
|
|
import cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryDO;
|
|
import cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryDO;
|
|
|
|
+import cn.newfeifan.mall.module.product.dal.dataobject.spu.ProductSpuDO;
|
|
import cn.newfeifan.mall.module.product.dal.mysql.category.ProductCategoryMapper;
|
|
import cn.newfeifan.mall.module.product.dal.mysql.category.ProductCategoryMapper;
|
|
import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
|
|
import cn.newfeifan.mall.module.product.service.spu.ProductSpuService;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
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.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -18,6 +20,7 @@ import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL;
|
|
import static cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL;
|
|
@@ -165,7 +168,19 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<ProductCategoryDO> getEnableCategoryList() {
|
|
|
|
|
|
+ public List<ProductCategoryDO> getEnableCategoryList(Long merchantId, Long shopId) {
|
|
|
|
+ if(merchantId != null && shopId != null) {
|
|
|
|
+ List<ProductSpuDO> spuDOS = productSpuService.getSpuListByMerchantIdAndShopId(merchantId, shopId);
|
|
|
|
+ List<Long> categoryIds = spuDOS.stream().map(ProductSpuDO::getCategoryId).distinct().collect(Collectors.toList());
|
|
|
|
+ List<ProductCategoryDO> productCategoryDOS = productCategoryMapper.selectList(new LambdaQueryWrapper<ProductCategoryDO>()
|
|
|
|
+ .eq(ProductCategoryDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
|
|
|
+ .in(ProductCategoryDO::getId, categoryIds));
|
|
|
|
+ List<ProductCategoryDO> parentCategory = productCategoryMapper.selectList(new LambdaQueryWrapper<ProductCategoryDO>()
|
|
|
|
+ .eq(ProductCategoryDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
|
|
|
+ .in(ProductCategoryDO::getId, productCategoryDOS.stream().map(ProductCategoryDO::getParentId).collect(Collectors.toList())));
|
|
|
|
+ productCategoryDOS.addAll(parentCategory);
|
|
|
|
+ return productCategoryDOS;
|
|
|
|
+ }
|
|
return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
return productCategoryMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
|
}
|
|
}
|
|
|
|
|