| | |
| | | } |
| | | |
| | | /** |
| | | * 更新配置值 |
| | | * |
| | | * @param configKey 参数键名 |
| | | * @param configValue 参数值 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateConfigValue(String configKey, String configValue) { |
| | | // 先查询是否存在该配置项 |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey(configKey); |
| | | SysConfig existingConfig = configMapper.selectConfig(config); |
| | | |
| | | if (existingConfig != null) { |
| | | // 如果存在,更新配置值 |
| | | existingConfig.setConfigValue(configValue); |
| | | existingConfig.setUpdateTime(new java.util.Date()); |
| | | int result = configMapper.updateConfig(existingConfig); |
| | | // 更新缓存 |
| | | if (result > 0) { |
| | | redisCache.setCacheObject(getCacheKey(configKey), configValue); |
| | | } |
| | | return result; |
| | | } else { |
| | | // 如果不存在,创建新的配置项 |
| | | SysConfig newConfig = new SysConfig(); |
| | | newConfig.setConfigKey(configKey); |
| | | newConfig.setConfigValue(configValue); |
| | | newConfig.setConfigName("企业微信配置"); |
| | | newConfig.setConfigType("N"); // 非系统内置 |
| | | newConfig.setCreateBy("system"); |
| | | int result = configMapper.insertConfig(newConfig); |
| | | // 更新缓存 |
| | | if (result > 0) { |
| | | redisCache.setCacheObject(getCacheKey(configKey), configValue); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey 参数键 |