陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
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
package com.mzl.flower.web.system;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.dto.request.system.*;
import com.mzl.flower.dto.response.system.CodeTypeDTO;
import com.mzl.flower.dto.response.system.CodeValueDTO;
import com.mzl.flower.service.system.CodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@RestController
@RequestMapping("/api/code")
@Api(value = "字典管理", tags = "字典管理")
@Validated
public class CodeController extends BaseController {
    @Autowired
    private CodeService codeService;
 
    @GetMapping("/value")
    @ApiOperation(value = "获取字典值")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型码", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<List<CodeValueDTO>>> searchValue(String type){
        return returnData(R.SUCCESS.getCode(), codeService.searchValue(type));
    }
 
    @GetMapping("/multiple")
    @ApiOperation(value = "获取多个字典值")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型码,逗号隔开", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO> searchMultipleValue(String type){
        return returnData(R.SUCCESS.getCode(), codeService.searchMultipleValue(type));
    }
 
    @PostMapping("/type/add")
    @ApiOperation(value = "新增字典类型")
    public ResponseEntity<ReturnDataDTO> addType(@RequestBody CreateCodeTypeDTO dto){
        codeService.addType(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/type/edit")
    @ApiOperation(value = "编辑字典类型")
    public ResponseEntity<ReturnDataDTO> updateType(@RequestBody UpdateCodeTypeDTO dto){
        codeService.updateType(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/type/list")
    @ApiOperation(value = "获取字典类型")
    public ResponseEntity<ReturnDataDTO<Page<CodeTypeDTO>>> searchCodeType(Page page, QueryCodeTypeDTO dto){
        return returnData(R.SUCCESS.getCode(), codeService.searchCodeType(page, dto));
    }
 
    @GetMapping("/type/delete")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "字典类型id", required = true, dataType = "String", paramType = "query")
    })
    @ApiOperation(value = "删除字典类型")
    public ResponseEntity<ReturnDataDTO> deleteDictType(String id) {
        codeService.deleteCodeType(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/value/add")
    @ApiOperation(value = "新增字典值")
    public ResponseEntity<ReturnDataDTO> addCodeValue(@RequestBody CreateCodeValueDTO dto){
        codeService.addCodeValue(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/value/edit")
    @ApiOperation(value = "编辑字典值")
    public ResponseEntity<ReturnDataDTO> updateValue(@RequestBody UpdateCodeValueDTO dto){
        codeService.updateValue(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/value/delete")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "字典值id", required = true, dataType = "String", paramType = "query")
    })
    @ApiOperation(value = "删除字典值")
    public ResponseEntity<ReturnDataDTO> deleteCodeValue(String id) {
        codeService.deleteCodeValue(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
}