提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.web.controller.system; |
懒 |
2 |
|
|
3 |
import java.util.List; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
6 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
7 |
import org.springframework.validation.annotation.Validated; |
|
8 |
import org.springframework.web.bind.annotation.DeleteMapping; |
|
9 |
import org.springframework.web.bind.annotation.GetMapping; |
|
10 |
import org.springframework.web.bind.annotation.PathVariable; |
|
11 |
import org.springframework.web.bind.annotation.PostMapping; |
|
12 |
import org.springframework.web.bind.annotation.PutMapping; |
|
13 |
import org.springframework.web.bind.annotation.RequestBody; |
|
14 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
15 |
import org.springframework.web.bind.annotation.RestController; |
|
16 |
import com.jcdm.common.annotation.Log; |
|
17 |
import com.jcdm.common.core.controller.BaseController; |
|
18 |
import com.jcdm.common.core.domain.AjaxResult; |
|
19 |
import com.jcdm.common.core.domain.entity.SysDictType; |
|
20 |
import com.jcdm.common.core.page.TableDataInfo; |
|
21 |
import com.jcdm.common.enums.BusinessType; |
|
22 |
import com.jcdm.common.utils.poi.ExcelUtil; |
|
23 |
import com.jcdm.system.service.ISysDictTypeService; |
|
24 |
|
|
25 |
/** |
|
26 |
* 数据字典信息 |
|
27 |
* |
|
28 |
* @author jc |
|
29 |
*/ |
|
30 |
@RestController |
|
31 |
@RequestMapping("/system/dict/type") |
|
32 |
public class SysDictTypeController extends BaseController |
|
33 |
{ |
|
34 |
@Autowired |
|
35 |
private ISysDictTypeService dictTypeService; |
|
36 |
|
|
37 |
@PreAuthorize("@ss.hasPermi('system:dict:list')") |
|
38 |
@GetMapping("/list") |
|
39 |
public TableDataInfo list(SysDictType dictType) |
|
40 |
{ |
|
41 |
startPage(); |
|
42 |
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
|
43 |
return getDataTable(list); |
|
44 |
} |
|
45 |
|
|
46 |
@Log(title = "字典类型", businessType = BusinessType.EXPORT) |
|
47 |
@PreAuthorize("@ss.hasPermi('system:dict:export')") |
|
48 |
@PostMapping("/export") |
|
49 |
public void export(HttpServletResponse response, SysDictType dictType) |
|
50 |
{ |
|
51 |
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); |
|
52 |
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); |
|
53 |
util.exportExcel(response, list, "字典类型"); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* 查询字典类型详细 |
|
58 |
*/ |
|
59 |
@PreAuthorize("@ss.hasPermi('system:dict:query')") |
|
60 |
@GetMapping(value = "/{dictId}") |
|
61 |
public AjaxResult getInfo(@PathVariable Long dictId) |
|
62 |
{ |
|
63 |
return success(dictTypeService.selectDictTypeById(dictId)); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* 新增字典类型 |
|
68 |
*/ |
|
69 |
@PreAuthorize("@ss.hasPermi('system:dict:add')") |
|
70 |
@Log(title = "字典类型", businessType = BusinessType.INSERT) |
|
71 |
@PostMapping |
|
72 |
public AjaxResult add(@Validated @RequestBody SysDictType dict) |
|
73 |
{ |
|
74 |
if (!dictTypeService.checkDictTypeUnique(dict)) |
|
75 |
{ |
|
76 |
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
|
77 |
} |
|
78 |
dict.setCreateBy(getUsername()); |
|
79 |
return toAjax(dictTypeService.insertDictType(dict)); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* 修改字典类型 |
|
84 |
*/ |
|
85 |
@PreAuthorize("@ss.hasPermi('system:dict:edit')") |
|
86 |
@Log(title = "字典类型", businessType = BusinessType.UPDATE) |
|
87 |
@PutMapping |
|
88 |
public AjaxResult edit(@Validated @RequestBody SysDictType dict) |
|
89 |
{ |
|
90 |
if (!dictTypeService.checkDictTypeUnique(dict)) |
|
91 |
{ |
|
92 |
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); |
|
93 |
} |
|
94 |
dict.setUpdateBy(getUsername()); |
|
95 |
return toAjax(dictTypeService.updateDictType(dict)); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* 删除字典类型 |
|
100 |
*/ |
|
101 |
@PreAuthorize("@ss.hasPermi('system:dict:remove')") |
|
102 |
@Log(title = "字典类型", businessType = BusinessType.DELETE) |
|
103 |
@DeleteMapping("/{dictIds}") |
|
104 |
public AjaxResult remove(@PathVariable Long[] dictIds) |
|
105 |
{ |
|
106 |
dictTypeService.deleteDictTypeByIds(dictIds); |
|
107 |
return success(); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* 刷新字典缓存 |
|
112 |
*/ |
|
113 |
@PreAuthorize("@ss.hasPermi('system:dict:remove')") |
|
114 |
@Log(title = "字典类型", businessType = BusinessType.CLEAN) |
|
115 |
@DeleteMapping("/refreshCache") |
|
116 |
public AjaxResult refreshCache() |
|
117 |
{ |
|
118 |
dictTypeService.resetDictCache(); |
|
119 |
return success(); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* 获取字典选择框列表 |
|
124 |
*/ |
|
125 |
@GetMapping("/optionselect") |
|
126 |
public AjaxResult optionselect() |
|
127 |
{ |
|
128 |
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll(); |
|
129 |
return success(dictTypes); |
|
130 |
} |
|
131 |
} |