在线热更新配置
This commit is contained in:
@@ -1,8 +1,81 @@
|
||||
package org.xyzh.api.system.constance;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通过redis事件,实现数据库更新配置,更新其他服务的bean数据
|
||||
* 按配置分组定义Redis前缀
|
||||
*
|
||||
* 注意:其他服务接收到事件后需延时2秒再查询数据库,等待发布方事务提交
|
||||
*
|
||||
* @see org.xyzh.common.redis.listener.AbstractSysConfigListener
|
||||
*/
|
||||
public class SysConfigRedisPrefix {
|
||||
public static final String SYS_CONFIG_DIFY="sys:config:dify";
|
||||
|
||||
/** 配置变更频道前缀(用于订阅所有配置变更) */
|
||||
public static final String SYS_CONFIG_PREFIX = "sys:config:";
|
||||
|
||||
/** 站点与品牌配置 */
|
||||
public static final String SYS_CONFIG_SITE = "sys:config:site";
|
||||
|
||||
/** 国际化与时区配置 */
|
||||
public static final String SYS_CONFIG_I18N = "sys:config:i18n";
|
||||
|
||||
/** 安全与认证配置 */
|
||||
public static final String SYS_CONFIG_SECURITY = "sys:config:security";
|
||||
|
||||
/** 存储与上传配置(含MinIO、文件管理) */
|
||||
public static final String SYS_CONFIG_STORAGE = "sys:config:storage";
|
||||
|
||||
/** 通知配置(邮件/短信) */
|
||||
public static final String SYS_CONFIG_NOTIFY = "sys:config:notify";
|
||||
|
||||
/** Dify AI配置 */
|
||||
public static final String SYS_CONFIG_DIFY = "sys:config:dify";
|
||||
|
||||
/** 日志与审计配置 */
|
||||
public static final String SYS_CONFIG_LOG = "sys:config:log";
|
||||
|
||||
/** 平台特性配置 */
|
||||
public static final String SYS_CONFIG_PLATFORM = "sys:config:platform";
|
||||
|
||||
/** 微信客服配置 */
|
||||
public static final String SYS_CONFIG_WECHAT = "sys:config:wechat";
|
||||
|
||||
/** group到channel的映射 */
|
||||
private static final Map<String, String> GROUP_CHANNEL_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
GROUP_CHANNEL_MAP.put("site", SYS_CONFIG_SITE);
|
||||
GROUP_CHANNEL_MAP.put("i18n", SYS_CONFIG_I18N);
|
||||
GROUP_CHANNEL_MAP.put("security", SYS_CONFIG_SECURITY);
|
||||
GROUP_CHANNEL_MAP.put("storage", SYS_CONFIG_STORAGE);
|
||||
GROUP_CHANNEL_MAP.put("notify", SYS_CONFIG_NOTIFY);
|
||||
GROUP_CHANNEL_MAP.put("dify", SYS_CONFIG_DIFY);
|
||||
GROUP_CHANNEL_MAP.put("log", SYS_CONFIG_LOG);
|
||||
GROUP_CHANNEL_MAP.put("platform", SYS_CONFIG_PLATFORM);
|
||||
GROUP_CHANNEL_MAP.put("wechat", SYS_CONFIG_WECHAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据group获取对应的Redis channel
|
||||
* @param group 配置分组(对应数据库中的group字段)
|
||||
* @return channel名称,未匹配则返回 sys:config:{group}
|
||||
*/
|
||||
public static String getChannelByGroup(String group) {
|
||||
if (group == null || group.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return GROUP_CHANNEL_MAP.getOrDefault(group, SYS_CONFIG_PREFIX + group);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断group是否有效
|
||||
* @param group 配置分组
|
||||
* @return 是否为已知的分组
|
||||
*/
|
||||
public static boolean isValidGroup(String group) {
|
||||
return group != null && GROUP_CHANNEL_MAP.containsKey(group);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user