| | |
| | | @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(); |
| | | } |
| | | |
| | |
| | | @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(); |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |