Commit a1553220 authored by 赵啸非's avatar 赵啸非

修改产品分类与公司查询

parent 8d8da1b5
package com.mortals.xhx.module.product.service.impl; package com.mortals.xhx.module.product.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
...@@ -219,12 +220,19 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -219,12 +220,19 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
} }
if (!ObjectUtils.isEmpty(entity.getCompanyId())) { if (!ObjectUtils.isEmpty(entity.getCompanyId())) {
List<CompanyProductEntity> companyProductList = Arrays.asList(entity.getCompanyId().split(",")).stream().map(item -> {
Long[] companyProductRemoveIds = companyProductService.find(new CompanyProductQuery().productId(Long.parseLong(item))).stream().map(i -> i.getId()).toArray(Long[]::new); List<Long> companyList = Arrays.asList(entity.getCompanyId().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(companyProductRemoveIds)) {
companyProductService.remove(companyProductRemoveIds, context); CompanyProductQuery companyProductQuery = new CompanyProductQuery();
} companyProductQuery.setProductId(entity.getId());
CompanyEntity companyEntity = companyService.get(Long.parseLong(item), context); companyProductQuery.setCompanyIdList(companyList);
Long[] companyProductRemoveIds = companyProductService.find(companyProductQuery).stream().map(i -> i.getId()).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(companyProductRemoveIds)) {
companyProductService.remove(companyProductRemoveIds, context);
}
List<CompanyProductEntity> companyProductList = companyList.stream().map(item -> {
CompanyEntity companyEntity = companyService.get(item, context);
CompanyProductEntity companyProductEntity = new CompanyProductEntity(); CompanyProductEntity companyProductEntity = new CompanyProductEntity();
companyProductEntity.initAttrValue(); companyProductEntity.initAttrValue();
companyProductEntity.setProductId(entity.getId()); companyProductEntity.setProductId(entity.getId());
...@@ -241,13 +249,18 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -241,13 +249,18 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
} }
if (!ObjectUtils.isEmpty(entity.getCategoryId())) { if (!ObjectUtils.isEmpty(entity.getCategoryId())) {
List<ProductCategoryEntity> productCategoryList = Arrays.asList(entity.getCategoryId().split(",")).stream().map(item -> { List<Long> categoryList = Arrays.asList(entity.getCategoryId().split(",")).stream().map(i->Long.parseLong(i)).collect(Collectors.toList());
Long[] productCategoryRemoveIds = productCategoryService.find(new ProductCategoryQuery().productId(Long.parseLong(item))).stream().map(i -> i.getId()).toArray(Long[]::new); ProductCategoryQuery productCategoryQuery = new ProductCategoryQuery();
if (!ObjectUtils.isEmpty(productCategoryRemoveIds)) { productCategoryQuery.setProductId(entity.getId());
productCategoryService.remove(productCategoryRemoveIds, context); productCategoryQuery.setCategoryIdList(categoryList);
}
Long[] productCategoryRemoveIds = productCategoryService.find(productCategoryQuery).stream().map(i -> i.getId()).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(productCategoryRemoveIds)) {
productCategoryService.remove(productCategoryRemoveIds, context);
}
CategoryEntity categoryEntity = categoryService.get(Long.parseLong(item), context); List<ProductCategoryEntity> productCategoryList = categoryList.stream().map(item -> {
CategoryEntity categoryEntity = categoryService.get(item, context);
ProductCategoryEntity productCategoryEntity = new ProductCategoryEntity(); ProductCategoryEntity productCategoryEntity = new ProductCategoryEntity();
productCategoryEntity.initAttrValue(); productCategoryEntity.initAttrValue();
productCategoryEntity.setProductId(entity.getId()); productCategoryEntity.setProductId(entity.getId());
...@@ -272,8 +285,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -272,8 +285,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
protected void removeAfter(Long[] ids, Context context, int result) throws AppException { protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
List<ProductQuestionEntity> productQuestionlist = productQuestionService.find(new ProductQuestionQuery().productIdList(Arrays.asList(ids))); List<ProductQuestionEntity> productQuestionlist = productQuestionService.find(new ProductQuestionQuery().productIdList(Arrays.asList(ids)));
productQuestionService.removeList(productQuestionlist, context); productQuestionService.removeList(productQuestionlist, context);
super.removeAfter(ids, context, result); super.removeAfter(ids, context, result);
} }
} }
\ No newline at end of file
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