ProductCategoryManagementController 中
@RequestMapping(value = "/addproductcategories", method = RequestMethod.POST)
@ResponseBody
private Map<String, Object> addProductCategories(@RequestBody List<ProductCategory> productCategoryList, HttpServletRequest request) {
Map<String, Object> modelMap = new HashMap<>();
Shop currentShop = (Shop) request.getSession().getAttribute("currentShop");
for (ProductCategory productCategory : productCategoryList) {
productCategory.setShopId(currentShop.getShopId());
}
if (productCategoryList != null && productCategoryList.size() > 0) {
...
} else {
modelMap.put("success", false);
modelMap.put("errMsg","请至少输入一个商品类别");
}
ProductCategoryServiceImpl
@Override
public ProductCategoryExecution batchAddProductCategory(List<ProductCategory> productCategoryList) throws ProductCategoryOperationException {
if (productCategoryList != null && productCategoryList.size() > 0) {
...
} else {
return new ProductCategoryExecution(ProductCategoryStateEnum.EMPTY_LIST);
}
如果在Controller层发现这个数组为空了,就不会触发Service层的return new ProductCategoryExecution(ProductCategoryStateEnum.EMPTY_LIST);
了吧……
所以不是很理解额。
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程