Administrator
1 days ago 4bfe57af40d98331721124837950c4329ad12baf
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
package cc.mrbird.febs.ai.controller.productCategory;
 
import cc.mrbird.febs.ai.entity.AiProductCategory;
import cc.mrbird.febs.ai.service.AiProductCategoryService;
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.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;
 
/**
 * @author Administrator
 */
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/productCategory")
public class AiProductCategoryController extends BaseController {
 
    private final AiProductCategoryService service;
 
    @GetMapping("list")
    public FebsResponse list(AiProductCategory dto, QueryRequest request) {
        String companyId = getCurrentUserCompanyId();
        dto.setCompanyId(companyId);
 
        Map<String, Object> data = getDataTable(service.listInPage(dto, request));
        return new FebsResponse().success().data(data);
    }
 
    @GetMapping("changeState/{id}/{type}/{state}")
    @ControllerEndpoint(operation = "状态操作", exceptionMessage = "操作失败")
    public FebsResponse changeState(
            @NotNull(message = "{required}") @PathVariable String id,
            @NotNull(message = "{required}") @PathVariable Integer type,
            @NotNull(message = "{required}") @PathVariable Integer state
    ) {
 
        return service.changeState(id,type,state);
    }
 
    @PostMapping("add")
    @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
    public FebsResponse add(@RequestBody @Valid AiProductCategory dto) {
        String companyId = getCurrentUserCompanyId();
        dto.setCompanyId(companyId);
        return service.add(dto);
    }
 
    @PostMapping("update")
    @ControllerEndpoint(operation = "更新", exceptionMessage = "操作失败")
    public FebsResponse update(@RequestBody @Valid AiProductCategory dto) {
 
        return service.update(dto);
    }
 
    @GetMapping("delete/{id}")
    @ControllerEndpoint(operation = "删除", exceptionMessage = "操作失败")
    public FebsResponse delete(
            @NotNull(message = "{required}") @PathVariable String id
    ) {
 
        return service.delete(id);
    }
 
    @GetMapping(value = "/categoryTree")
    public FebsResponse categoryTree() {
 
        String companyId = getCurrentUserCompanyId();
        return new FebsResponse().success().data(service.categoryTree(companyId));
    }
 
    @GetMapping("categoryTree/parent")
    @ControllerEndpoint(exceptionMessage = "获取分类失败")
    public List<AiProductCategory> parent(){
 
        String companyId = getCurrentUserCompanyId();
        return service.parent(companyId);
    }
}