old mode 100644
new mode 100755
| | |
| | | import com.java110.dto.product.ProductSpecDto; |
| | | import com.java110.dto.productAttr.ProductAttrDto; |
| | | import com.java110.dto.productDetail.ProductDetailDto; |
| | | import com.java110.dto.productLabel.ProductLabelDto; |
| | | import com.java110.dto.productSpecValue.ProductSpecValueDto; |
| | | import com.java110.goods.bmo.product.IDeleteProductBMO; |
| | | import com.java110.goods.bmo.product.IGetProductBMO; |
| | |
| | | import com.java110.goods.bmo.productDetail.IGetProductDetailBMO; |
| | | import com.java110.goods.bmo.productDetail.ISaveProductDetailBMO; |
| | | import com.java110.goods.bmo.productDetail.IUpdateProductDetailBMO; |
| | | import com.java110.goods.bmo.productLabel.IDeleteProductLabelBMO; |
| | | import com.java110.goods.bmo.productLabel.IGetProductLabelBMO; |
| | | import com.java110.goods.bmo.productLabel.ISaveProductLabelBMO; |
| | | import com.java110.goods.bmo.productLabel.IUpdateProductLabelBMO; |
| | | import com.java110.goods.bmo.productSpec.IDeleteProductSpecBMO; |
| | | import com.java110.goods.bmo.productSpec.IGetProductSpecBMO; |
| | | import com.java110.goods.bmo.productSpec.ISaveProductSpecBMO; |
| | |
| | | import com.java110.po.product.ProductSpecPo; |
| | | import com.java110.po.productAttr.ProductAttrPo; |
| | | import com.java110.po.productDetail.ProductDetailPo; |
| | | import com.java110.po.productLabel.ProductLabelPo; |
| | | import com.java110.po.productSpecValue.ProductSpecValuePo; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestHeader; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | @RestController |
| | | @RequestMapping(value = "/product") |
| | | public class ProductApi { |
| | | |
| | | @Autowired |
| | | private ISaveProductLabelBMO saveProductLabelBMOImpl; |
| | | @Autowired |
| | | private IUpdateProductLabelBMO updateProductLabelBMOImpl; |
| | | @Autowired |
| | | private IDeleteProductLabelBMO deleteProductLabelBMOImpl; |
| | | |
| | | @Autowired |
| | | private IGetProductLabelBMO getProductLabelBMOImpl; |
| | | |
| | | @Autowired |
| | | private ISaveProductBMO saveProductBMOImpl; |
| | |
| | | |
| | | JSONObject spec = null; |
| | | List<ProductSpecValuePo> productSpecValuePos = new ArrayList<>(); |
| | | boolean hasDefault = false; |
| | | ProductSpecValuePo productSpecValuePo = null; |
| | | for (int specIndex = 0; specIndex < productSpecs.size(); specIndex++) { |
| | | spec = productSpecs.getJSONObject(specIndex); |
| | | productSpecValuePos.add(BeanConvertUtil.covertBean(spec, ProductSpecValuePo.class)); |
| | | productSpecValuePo = BeanConvertUtil.covertBean(spec, ProductSpecValuePo.class); |
| | | productSpecValuePos.add(productSpecValuePo); |
| | | if("T".equals(productSpecValuePo.getIsDefault())){ |
| | | hasDefault = true; |
| | | } |
| | | } |
| | | |
| | | if(!hasDefault){ |
| | | throw new IllegalArgumentException("请求报文中未包含默认规格"); |
| | | } |
| | | |
| | | ProductPo productPo = BeanConvertUtil.covertBean(reqJson, ProductPo.class); |
| | |
| | | JSONArray productSpecs = reqJson.containsKey("productSpecs") ? reqJson.getJSONArray("productSpecs") : null; |
| | | |
| | | JSONObject spec = null; |
| | | List<ProductSpecValuePo> productSpecValuePos = null;; |
| | | List<ProductSpecValuePo> productSpecValuePos = null; |
| | | |
| | | boolean hasDefault = false; |
| | | ProductSpecValuePo productSpecValuePo = null; |
| | | if (productSpecs != null) { |
| | | productSpecValuePos = new ArrayList<>(); |
| | | for (int specIndex = 0; specIndex < productSpecs.size(); specIndex++) { |
| | | spec = productSpecs.getJSONObject(specIndex); |
| | | productSpecValuePos.add(BeanConvertUtil.covertBean(spec, ProductSpecValuePo.class)); |
| | | productSpecValuePo = BeanConvertUtil.covertBean(spec, ProductSpecValuePo.class); |
| | | productSpecValuePos.add(productSpecValuePo); |
| | | if("T".equals(productSpecValuePo.getIsDefault())){ |
| | | hasDefault = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(!hasDefault){ |
| | | throw new IllegalArgumentException("请求报文中未包含默认规格"); |
| | | } |
| | | |
| | | ProductPo productPo = BeanConvertUtil.covertBean(reqJson, ProductPo.class); |
| | |
| | | |
| | | |
| | | ProductDetailPo productDetailPo = null; |
| | | if(reqJson.containsKey("content")) { |
| | | if (reqJson.containsKey("content")) { |
| | | productDetailPo = new ProductDetailPo(); |
| | | productDetailPo.setStoreId(storeId); |
| | | productDetailPo.setContent(reqJson.getString("content")); |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /productDetail/saveProductDetail |
| | | * @path /app/productDetail/saveProductDetail |
| | | * @serviceCode /product/saveProductDetail |
| | | * @path /app/product/saveProductDetail |
| | | */ |
| | | @RequestMapping(value = "/saveProductDetail", method = RequestMethod.POST) |
| | | public ResponseEntity<String> saveProductDetail(@RequestBody JSONObject reqJson, |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /productDetail/updateProductDetail |
| | | * @path /app/productDetail/updateProductDetail |
| | | * @serviceCode /product/updateProductDetail |
| | | * @path /app/product/updateProductDetail |
| | | */ |
| | | @RequestMapping(value = "/updateProductDetail", method = RequestMethod.POST) |
| | | public ResponseEntity<String> updateProductDetail(@RequestBody JSONObject reqJson, |
| | |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /productDetail/deleteProductDetail |
| | | * @path /app/productDetail/deleteProductDetail |
| | | * @serviceCode /product/deleteProductDetail |
| | | * @path /app/product/deleteProductDetail |
| | | */ |
| | | @RequestMapping(value = "/deleteProductDetail", method = RequestMethod.POST) |
| | | public ResponseEntity<String> deleteProductDetail(@RequestBody JSONObject reqJson, @RequestHeader(value = "store-id") String storeId) { |
| | |
| | | * |
| | | * @param storeId 小区ID |
| | | * @return |
| | | * @serviceCode /productDetail/queryProductDetail |
| | | * @path /app/productDetail/queryProductDetail |
| | | * @serviceCode /product/queryProductDetail |
| | | * @path /app/product/queryProductDetail |
| | | */ |
| | | @RequestMapping(value = "/queryProductDetail", method = RequestMethod.GET) |
| | | public ResponseEntity<String> queryProductDetail(@RequestHeader(value = "store-id") String storeId, |
| | |
| | | productDetailDto.setProductId(productId); |
| | | return getProductDetailBMOImpl.get(productDetailDto); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信保存消息模板 |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /product/saveProductLabel |
| | | * @path /app/product/saveProductLabel |
| | | */ |
| | | @RequestMapping(value = "/saveProductLabel", method = RequestMethod.POST) |
| | | public ResponseEntity<String> saveProductLabel(@RequestBody JSONObject reqJson) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "labelCd", "请求报文中未包含labelCd"); |
| | | Assert.hasKeyAndValue(reqJson, "productId", "请求报文中未包含productId"); |
| | | |
| | | |
| | | ProductLabelPo productLabelPo = BeanConvertUtil.covertBean(reqJson, ProductLabelPo.class); |
| | | return saveProductLabelBMOImpl.save(productLabelPo); |
| | | } |
| | | |
| | | /** |
| | | * 微信修改消息模板 |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /product/updateProductLabel |
| | | * @path /app/product/updateProductLabel |
| | | */ |
| | | @RequestMapping(value = "/updateProductLabel", method = RequestMethod.POST) |
| | | public ResponseEntity<String> updateProductLabel(@RequestBody JSONObject reqJson) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "labelCd", "请求报文中未包含labelCd"); |
| | | Assert.hasKeyAndValue(reqJson, "productId", "请求报文中未包含productId"); |
| | | Assert.hasKeyAndValue(reqJson, "labelId", "labelId不能为空"); |
| | | |
| | | |
| | | ProductLabelPo productLabelPo = BeanConvertUtil.covertBean(reqJson, ProductLabelPo.class); |
| | | return updateProductLabelBMOImpl.update(productLabelPo); |
| | | } |
| | | |
| | | /** |
| | | * 微信删除消息模板 |
| | | * |
| | | * @param reqJson |
| | | * @return |
| | | * @serviceCode /product/deleteProductLabel |
| | | * @path /app/product/deleteProductLabel |
| | | */ |
| | | @RequestMapping(value = "/deleteProductLabel", method = RequestMethod.POST) |
| | | public ResponseEntity<String> deleteProductLabel(@RequestBody JSONObject reqJson) { |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "labelId", "labelId不能为空"); |
| | | |
| | | |
| | | ProductLabelPo productLabelPo = BeanConvertUtil.covertBean(reqJson, ProductLabelPo.class); |
| | | return deleteProductLabelBMOImpl.delete(productLabelPo); |
| | | } |
| | | |
| | | /** |
| | | * 微信删除消息模板 |
| | | * |
| | | * @return |
| | | * @serviceCode /product/queryProductLabel |
| | | * @path /app/product/queryProductLabel |
| | | */ |
| | | @RequestMapping(value = "/queryProductLabel", method = RequestMethod.GET) |
| | | public ResponseEntity<String> queryProductLabel(@RequestParam(value = "labelCd", required = false) String labelCd, |
| | | @RequestParam(value = "hasProduct", required = false) String hasProduct, |
| | | @RequestParam(value = "page") int page, |
| | | @RequestParam(value = "row") int row) { |
| | | ProductLabelDto productLabelDto = new ProductLabelDto(); |
| | | productLabelDto.setPage(page); |
| | | productLabelDto.setRow(row); |
| | | productLabelDto.setLabelCd(labelCd); |
| | | productLabelDto.setHasProduct(hasProduct); |
| | | return getProductLabelBMOImpl.get(productLabelDto); |
| | | } |
| | | |
| | | } |