| | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.se.common.core.utils.AesUtils; |
| | | import com.se.common.core.utils.StringUtils; |
| | | import com.se.system.domain.SysConfig; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/config") |
| | | public class SysConfigController extends BaseController |
| | | { |
| | | @SuppressWarnings("ALL") |
| | | public class SysConfigController extends BaseController { |
| | | @Value("${enableEncrypt}") |
| | | boolean enableEncrypt; |
| | | |
| | | private final static String PWD_KEY = "sys.user.initPassword"; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | |
| | | */ |
| | | @RequiresPermissions("system:config:list") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysConfig config) |
| | | { |
| | | public TableDataInfo list(SysConfig config) throws Exception { |
| | | startPage(); |
| | | List<SysConfig> list = configService.selectConfigList(config); |
| | | /*if (enableEncrypt && null != list) { |
| | | for (SysConfig cfg : list) { |
| | | if (null != cfg && PWD_KEY.equals(cfg.getConfigKey()) && !StringUtils.isEmpty(cfg.getConfigValue())) { |
| | | cfg.setConfigValue(AesUtils.encrypt(cfg.getConfigValue())); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @Log(title = "参数管理", businessType = BusinessType.EXPORT) |
| | | @RequiresPermissions("system:config:export") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysConfig config) |
| | | { |
| | | public void export(HttpServletResponse response, SysConfig config) { |
| | | List<SysConfig> list = configService.selectConfigList(config); |
| | | /*if (enableEncrypt && null != list) { |
| | | for (SysConfig cfg : list) { |
| | | if (null != cfg && PWD_KEY.equals(cfg.getConfigKey()) && !StringUtils.isEmpty(cfg.getConfigValue())) { |
| | | cfg.setConfigValue(AesUtils.encrypt(cfg.getConfigValue())); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); |
| | | util.exportExcel(response, list, "参数数据"); |
| | | } |
| | |
| | | * 根据参数编号获取详细信息 |
| | | */ |
| | | @GetMapping(value = "/{configId}") |
| | | public AjaxResult getInfo(@PathVariable Long configId) |
| | | { |
| | | return success(configService.selectConfigById(configId)); |
| | | public AjaxResult getInfo(@PathVariable Long configId) throws Exception { |
| | | SysConfig config = configService.selectConfigById(configId); |
| | | /*if ((enableEncrypt && null != config && PWD_KEY.equals(config.getConfigKey()) && !StringUtils.isEmpty(config.getConfigValue())) { |
| | | config.setConfigValue(AesUtils.encrypt(config.getConfigValue())); |
| | | }*/ |
| | | |
| | | return success(config); |
| | | } |
| | | |
| | | /** |
| | | * 根据参数键名查询参数值 |
| | | */ |
| | | @GetMapping(value = "/configKey/{configKey}") |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) |
| | | { |
| | | return success(configService.selectConfigByKey(configKey)); |
| | | public AjaxResult getConfigKey(@PathVariable String configKey) throws Exception { |
| | | String val = configService.selectConfigByKey(configKey); |
| | | /*if (enableEncrypt && PWD_KEY.equals(configKey) && !StringUtils.isEmpty(val)) { |
| | | val = AesUtils.encrypt(val); |
| | | }*/ |
| | | |
| | | return success(val); |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequiresPermissions("system:config:add") |
| | | @Log(title = "参数管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | | public AjaxResult add(@Validated @RequestBody SysConfig config) { |
| | | if (!configService.checkConfigKeyUnique(config)) { |
| | | return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setCreateBy(SecurityUtils.getUsername()); |
| | |
| | | @RequiresPermissions("system:config:edit") |
| | | @Log(title = "参数管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config) |
| | | { |
| | | if (!configService.checkConfigKeyUnique(config)) |
| | | { |
| | | public AjaxResult edit(@Validated @RequestBody SysConfig config) throws Exception { |
| | | if (!configService.checkConfigKeyUnique(config)) { |
| | | return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); |
| | | } |
| | | config.setUpdateBy(SecurityUtils.getUsername()); |
| | | /*if ((enableEncrypt && PWD_KEY.equals(config.getConfigKey()) && !StringUtils.isEmpty(config.getConfigValue())){ |
| | | config.setConfigValue(AesUtils.decrypt(config.getConfigValue())); |
| | | }*/ |
| | | |
| | | return toAjax(configService.updateConfig(config)); |
| | | } |
| | | |
| | |
| | | @RequiresPermissions("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{configIds}") |
| | | public AjaxResult remove(@PathVariable Long[] configIds) |
| | | { |
| | | public AjaxResult remove(@PathVariable Long[] configIds) { |
| | | configService.deleteConfigByIds(configIds); |
| | | return success(); |
| | | } |
| | |
| | | @RequiresPermissions("system:config:remove") |
| | | @Log(title = "参数管理", businessType = BusinessType.CLEAN) |
| | | @DeleteMapping("/refreshCache") |
| | | public AjaxResult refreshCache() |
| | | { |
| | | public AjaxResult refreshCache() { |
| | | configService.resetConfigCache(); |
| | | return success(); |
| | | } |