Commit 3f6ca8fe authored by 赵啸非's avatar 赵啸非

修改产品分类编辑

parent 16730954
...@@ -14,6 +14,7 @@ import com.mortals.xhx.module.product.model.ProductCategoryQuery; ...@@ -14,6 +14,7 @@ import com.mortals.xhx.module.product.model.ProductCategoryQuery;
import com.mortals.xhx.module.product.service.ProductCategoryService; import com.mortals.xhx.module.product.service.ProductCategoryService;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -80,8 +81,13 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product ...@@ -80,8 +81,13 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product
protected int editAfter(Long id, Map<String, Object> model, ProductEntity entity, Context context) throws AppException { protected int editAfter(Long id, Map<String, Object> model, ProductEntity entity, Context context) throws AppException {
String categoryIds = productCategoryService.find(new ProductCategoryQuery().productId(entity.getId())).stream().map(i -> i.getCategoryId().toString()).collect(Collectors.joining(",")); String categoryIds = productCategoryService.find(new ProductCategoryQuery().productId(entity.getId())).stream().map(i -> i.getCategoryId().toString()).collect(Collectors.joining(","));
String companyIds = companyProductService.find(new CompanyProductQuery().productId(entity.getId())).stream().map(i -> i.getProductId().toString()).collect(Collectors.joining(",")); String companyIds = companyProductService.find(new CompanyProductQuery().productId(entity.getId())).stream().map(i -> i.getProductId().toString()).collect(Collectors.joining(","));
entity.setCompanyId(companyIds);
entity.setCategoryId(categoryIds); if (!ObjectUtils.isEmpty(categoryIds)) {
entity.setCategoryId(categoryIds);
}
if (!ObjectUtils.isEmpty(companyIds)) {
entity.setCompanyId(companyIds);
}
return super.editAfter(id, model, entity, context); return super.editAfter(id, model, entity, context);
} }
} }
\ 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