xiangpei
7 天以前 288ce585418550bbf2fd898fc01bc2ff9245f960
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
package cn.lili.controller.goods;
 
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.StoreGoodsLabel;
import cn.lili.modules.goods.entity.vos.StoreGoodsLabelVO;
import cn.lili.modules.goods.service.StoreGoodsLabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Objects;
 
 
/**
 * 店铺端,店铺分类接口
 *
 * @author Bulbasaur
 * @since 2020/11/17 2:32 下午
 */
@Api(tags = "店铺端,店铺分类接口")
@RestController
@RequestMapping("/store/goods/label")
public class GoodsLabelStoreController {
 
    /**
     * 店铺分类
     */
    @Autowired
    private StoreGoodsLabelService storeGoodsLabelService;
 
    @ApiOperation(value = "获取当前店铺商品分类列表")
    @GetMapping
    public ResultMessage<List<StoreGoodsLabelVO>> list() {
        String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
        return ResultUtil.data(storeGoodsLabelService.listByStoreId(storeId));
    }
 
    @ApiImplicitParam(name = "id", value = "店铺商品分类ID", required = true, paramType = "path")
    @ApiOperation(value = "获取店铺商品分类详情")
    @GetMapping("/get/{id}")
    public ResultMessage<StoreGoodsLabel> getStoreGoodsLabel(@PathVariable String id) {
        return ResultUtil.data(OperationalJudgment.judgment(storeGoodsLabelService.getById(id)));
    }
 
    @ApiOperation(value = "添加店铺商品分类")
    @PostMapping
    public ResultMessage<StoreGoodsLabel> add(@Validated StoreGoodsLabel storeGoodsLabel) {
        String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
        storeGoodsLabel.setStoreId(storeId);
        return ResultUtil.data(storeGoodsLabelService.addStoreGoodsLabel(storeGoodsLabel));
    }
 
    @ApiOperation(value = "修改店铺商品分类")
    @PutMapping
    public ResultMessage<StoreGoodsLabel> edit(@Validated StoreGoodsLabel storeGoodsLabel) {
        OperationalJudgment.judgment(storeGoodsLabelService.getById(storeGoodsLabel.getId()));
        return ResultUtil.data(storeGoodsLabelService.editStoreGoodsLabel(storeGoodsLabel));
    }
 
    @ApiImplicitParam(name = "id", value = "店铺商品分类ID", required = true, paramType = "path")
    @ApiOperation(value = "删除店铺商品分类")
    @DeleteMapping("/{id}")
    public ResultMessage<StoreGoodsLabel> delete(@PathVariable String id) {
        OperationalJudgment.judgment(storeGoodsLabelService.getById(id));
        storeGoodsLabelService.removeStoreGoodsLabel(id);
        return ResultUtil.success();
    }
}