package org.xyzh.ai.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.xyzh.api.system.constance.SysConfigRedisPrefix;
import org.xyzh.ai.config.DifyConfig;
import org.xyzh.common.redis.listener.AbstractSysConfigListener;

/**
 * Dify配置变更监听器
 * 监听sys:config:dify频道，接收到事件后延时2秒刷新配置
 *
 * @author cascade
 * @since 2026-01-01
 */
@Component
public class DifyConfigListener extends AbstractSysConfigListener {

    @Autowired
    private DifyConfig difyConfig;

    @Override
    protected void doRefresh(String channel, String body) {
        difyConfig.refresh();
    }

    @Override
    public String getChannelPattern() {
        return SysConfigRedisPrefix.SYS_CONFIG_DIFY;
    }
}
