提交 | 用户 | 时间
|
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.page.TableDataInfo; |
|
20 |
import com.jcdm.common.enums.BusinessType; |
|
21 |
import com.jcdm.common.utils.poi.ExcelUtil; |
|
22 |
import com.jcdm.system.domain.SysConfig; |
|
23 |
import com.jcdm.system.service.ISysConfigService; |
|
24 |
|
|
25 |
/** |
|
26 |
* 参数配置 信息操作处理 |
|
27 |
* |
|
28 |
* @author jc |
|
29 |
*/ |
|
30 |
@RestController |
|
31 |
@RequestMapping("/system/config") |
|
32 |
public class SysConfigController extends BaseController |
|
33 |
{ |
|
34 |
@Autowired |
|
35 |
private ISysConfigService configService; |
|
36 |
|
|
37 |
/** |
|
38 |
* 获取参数配置列表 |
|
39 |
*/ |
|
40 |
@PreAuthorize("@ss.hasPermi('system:config:list')") |
|
41 |
@GetMapping("/list") |
|
42 |
public TableDataInfo list(SysConfig config) |
|
43 |
{ |
|
44 |
startPage(); |
|
45 |
List<SysConfig> list = configService.selectConfigList(config); |
|
46 |
return getDataTable(list); |
|
47 |
} |
|
48 |
|
|
49 |
@Log(title = "参数管理", businessType = BusinessType.EXPORT) |
|
50 |
@PreAuthorize("@ss.hasPermi('system:config:export')") |
|
51 |
@PostMapping("/export") |
|
52 |
public void export(HttpServletResponse response, SysConfig config) |
|
53 |
{ |
|
54 |
List<SysConfig> list = configService.selectConfigList(config); |
|
55 |
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); |
|
56 |
util.exportExcel(response, list, "参数数据"); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* 根据参数编号获取详细信息 |
|
61 |
*/ |
|
62 |
@PreAuthorize("@ss.hasPermi('system:config:query')") |
|
63 |
@GetMapping(value = "/{configId}") |
|
64 |
public AjaxResult getInfo(@PathVariable Long configId) |
|
65 |
{ |
|
66 |
return success(configService.selectConfigById(configId)); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* 根据参数键名查询参数值 |
|
71 |
*/ |
|
72 |
@GetMapping(value = "/configKey/{configKey}") |
|
73 |
public AjaxResult getConfigKey(@PathVariable String configKey) |
|
74 |
{ |
|
75 |
return success(configService.selectConfigByKey(configKey)); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* 新增参数配置 |
|
80 |
*/ |
|
81 |
@PreAuthorize("@ss.hasPermi('system:config:add')") |
|
82 |
@Log(title = "参数管理", businessType = BusinessType.INSERT) |
|
83 |
@PostMapping |
|
84 |
public AjaxResult add(@Validated @RequestBody SysConfig config) |
|
85 |
{ |
|
86 |
if (!configService.checkConfigKeyUnique(config)) |
|
87 |
{ |
|
88 |
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
|
89 |
} |
|
90 |
config.setCreateBy(getUsername()); |
|
91 |
return toAjax(configService.insertConfig(config)); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* 修改参数配置 |
|
96 |
*/ |
|
97 |
@PreAuthorize("@ss.hasPermi('system:config:edit')") |
|
98 |
@Log(title = "参数管理", businessType = BusinessType.UPDATE) |
|
99 |
@PutMapping |
|
100 |
public AjaxResult edit(@Validated @RequestBody SysConfig config) |
|
101 |
{ |
|
102 |
if (!configService.checkConfigKeyUnique(config)) |
|
103 |
{ |
|
104 |
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
|
105 |
} |
|
106 |
config.setUpdateBy(getUsername()); |
|
107 |
return toAjax(configService.updateConfig(config)); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* 删除参数配置 |
|
112 |
*/ |
|
113 |
@PreAuthorize("@ss.hasPermi('system:config:remove')") |
|
114 |
@Log(title = "参数管理", businessType = BusinessType.DELETE) |
|
115 |
@DeleteMapping("/{configIds}") |
|
116 |
public AjaxResult remove(@PathVariable Long[] configIds) |
|
117 |
{ |
|
118 |
configService.deleteConfigByIds(configIds); |
|
119 |
return success(); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* 刷新参数缓存 |
|
124 |
*/ |
|
125 |
@PreAuthorize("@ss.hasPermi('system:config:remove')") |
|
126 |
@Log(title = "参数管理", businessType = BusinessType.CLEAN) |
|
127 |
@DeleteMapping("/refreshCache") |
|
128 |
public AjaxResult refreshCache() |
|
129 |
{ |
|
130 |
configService.resetConfigCache(); |
|
131 |
return success(); |
|
132 |
} |
|
133 |
} |