Commit 8d8da1b5 authored by 赵啸非's avatar 赵啸非

修改产品分类与公司查询

parent 9f68db8d
...@@ -59,18 +59,31 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -59,18 +59,31 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
if (ObjectUtils.isEmpty(entity.getCategoryId()) && ObjectUtils.isEmpty(entity.getCompanyId())) { if (ObjectUtils.isEmpty(entity.getCategoryId()) && ObjectUtils.isEmpty(entity.getCompanyId())) {
return super.find(entity, pageInfo, context); return super.find(entity, pageInfo, context);
} else { } else {
Integer hot = entity.getHot();
//针对不同查询返回不同结果集 //针对不同查询返回不同结果集
if (!ObjectUtils.isEmpty(entity.getCategoryId()) && ObjectUtils.isEmpty(entity.getCompanyId())) { if (!ObjectUtils.isEmpty(entity.getCategoryId()) && ObjectUtils.isEmpty(entity.getCompanyId())) {
Result<ProductCategoryEntity> productCategoryResult = productCategoryService.find(new ProductCategoryQuery().categoryId(Long.parseLong(entity.getCategoryId())), pageInfo, context); Result<ProductCategoryEntity> productCategoryResult = productCategoryService.find(new ProductCategoryQuery().categoryId(Long.parseLong(entity.getCategoryId())), pageInfo, context);
List<ProductEntity> productList = getProductEntitiesByCategory(entity, productCategoryResult); List<ProductEntity> productList = getProductEntitiesByCategory(entity, productCategoryResult);
if (!ObjectUtils.isEmpty(hot)) {
//过滤热门与非热门
productList = productList.stream().filter(f -> f.getHot() == hot).collect(Collectors.toList());
}
productEntityResult.setList(productList); productEntityResult.setList(productList);
productEntityResult.setPageInfo(productCategoryResult.getPageInfo()); productEntityResult.setPageInfo(productCategoryResult.getPageInfo());
productEntityResult.setDict(productCategoryResult.getDict()); productEntityResult.setDict(productCategoryResult.getDict());
} else if (ObjectUtils.isEmpty(entity.getCategoryId()) && !ObjectUtils.isEmpty(entity.getCompanyId())) { } else if (ObjectUtils.isEmpty(entity.getCategoryId()) && !ObjectUtils.isEmpty(entity.getCompanyId())) {
Result<CompanyProductEntity> companyProductEntityResult = companyProductService.find(new CompanyProductQuery().companyId(Long.parseLong(entity.getCompanyId())), pageInfo, context); Result<CompanyProductEntity> companyProductEntityResult = companyProductService.find(new CompanyProductQuery().companyId(Long.parseLong(entity.getCompanyId())), pageInfo, context);
List<CompanyProductEntity> companyProducList = companyProductEntityResult.getList(); List<CompanyProductEntity> companyProducList = companyProductEntityResult.getList();
List<ProductEntity> productList = getProductEntitiesByCompanyId(entity, companyProducList); List<ProductEntity> productList = getProductEntitiesByCompanyId(entity, companyProducList);
if (!ObjectUtils.isEmpty(hot)) {
//过滤热门与非热门
productList = productList.stream().filter(f -> f.getHot() == hot).collect(Collectors.toList());
}
productEntityResult.setList(productList); productEntityResult.setList(productList);
productEntityResult.setPageInfo(companyProductEntityResult.getPageInfo()); productEntityResult.setPageInfo(companyProductEntityResult.getPageInfo());
productEntityResult.setDict(companyProductEntityResult.getDict()); productEntityResult.setDict(companyProductEntityResult.getDict());
...@@ -85,6 +98,10 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -85,6 +98,10 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
//求2个list的交集 //求2个list的交集
List<ProductEntity> collect = CollUtil.intersection(productCategoryList, productCompanyList).stream().collect(Collectors.toList()); List<ProductEntity> collect = CollUtil.intersection(productCategoryList, productCompanyList).stream().collect(Collectors.toList());
if (!ObjectUtils.isEmpty(hot)) {
//过滤热门与非热门
collect = collect.stream().filter(f -> f.getHot() == hot).collect(Collectors.toList());
}
productEntityResult.setList(collect); productEntityResult.setList(collect);
pageInfo.setTotalResult(collect.size()); pageInfo.setTotalResult(collect.size());
productEntityResult.setPageInfo(pageInfo); productEntityResult.setPageInfo(pageInfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment