| | |
| | | Assert.hasKeyAndValue(reqJson, "unitName", "请求报文中未包含unitName"); |
| | | Assert.hasKeyAndValue(reqJson, "sort", "请求报文中未包含sort"); |
| | | Assert.hasKeyAndValue(reqJson, "isPostage", "请求报文中未包含isPostage"); |
| | | Assert.hasKeyAndValue(reqJson, "coverPhoto", "请求报文中未包含商品封面"); |
| | | |
| | | Assert.hasKey(reqJson,"carouselFigurePhoto","请求报文中未包含轮播图"); |
| | | Assert.hasKey(reqJson,"productSpecs","请求报文中未包含规格信息"); |
| | | |
| | | |
| | | String coverPhoto = reqJson.getString("coverPhoto"); |
| | | JSONArray carouselFigurePhoto = reqJson.getJSONArray("carouselFigurePhoto"); |
| | | |
| | | JSONArray productSpecs = reqJson.getJSONArray("productSpecs"); |
| | | |
| | | if(carouselFigurePhoto.size() < 1){ |
| | | throw new IllegalArgumentException("请求报文中未包含轮播图"); |
| | | } |
| | | if(productSpecs.size() < 1){ |
| | | throw new IllegalArgumentException("请求报文中未包含规格信息"); |
| | | } |
| | | |
| | | JSONObject spec = null; |
| | | List<ProductSpecValuePo> productSpecValuePos = new ArrayList<>(); |
| | | for (int specIndex = 0; specIndex < productSpecs.size(); specIndex++) { |
| | | spec = productSpecs.getJSONObject(specIndex); |
| | | productSpecValuePos.add(BeanConvertUtil.covertBean(spec,ProductSpecValuePo.class)); |
| | | } |
| | | |
| | | ProductPo productPo = BeanConvertUtil.covertBean(reqJson, ProductPo.class); |
| | | productPo.setStoreId(storeId); |
| | | return saveProductBMOImpl.save(productPo); |
| | | return saveProductBMOImpl.save(productPo,coverPhoto,carouselFigurePhoto,productSpecValuePos); |
| | | } |
| | | |
| | | /** |