shiyj1101
2021-08-05 e57e32fc43da31917912eebb4e47d4e50df1a9e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package com.java110.goods.api;
 
import com.alibaba.fastjson.JSONObject;
import com.java110.dto.product.ProductCategoryDto;
import com.java110.goods.bmo.productCategory.IDeleteProductCategoryBMO;
import com.java110.goods.bmo.productCategory.IGetProductCategoryBMO;
import com.java110.goods.bmo.productCategory.ISaveProductCategoryBMO;
import com.java110.goods.bmo.productCategory.IUpdateProductCategoryBMO;
import com.java110.po.product.ProductCategoryPo;
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;
 
 
@RestController
@RequestMapping(value = "/productCategory")
public class ProductCategoryApi {
 
    @Autowired
    private ISaveProductCategoryBMO saveProductCategoryBMOImpl;
    @Autowired
    private IUpdateProductCategoryBMO updateProductCategoryBMOImpl;
    @Autowired
    private IDeleteProductCategoryBMO deleteProductCategoryBMOImpl;
 
    @Autowired
    private IGetProductCategoryBMO getProductCategoryBMOImpl;
 
    /**
     * 微信保存消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /productCategory/saveProductCategory
     * @path /app/productCategory/saveProductCategory
     */
    @RequestMapping(value = "/saveProductCategory", method = RequestMethod.POST)
    public ResponseEntity<String> saveProductCategory(@RequestBody JSONObject reqJson,
                                                      @RequestHeader(value = "store-id") String storeId) {
 
        Assert.hasKeyAndValue(reqJson, "categoryName", "请求报文中未包含categoryName");
        Assert.hasKeyAndValue(reqJson, "categoryLevel", "请求报文中未包含categoryLevel");
        Assert.hasKeyAndValue(reqJson, "seq", "请求报文中未包含seq");
        Assert.hasKeyAndValue(reqJson, "isShow", "请求报文中未包含isShow");
 
 
        ProductCategoryPo productCategoryPo = BeanConvertUtil.covertBean(reqJson, ProductCategoryPo.class);
        productCategoryPo.setStoreId(storeId);
        if (!reqJson.containsKey("parentCategoryId")) {
            productCategoryPo.setParentCategoryId("-1");
        }
        return saveProductCategoryBMOImpl.save(productCategoryPo);
    }
 
    /**
     * 微信修改消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /productCategory/updateProductCategory
     * @path /app/productCategory/updateProductCategory
     */
    @RequestMapping(value = "/updateProductCategory", method = RequestMethod.POST)
    public ResponseEntity<String> updateProductCategory(@RequestBody JSONObject reqJson,
                                                        @RequestHeader(value = "store-id") String storeId) {
 
        Assert.hasKeyAndValue(reqJson, "categoryName", "请求报文中未包含categoryName");
        Assert.hasKeyAndValue(reqJson, "categoryLevel", "请求报文中未包含categoryLevel");
        Assert.hasKeyAndValue(reqJson, "seq", "请求报文中未包含seq");
        Assert.hasKeyAndValue(reqJson, "isShow", "请求报文中未包含isShow");
        Assert.hasKeyAndValue(reqJson, "categoryId", "categoryId不能为空");
 
 
        ProductCategoryPo productCategoryPo = BeanConvertUtil.covertBean(reqJson, ProductCategoryPo.class);
        productCategoryPo.setStoreId(storeId);
        return updateProductCategoryBMOImpl.update(productCategoryPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param reqJson
     * @return
     * @serviceCode /productCategory/deleteProductCategory
     * @path /app/productCategory/deleteProductCategory
     */
    @RequestMapping(value = "/deleteProductCategory", method = RequestMethod.POST)
    public ResponseEntity<String> deleteProductCategory(@RequestBody JSONObject reqJson,
                                                        @RequestHeader(value = "store-id") String storeId) {
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
 
        Assert.hasKeyAndValue(reqJson, "categoryId", "categoryId不能为空");
 
 
        ProductCategoryPo productCategoryPo = BeanConvertUtil.covertBean(reqJson, ProductCategoryPo.class);
        productCategoryPo.setStoreId(storeId);
        return deleteProductCategoryBMOImpl.delete(productCategoryPo);
    }
 
    /**
     * 微信删除消息模板
     *
     * @param storeId 商户ID
     * @return
     * @serviceCode /productCategory/queryProductCategory
     * @path /app/productCategory/queryProductCategory
     */
    @RequestMapping(value = "/queryProductCategory", method = RequestMethod.GET)
    public ResponseEntity<String> queryProductCategory(@RequestHeader(value = "store-id") String storeId,
                                                       @RequestParam(value = "page") int page,
                                                       @RequestParam(value = "row") int row) {
        ProductCategoryDto productCategoryDto = new ProductCategoryDto();
        productCategoryDto.setPage(page);
        productCategoryDto.setRow(row);
        productCategoryDto.setStoreId(storeId);
        return getProductCategoryBMOImpl.get(productCategoryDto);
    }
}