SysDictDataController.java
4.11 KB
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
package com.huaheng.system.controller;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.huaheng.system.domain.SysDictData;
import com.huaheng.system.service.ISysDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.huaheng.common.core.utils.poi.ExcelUtil;
import com.huaheng.common.core.web.controller.BaseController;
import com.huaheng.common.core.web.domain.AjaxResult;
import com.huaheng.common.core.web.page.TableDataInfo;
import com.huaheng.common.log.annotation.Log;
import com.huaheng.common.log.enums.BusinessType;
import com.huaheng.common.security.annotation.PreAuthorize;
import com.huaheng.common.security.utils.SecurityUtils;
import com.huaheng.system.service.ISysDictTypeService;
/**
* 数据字典信息
*/
@RestController
@RequestMapping("/dict/data")
@Api(value = "数据字典信息", tags = "数据字典信息")
public class SysDictDataController extends BaseController {
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize(hasPermi = "system:dict:list")
@GetMapping("/list")
@ApiOperation(value = "获取数据字典信息")
public TableDataInfo list(SysDictData dictData) {
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize(hasPermi = "system:dict:export")
@PostMapping("/export")
@ApiOperation(value = "获取字典数据")
public void export(HttpServletResponse response, SysDictData dictData) throws IOException {
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");
}
/**
* 查询字典数据详细
*/
@ApiOperation(value = "查询字典数据详细")
@PreAuthorize(hasPermi = "system:dict:query")
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable @ApiParam(value = "字典编码") Long dictCode) {
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
}
/**
* 根据字典类型查询字典数据信息
*/
@GetMapping(value = "/type/{dictType}")
@ApiOperation(value = "根据字典类型查询字典数据信息")
public AjaxResult dictType(@PathVariable @ApiParam(value = "字典类型") String dictType) {
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
}
/**
* 新增字典类型
*/
@PreAuthorize(hasPermi = "system:dict:add")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation(value = "新增字典类型")
public AjaxResult add(@Validated @RequestBody SysDictData dict) {
dict.setCreateBy(SecurityUtils.getUsername());
return toAjax(dictDataService.insertDictData(dict));
}
/**
* 修改保存字典类型
*/
@PreAuthorize(hasPermi = "system:dict:edit")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation(value = "修改字典类型")
public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
dict.setUpdateBy(SecurityUtils.getUsername());
return toAjax(dictDataService.updateDictData(dict));
}
/**
* 删除字典类型
*/
@PreAuthorize(hasPermi = "system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
@ApiOperation(value = "删除字典类型")
public AjaxResult remove(@PathVariable @ApiParam(value = "字典编码数组") Long[] dictCodes) {
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
}
}