-
admin
2024-06-01 a846f28bef985e7671f0b469fb73541cbfb08a93
提交 | 用户 | 时间
e57a89 1 package com.jcdm.web.controller.system;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import javax.servlet.http.HttpServletResponse;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.security.access.prepost.PreAuthorize;
8 import org.springframework.validation.annotation.Validated;
9 import org.springframework.web.bind.annotation.DeleteMapping;
10 import org.springframework.web.bind.annotation.GetMapping;
11 import org.springframework.web.bind.annotation.PathVariable;
12 import org.springframework.web.bind.annotation.PostMapping;
13 import org.springframework.web.bind.annotation.PutMapping;
14 import org.springframework.web.bind.annotation.RequestBody;
15 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RestController;
17 import com.jcdm.common.annotation.Log;
18 import com.jcdm.common.core.controller.BaseController;
19 import com.jcdm.common.core.domain.AjaxResult;
20 import com.jcdm.common.core.domain.entity.SysDictData;
21 import com.jcdm.common.core.page.TableDataInfo;
22 import com.jcdm.common.enums.BusinessType;
23 import com.jcdm.common.utils.StringUtils;
24 import com.jcdm.common.utils.poi.ExcelUtil;
25 import com.jcdm.system.service.ISysDictDataService;
26 import com.jcdm.system.service.ISysDictTypeService;
27
28 /**
29  * 数据字典信息
30  * 
31  * @author jc
32  */
33 @RestController
34 @RequestMapping("/system/dict/data")
35 public class SysDictDataController extends BaseController
36 {
37     @Autowired
38     private ISysDictDataService dictDataService;
39
40     @Autowired
41     private ISysDictTypeService dictTypeService;
42
43     @PreAuthorize("@ss.hasPermi('system:dict:list')")
44     @GetMapping("/list")
45     public TableDataInfo list(SysDictData dictData)
46     {
47         startPage();
48         List<SysDictData> list = dictDataService.selectDictDataList(dictData);
49         return getDataTable(list);
50     }
51
52     @Log(title = "字典数据", businessType = BusinessType.EXPORT)
53     @PreAuthorize("@ss.hasPermi('system:dict:export')")
54     @PostMapping("/export")
55     public void export(HttpServletResponse response, SysDictData dictData)
56     {
57         List<SysDictData> list = dictDataService.selectDictDataList(dictData);
58         ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
59         util.exportExcel(response, list, "字典数据");
60     }
61
62     /**
63      * 查询字典数据详细
64      */
65     @PreAuthorize("@ss.hasPermi('system:dict:query')")
66     @GetMapping(value = "/{dictCode}")
67     public AjaxResult getInfo(@PathVariable Long dictCode)
68     {
69         return success(dictDataService.selectDictDataById(dictCode));
70     }
71
72     /**
73      * 根据字典类型查询字典数据信息
74      */
75     @GetMapping(value = "/type/{dictType}")
76     public AjaxResult dictType(@PathVariable String dictType)
77     {
78         List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
79         if (StringUtils.isNull(data))
80         {
81             data = new ArrayList<SysDictData>();
82         }
83         return success(data);
84     }
85
86     /**
87      * 新增字典类型
88      */
89     @PreAuthorize("@ss.hasPermi('system:dict:add')")
90     @Log(title = "字典数据", businessType = BusinessType.INSERT)
91     @PostMapping
92     public AjaxResult add(@Validated @RequestBody SysDictData dict)
93     {
94         dict.setCreateBy(getUsername());
95         return toAjax(dictDataService.insertDictData(dict));
96     }
97
98     /**
99      * 修改保存字典类型
100      */
101     @PreAuthorize("@ss.hasPermi('system:dict:edit')")
102     @Log(title = "字典数据", businessType = BusinessType.UPDATE)
103     @PutMapping
104     public AjaxResult edit(@Validated @RequestBody SysDictData dict)
105     {
106         dict.setUpdateBy(getUsername());
107         return toAjax(dictDataService.updateDictData(dict));
108     }
109
110     /**
111      * 删除字典类型
112      */
113     @PreAuthorize("@ss.hasPermi('system:dict:remove')")
114     @Log(title = "字典类型", businessType = BusinessType.DELETE)
115     @DeleteMapping("/{dictCodes}")
116     public AjaxResult remove(@PathVariable Long[] dictCodes)
117     {
118         dictDataService.deleteDictDataByIds(dictCodes);
119         return success();
120     }
121 }