|
@@ -9,10 +9,7 @@ import com.example.xiaoshiweixinback.business.common.base.SystemFile;
|
|
|
import com.example.xiaoshiweixinback.business.exception.BusinessException;
|
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
|
-import com.example.xiaoshiweixinback.domain.AssoPersonFunction;
|
|
|
-import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
|
|
|
-import com.example.xiaoshiweixinback.domain.AssoProductFile;
|
|
|
-import com.example.xiaoshiweixinback.domain.Product;
|
|
|
+import com.example.xiaoshiweixinback.domain.*;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.product.*;
|
|
@@ -44,7 +41,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
private final FileManagerService fileManagerService;
|
|
|
private final AssoPersonProductService assoPersonProductService;
|
|
|
private final VipService vipService;
|
|
|
-
|
|
|
+ private ProductCategoryService productCategoryService;
|
|
|
/**
|
|
|
* 查询爆款产品
|
|
|
*
|
|
@@ -73,14 +70,16 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
if (ids != null) {
|
|
|
List<ProductVO> productVOs = this.getBaseMapper().getProductByCategory(getProductDTO);
|
|
|
Long count = this.getBaseMapper().getProductCount(getProductDTO);
|
|
|
- this.loadProduct(productVOs);
|
|
|
+ this.loadProduct(productVOs,false);
|
|
|
records.setData(productVOs);
|
|
|
records.setTotal(count);
|
|
|
}
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
- private void loadProduct(List<ProductVO> productVOS) {
|
|
|
+
|
|
|
+
|
|
|
+ private void loadProduct(List<ProductVO> productVOS,Boolean ifCotentCategoryPath) {
|
|
|
PersonnelVO personnelVO = null;
|
|
|
try {
|
|
|
personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
@@ -100,7 +99,9 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
return;
|
|
|
}
|
|
|
List<Integer> ids = productVOS.stream().map(ProductVO::getId).collect(Collectors.toList());
|
|
|
+ List<Integer> projectCategoryIds=productVOS.stream().map(ProductVO::getProductCategoryId).collect(Collectors.toList());
|
|
|
List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
+
|
|
|
if (ids.size() != 0) {
|
|
|
//根据产品类别id获得产品类别与文件关联表
|
|
|
LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -123,6 +124,12 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if(projectCategoryIds.size()!=0){
|
|
|
+ productCategoryService.getProductCategory(projectCategoryIds,ifCotentCategoryPath);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
for (ProductVO productVO : productVOS) {
|
|
|
//装载文件信息
|
|
|
List<AssoProductFile> assoProductFilesTemp = assoProductFiles.stream().filter(item -> item.getProductId().equals(productVO.getId())).collect(Collectors.toList());
|
|
@@ -136,15 +143,21 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //装载关注类型
|
|
|
if (assoPersonProducts.size() != 0) {
|
|
|
AssoPersonProduct assoPersonProduct = assoPersonProducts.stream().filter(item -> item.getProductId().equals(productVO.getId())).findFirst().orElse(null);
|
|
|
if (assoPersonProduct != null) {
|
|
|
productVO.setConcernType(assoPersonProduct.getConcernType());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
|
|
|
Product product = new Product();
|
|
@@ -212,7 +225,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
getProductDTO.setConcernTypes(productDTO.getConcernTypes());
|
|
|
List<ProductVO> productVOs = this.getBaseMapper().getConcernProduct(getProductDTO);
|
|
|
Long count = this.getBaseMapper().getConcernProductCount(getProductDTO);
|
|
|
- this.loadProduct(productVOs);
|
|
|
+ this.loadProduct(productVOs,false);
|
|
|
records.setData(productVOs);
|
|
|
records.setTotal(count);
|
|
|
return records;
|
|
@@ -259,7 +272,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
|
|
|
BeanUtils.copyProperties(product, productVO);
|
|
|
List<ProductVO> productVOS = new ArrayList<>();
|
|
|
productVOS.add(productVO);
|
|
|
- this.loadProduct(productVOS);
|
|
|
+ this.loadProduct(productVOS,true);
|
|
|
return productVO;
|
|
|
}
|
|
|
|