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

修改产品分类与公司查询

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