xiaoyong931011
2021-09-26 7ebf766e3a037d10d30c569437288c230e83d9a8
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 cc.mrbird.febs.mall.controller;
 
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.mall.entity.MallGoodsCategory;
import cc.mrbird.febs.mall.service.IAdminMallGoodsCategoryService;
import cc.mrbird.febs.mall.vo.AdminAddAddressTreeVo;
import cc.mrbird.febs.mall.vo.AdminMallGoodsCategoryTreeVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
 
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/goodsCategory")
public class AdminMallGoodsCategoryController extends BaseController {
 
    private final IAdminMallGoodsCategoryService goodsCategoryService;
 
    /**
     * 商品分类列表
     * @param mallGoodsCategory
     * @param request
     * @return
     */
    @GetMapping("categoryList")
    public FebsResponse getCategoryList(MallGoodsCategory mallGoodsCategory, QueryRequest request) {
        Map<String, Object> data = getDataTable(goodsCategoryService.getCategoryList(mallGoodsCategory, request));
        return new FebsResponse().success().data(data);
    }
 
    @GetMapping("categorys")
    public FebsResponse getCategorys(MallGoodsCategory mallGoodsCategory) {
        return new FebsResponse().success().data(goodsCategoryService.getCategorys(mallGoodsCategory));
    }
 
    /**
     * 商品分类-选择
     */
    @GetMapping("categorys/tree")
    @ControllerEndpoint(exceptionMessage = "获取分类失败")
    public List<AdminMallGoodsCategoryTreeVo> getParentCategorys(){
        return goodsCategoryService.getParentCategorys();
    }
 
    /**
     * 商品分类-新增
     */
    @PostMapping("addCategory")
    @ControllerEndpoint(operation = " 商品分类-新增", exceptionMessage = "操作失败")
    public FebsResponse addCategory(@Valid MallGoodsCategory mallGoodsCategory) {
        return goodsCategoryService.addCategory(mallGoodsCategory);
    }
 
    /**
     * 商品分类-编辑
     */
    @PostMapping("updateCategory")
    @ControllerEndpoint(operation = " 商品分类-编辑", exceptionMessage = "操作失败")
    public FebsResponse updateCategory(@Valid MallGoodsCategory mallGoodsCategory) {
        return goodsCategoryService.updateCategory(mallGoodsCategory);
    }
}