From 4f7362ec2854732c2ff2454331ec815c4c3147f0 Mon Sep 17 00:00:00 2001 From: lixuliang <lixuliang_hd@126.com> Date: 星期五, 22 十一月 2024 11:08:59 +0800 Subject: [PATCH] Merge branch 'master' of http://103.135.160.14:9034/r/se-cloud --- se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java | 76 +++++++++++++++++++++++++------------ 1 files changed, 51 insertions(+), 25 deletions(-) diff --git a/se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java b/se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java index 8f816b5..77886d7 100644 --- a/se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java +++ b/se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java @@ -5,6 +5,7 @@ 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; @@ -22,7 +23,7 @@ import com.se.common.log.enums.BusinessType; import com.se.common.security.annotation.RequiresPermissions; import com.se.common.security.utils.SecurityUtils; -import com.se.system.service.ISysConfigService; +import com.se.system.service.inte.ISysConfigService; /** * 鍙傛暟閰嶇疆 淇℃伅鎿嶄綔澶勭悊 @@ -31,8 +32,13 @@ */ @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; @@ -41,19 +47,33 @@ */ @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, "鍙傛暟鏁版嵁"); } @@ -62,18 +82,26 @@ * 鏍规嵁鍙傛暟缂栧彿鑾峰彇璇︾粏淇℃伅 */ @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); } /** @@ -82,10 +110,8 @@ @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()); @@ -98,13 +124,15 @@ @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)); } @@ -114,8 +142,7 @@ @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(); } @@ -126,8 +153,7 @@ @RequiresPermissions("system:config:remove") @Log(title = "鍙傛暟绠$悊", businessType = BusinessType.CLEAN) @DeleteMapping("/refreshCache") - public AjaxResult refreshCache() - { + public AjaxResult refreshCache() { configService.resetConfigCache(); return success(); } -- Gitblit v1.9.3