| | |
| | | @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(); |
| | | } |
| | | |
| | |
| | | |
| | | private void convert(Map<String, Object> map, QueryWrapper wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | String column = humpToLine(entry.getKey()); |
| | | if (val.contains(" - ")) { |
| | | String[] dates = val.split(" - "); |
| | | wrapper.ge(column, DateUtils.convert(dates[0])); |
| | | wrapper.le(column, DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(column, val); |
| | | } |
| | | } |
| | | } |
| | |
| | | @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); |
| | | } |
| | | |
| | | } |