yangys
2024-04-01 86cdd920b68274185233383f69ddb974052b6b6f
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
package com.qianwen.smartman.modules.system.controller;
 
import java.util.List;
import java.util.Map;
 
import javax.validation.Valid;
 
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.qianwen.core.boot.ctrl.BladeController;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.mp.support.Condition;
import com.qianwen.core.mp.support.Query;
import com.qianwen.core.scanner.modular.annotation.GetResource;
import com.qianwen.core.scanner.modular.annotation.PostResource;
import com.qianwen.core.scanner.modular.stereotype.ApiResource;
import com.qianwen.core.tenant.annotation.NonDS;
import com.qianwen.core.tool.api.R;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.constant.ExtCacheConstant;
import com.qianwen.smartman.modules.system.entity.DictBiz;
import com.qianwen.smartman.modules.system.service.IDictBizService;
import com.qianwen.smartman.modules.system.vo.DictBizVO;
import com.qianwen.smartman.modules.system.wrapper.DictBizWrapper;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore;
 
@Api(value = "业务字典", tags = {"业务字典"})
@RestController
@ApiResource({"blade-system/dict-biz"})
@NonDS
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/DictBizController.class */
public class DictBizController extends BladeController {
    private final IDictBizService dictService;
 
    public DictBizController(final IDictBizService dictService) {
        this.dictService = dictService;
    }
 
    @ApiOperationSupport(order = 1)
    @GetResource({"/detail"})
    @ApiOperation(value = "详情", notes = "传入dict")
    public R<DictBizVO> detail(DictBiz dict) {
        DictBiz detail = (DictBiz) this.dictService.getOne(Condition.getQueryWrapper(dict));
        return R.data(DictBizWrapper.build().entityVO(detail));
    }
 
    @ApiOperationSupport(order = 2)
    @ApiImplicitParams({@ApiImplicitParam(name = "code", value = "字典编号", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "dictValue", value = "字典名称", paramType = "query", dataType = "string")})
    @GetResource({"/list"})
    @ApiOperation(value = "列表", notes = "传入dict")
    public R<List<DictBizVO>> list(@RequestParam @ApiIgnore Map<String, Object> dict) {
        List<DictBiz> list = this.dictService.list(Condition.getQueryWrapper(dict, DictBiz.class).lambda().orderByAsc(DictBiz::getSort));
        /*
        List<DictBiz> list = this.dictService.list((Wrapper) Condition.getQueryWrapper(dict, DictBiz.class).lambda().orderByAsc((v0) -> {
            return v0.getSort();
        }));*/
        return R.data(DictBizWrapper.build().listNodeVO(list));
    }
 
    @ApiOperationSupport(order = 3)
    @ApiImplicitParams({@ApiImplicitParam(name = "code", value = "字典编号", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "dictValue", value = "字典名称", paramType = "query", dataType = "string")})
    @GetResource({"/parent-list"})
    @ApiOperation(value = "列表", notes = "传入dict")
    public R<IPage<DictBizVO>> parentList(@RequestParam @ApiIgnore Map<String, Object> dict, Query query) {
        return R.data(this.dictService.parentList(dict, query));
    }
 
    @ApiOperationSupport(order = 4)
    @ApiImplicitParams({@ApiImplicitParam(name = "code", value = "字典编号", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "dictValue", value = "字典名称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "parentId", value = "字典名称", paramType = "query", dataType = "string")})
    @GetResource({"/child-list"})
    @ApiOperation(value = "列表", notes = "传入dict")
    public R<List<DictBizVO>> childList(@RequestParam @ApiIgnore Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) {
        return R.data(this.dictService.childList(dict, parentId));
    }
 
    @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL)
    @GetResource({"/tree"})
    @ApiOperation(value = "树形结构", notes = "树形结构")
    public R<List<DictBizVO>> tree() {
        List<DictBizVO> tree = this.dictService.tree();
        return R.data(tree);
    }
 
    @ApiOperationSupport(order = RegionCache.VILLAGE_LEVEL)
    @GetResource({"/parent-tree"})
    @ApiOperation(value = "树形结构", notes = "树形结构")
    public R<List<DictBizVO>> parentTree() {
        List<DictBizVO> tree = this.dictService.parentTree();
        return R.data(tree);
    }
 
    @ApiOperationSupport(order = 6)
    @PostResource({"/submit"})
    @ApiOperation(value = "新增或修改", notes = "传入dict")
    public R submit(@Valid @RequestBody DictBiz dict) {
        CacheUtil.clear("blade:dict", ExtCacheConstant.TENANT_MODE);
        return R.status(this.dictService.submit(dict));
    }
 
    @ApiOperationSupport(order = 7)
    @PostResource({"/remove"})
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(@RequestParam @ApiParam(value = "主键集合", required = true) String ids) {
        CacheUtil.clear("blade:dict", ExtCacheConstant.TENANT_MODE);
        return R.status(this.dictService.removeDict(ids));
    }
 
    @ApiOperationSupport(order = 8)
    @GetResource({"/dictionary"})
    @ApiOperation(value = "获取字典", notes = "获取字典")
    public R<List<DictBiz>> dictionary(String code) {
        List<DictBiz> tree = this.dictService.getList(code);
        return R.data(tree);
    }
 
    @ApiOperationSupport(order = 9)
    @GetResource({"/dictionary-tree"})
    @ApiOperation(value = "获取字典树", notes = "获取字典树")
    public R<List<DictBizVO>> dictionaryTree(String code) {
        List<DictBiz> tree = this.dictService.getList(code);
        return R.data(DictBizWrapper.build().listNodeVO(tree));
    }
}