elkers
2025-04-07 2dba8dbb14af4616eec876fd9af744651e8beeda
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
144
145
/**
#                                                    __----~~~~~~~~~~~------___
#                                   .  .   ~~//====......          __--~ ~~
#                   -.            \_|//     |||\\  ~~~~~~::::... /~
#                ___-==_       _-~o~  \/    |||  \\            _/~~-
#        __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
#    _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
#  .~       .~       |   \\ -_    /  /-   /   ||      \   /
# /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
# |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
#          '         ~-|      /|    |-~\~~       __--~~
#                      |-~~-_/ |    |   ~\_   _-~            /\
#                           /  \     \__   \/~                \__
#                       _--~ _/ | .-~~____--~-/                  ~~==.
#                      ((->/~   '.|||' -_|    ~~-/ ,              . _||
#                                 -_     ~\      ~~---l__i__i__i--~~_/
#                                 _-~-__   ~)  \--______________--~~
#                               //.-~~~-~_--~- |-------~~~~~~~~
#                                      //.-~~~--\
#                  神兽保佑
#                  永无BUG!
*/
package com.nanjing.water.host.controller.base;
 
import com.nanjing.water.common.ExecutedResult;
import com.nanjing.water.common.PagerResult;
import com.nanjing.water.common.util.ParameterUtil;
import com.nanjing.water.common.validator.ParameterValidateResult;
import com.nanjing.water.common.validator.ParameterValidator;
import com.nanjing.water.entity.request.ReqListId;
import com.nanjing.water.entity.request.sysdictdata.ReqCreateSysDictData;
import com.nanjing.water.entity.request.sysdictdata.ReqModifySysDictData;
import com.nanjing.water.entity.search.SearchSysDictData;
import com.nanjing.water.host.BasicController;
import com.nanjing.water.repository.vo.SysDictDataVO;
import com.nanjing.water.service.SysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 04.字典数据
 * @author lin.liu
 * @description 字典数据
 * @order 04
 */
@RestController
@RequestMapping(value = "sysDictData")
public class SysDictDataController extends BasicController {
    @Autowired
    private SysDictDataService service;
 
    /**
     * 创建[字典数据表]
     * @author lin.liu
     * @description 创建[字典数据表]
     */
    @PostMapping(value = "create")
    public ExecutedResult<Long> create(@RequestBody ReqCreateSysDictData request) {
        //#region 参数验证
        ParameterValidator validator = new ParameterValidator()
                // 非空
                //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName())
                // 限制最大长度
                //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50)
                ;
        ParameterValidateResult result = validator.validate();
        if (result.getIsFiled()) {
            return failed(result.getErrorMsg());
        }
        //#endregion
        return this.service.create(request, super.getTokenUser());
    }
 
    /**
     * 编辑[字典数据表]
     * @author lin.liu
     * @description 编辑[字典数据表]
     */
    @PostMapping(value = "modify")
    public ExecutedResult<String> modify(@RequestBody ReqModifySysDictData request) {
        //#region 参数验证
        ParameterValidator validator = new ParameterValidator()
                // 必须大于0
                .addGreater(ParameterUtil.named("[字典数据表]id"), request.getId(), 0L)
                // 非空
                //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName())
                // 限制最大长度
                //.addLengthMax(ParameterUtil.named("名称"), request.getName(), ConstantFactory.LENGTH_MAX50)
                ;
        ParameterValidateResult result = validator.validate();
        if (result.getIsFiled()) {
            return failed(result.getErrorMsg());
        }
        //#endregion
        return this.service.modify(request, super.getTokenUser());
    }
 
    /**
     * 获取[字典数据表]
     * @author lin.liu
     */
    @GetMapping(value = "get/{id}")
    public ExecutedResult<SysDictDataVO> get(@PathVariable Long id) {
        return this.service.get(id);
    }
 
    /**
     * 根据id删除[字典数据表]
     * @author zr
     * @description 根据id删除[字典数据表]
     */
    @PostMapping(value = "remove/{id}")
    public ExecutedResult<String> remove(@PathVariable Long id){
        return this.service.remove(id);
    }
 
    /**
     * 根据id批量删除字典数据
     * @author zr
     */
    @PostMapping(value = "removeList")
    public ExecutedResult<String> removeList(@RequestBody ReqListId reqListId){
        return this.service.removeList(reqListId.getListId());
    }
 
    /**
     * 根据类型获取[字典数据表]
     * @author zr
     */
    @GetMapping(value = "getListByType/{type}")
    public ExecutedResult<List<SysDictDataVO>> getListByType(@PathVariable String type) {
        return this.service.getListByType(type);
    }
 
    /**
     * 查询[字典数据表]
     * @author lin.liu
     */
    @PostMapping(value = "search")
    public ExecutedResult<PagerResult<SysDictDataVO>> search(@RequestBody SearchSysDictData request) {
        return this.service.search(request);
    }
}