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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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.common.utils.AppContants;
import cc.mrbird.febs.mall.entity.MallGoodsCategory;
import cc.mrbird.febs.mall.service.IAdminMallGoodsCategoryService;
import cc.mrbird.febs.mall.service.IApiMallGoodsCategoryService;
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.*;
 
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
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;
    private final IApiMallGoodsCategoryService mallGoodsCategoryService;
 
    /**
     * 商品分类列表
     * @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(value = "/categoryTree")
    public FebsResponse categoryTree() {
        return new FebsResponse().success().data(mallGoodsCategoryService.findAllCategoryList());
    }
 
    @GetMapping(value = "/categoryAppTree")
    public FebsResponse categoryAppTree() {
        return new FebsResponse().success().data(mallGoodsCategoryService.findAllAppCategoryList());
    }
 
    /**
     * 商品分类-选择
     */
    @GetMapping("categorys/tree")
    @ControllerEndpoint(exceptionMessage = "获取分类失败")
    public List<AdminMallGoodsCategoryTreeVo> getParentCategorys(){
        return goodsCategoryService.getParentCategorys();
    }
 
    /**
     * 商品分类-全部选择
     */
    @GetMapping("categorys/allTree")
    @ControllerEndpoint(exceptionMessage = "获取分类失败")
    public List<AdminMallGoodsCategoryTreeVo> getAllCategorys(){
        return goodsCategoryService.getAllCategorys();
    }
 
    /**
     * 商品分类-新增
     */
    @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);
    }
 
    /**
     * 商品分类-删除
     */
    @GetMapping("delCategary/{id}")
    @ControllerEndpoint(operation = " 商品分类-删除", exceptionMessage = "操作失败")
    public FebsResponse delCategary(@NotNull(message = "{required}") @PathVariable Long id) {
        return goodsCategoryService.delCategary(id);
    }
 
    /**
     * APP商品分类列表
     * @param mallGoodsCategory
     * @param request
     * @return
     */
    @GetMapping("categoryAppList")
    public FebsResponse categoryAppList(MallGoodsCategory mallGoodsCategory, QueryRequest request) {
        mallGoodsCategory.setIsApp(AppContants.IS_APP_CATEGORY);
        Map<String, Object> data = getDataTable(goodsCategoryService.getCategoryList(mallGoodsCategory, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 商品分类-新增
     */
    @PostMapping("addAppCategory")
    @ControllerEndpoint(operation = " 商品分类-新增", exceptionMessage = "操作失败")
    public FebsResponse addAppCategory(@Valid MallGoodsCategory mallGoodsCategory) {
        return goodsCategoryService.addAppCategory(mallGoodsCategory);
    }
    /**
     * 商品分类-编辑
     */
    @PostMapping("updateAppCategory")
    @ControllerEndpoint(operation = " 商品分类-编辑", exceptionMessage = "操作失败")
    public FebsResponse updateAppCategory(@Valid MallGoodsCategory mallGoodsCategory) {
        return goodsCategoryService.updateAppCategory(mallGoodsCategory);
    }
    /**
     * 商品分类-删除
     */
    @GetMapping("delAppCategary/{id}")
    @ControllerEndpoint(operation = " 商品分类-删除", exceptionMessage = "操作失败")
    public FebsResponse delAppCategary(@NotNull(message = "{required}") @PathVariable Long id) {
        return goodsCategoryService.delAppCategary(id);
    }
 
 
}