package com.ruoyi.credit.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 验证规则配置属性类
 * 
 * @author ruoyi
 * @date 2025-12-30
 */
@Component
@ConfigurationProperties(prefix = "credit.validation.rules")
public class ValidationRuleProperties {
    
    /**
     * 配置文件路径
     */
    private String configFile = "classpath:validation-rules.json";
    
    /**
     * 热更新配置
     */
    private HotReload hotReload = new HotReload();
    
    /**
     * 文件监听配置
     */
    private FileWatch fileWatch = new FileWatch();
    
    /**
     * 缓存配置
     */
    private Cache cache = new Cache();
    
    public String getConfigFile() {
        return configFile;
    }
    
    public void setConfigFile(String configFile) {
        this.configFile = configFile;
    }
    
    public HotReload getHotReload() {
        return hotReload;
    }
    
    public void setHotReload(HotReload hotReload) {
        this.hotReload = hotReload;
    }
    
    public FileWatch getFileWatch() {
        return fileWatch;
    }
    
    public void setFileWatch(FileWatch fileWatch) {
        this.fileWatch = fileWatch;
    }
    
    public Cache getCache() {
        return cache;
    }
    
    public void setCache(Cache cache) {
        this.cache = cache;
    }
    
    /**
     * 热更新配置
     */
    public static class HotReload {
        /**
         * 是否启用热更新
         */
        private boolean enabled = true;
        
        /**
         * 热更新检查间隔（秒）
         */
        private int interval = 30;
        
        /**
         * 最大重试次数
         */
        private int maxRetries = 3;
        
        /**
         * 重试间隔（秒）
         */
        private int retryInterval = 5;
        
        public boolean isEnabled() {
            return enabled;
        }
        
        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
        
        public int getInterval() {
            return interval;
        }
        
        public void setInterval(int interval) {
            this.interval = interval;
        }
        
        public int getMaxRetries() {
            return maxRetries;
        }
        
        public void setMaxRetries(int maxRetries) {
            this.maxRetries = maxRetries;
        }
        
        public int getRetryInterval() {
            return retryInterval;
        }
        
        public void setRetryInterval(int retryInterval) {
            this.retryInterval = retryInterval;
        }
    }
    
    /**
     * 文件监听配置
     */
    public static class FileWatch {
        /**
         * 是否启用文件监听
         */
        private boolean enabled = true;
        
        /**
         * 监听延迟（毫秒）
         */
        private long delay = 1000;
        
        /**
         * 是否监听子目录
         */
        private boolean recursive = false;
        
        public boolean isEnabled() {
            return enabled;
        }
        
        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
        
        public long getDelay() {
            return delay;
        }
        
        public void setDelay(long delay) {
            this.delay = delay;
        }
        
        public boolean isRecursive() {
            return recursive;
        }
        
        public void setRecursive(boolean recursive) {
            this.recursive = recursive;
        }
    }
    
    /**
     * 缓存配置
     */
    public static class Cache {
        /**
         * 是否启用缓存
         */
        private boolean enabled = true;
        
        /**
         * 缓存过期时间（秒）
         */
        private int expireTime = 300;
        
        /**
         * 最大缓存大小
         */
        private int maxSize = 1000;
        
        /**
         * 缓存预热
         */
        private boolean preload = true;
        
        public boolean isEnabled() {
            return enabled;
        }
        
        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
        
        public int getExpireTime() {
            return expireTime;
        }
        
        public void setExpireTime(int expireTime) {
            this.expireTime = expireTime;
        }
        
        public int getMaxSize() {
            return maxSize;
        }
        
        public void setMaxSize(int maxSize) {
            this.maxSize = maxSize;
        }
        
        public boolean isPreload() {
            return preload;
        }
        
        public void setPreload(boolean preload) {
            this.preload = preload;
        }
    }
}