#
Junjie
1 天以前 223e200a69aff78811cd93de72f6053532f97d3c
src/main/java/com/zy/system/controller/ConfigController.java
@@ -31,12 +31,7 @@
    @RequestMapping(value = "/config/refreshCache")
    @ManagerAuth
    public R refreshCache(){
        HashMap<String, String> systemConfigMap = new HashMap<>();
        List<Config> configList = configService.list(new QueryWrapper<>());
        for (Config config : configList) {
            systemConfigMap.put(config.getCode(), config.getValue());
        }
        redisUtil.set(RedisKeyType.SYSTEM_CONFIG_MAP.key, systemConfigMap);
        refreshCacheData();
        return R.ok();
    }
@@ -85,6 +80,7 @@
    @RequestMapping(value = "/config/updateBatch")
    @ManagerAuth
    public R updateBatch(@RequestBody List<ConfigUpdateBatchParam> params){
        boolean updated = false;
        for (ConfigUpdateBatchParam param : params) {
            String code = param.getCode();
            String value = param.getValue();
@@ -92,9 +88,20 @@
            if (config == null) {
                continue;
            }
            if (Short.valueOf((short) 2).equals(config.getType()) && !checkJson(value)) {
                return R.error(config.getCode() + " json解析失败");
            }
            if (Objects.equals(config.getValue(), value)) {
                continue;
            }
            config.setValue(value);
            configService.updateById(config);
            updated = true;
        }
        if (updated) {
            Parameter.reset();
            refreshCacheData();
        }
        return R.ok();
    }
@@ -229,4 +236,13 @@
        return parse != null;
    }
    private void refreshCacheData() {
        HashMap<String, String> systemConfigMap = new HashMap<>();
        List<Config> configList = configService.list(new QueryWrapper<>());
        for (Config config : configList) {
            systemConfigMap.put(config.getCode(), config.getValue());
        }
        redisUtil.set(RedisKeyType.SYSTEM_CONFIG_MAP.key, systemConfigMap);
    }
}