package com.ruoyi.credit.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 债权服务配置
 * 
 * @author ruoyi
 */
@Configuration
@ConfigurationProperties(prefix = "digital-credit")
public class CreditConfig {
    
    /** 系统名称 */
    private String name;
    
    /** 版本 */
    private String version;
    
    /** 加密配置 */
    private Encryption encryption = new Encryption();
    
    /** 缓存配置 */
    private Cache cache = new Cache();
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getVersion() {
        return version;
    }
    
    public void setVersion(String version) {
        this.version = version;
    }
    
    public Encryption getEncryption() {
        return encryption;
    }
    
    public void setEncryption(Encryption encryption) {
        this.encryption = encryption;
    }
    
    public Cache getCache() {
        return cache;
    }
    
    public void setCache(Cache cache) {
        this.cache = cache;
    }
    
    /**
     * 加密配置
     */
    public static class Encryption {
        /** 默认加密算法 */
        private String defaultAlgorithm = "AES-256-GCM";
        
        /** 密钥存储类型 */
        private String keyStoreType = "database";
        
        /** 密钥轮换间隔(天) */
        private int keyRotationDays = 90;
        
        /** 启用字段级加密 */
        private boolean fieldEncryptionEnabled = true;
        
        public String getDefaultAlgorithm() {
            return defaultAlgorithm;
        }
        
        public void setDefaultAlgorithm(String defaultAlgorithm) {
            this.defaultAlgorithm = defaultAlgorithm;
        }
        
        public String getKeyStoreType() {
            return keyStoreType;
        }
        
        public void setKeyStoreType(String keyStoreType) {
            this.keyStoreType = keyStoreType;
        }
        
        public int getKeyRotationDays() {
            return keyRotationDays;
        }
        
        public void setKeyRotationDays(int keyRotationDays) {
            this.keyRotationDays = keyRotationDays;
        }
        
        public boolean isFieldEncryptionEnabled() {
            return fieldEncryptionEnabled;
        }
        
        public void setFieldEncryptionEnabled(boolean fieldEncryptionEnabled) {
            this.fieldEncryptionEnabled = fieldEncryptionEnabled;
        }
    }
    
    /**
     * 缓存配置
     */
    public static class Cache {
        /** 缓存类型 */
        private String type = "redisson";
        
        /** 缓存前缀 */
        private String prefix = "dc:";
        
        /** 默认过期时间(秒) */
        private int defaultTtl = 3600;
        
        /** 统计数据缓存时间(秒) */
        private int statisticsTtl = 1800;
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
        
        public String getPrefix() {
            return prefix;
        }
        
        public void setPrefix(String prefix) {
            this.prefix = prefix;
        }
        
        public int getDefaultTtl() {
            return defaultTtl;
        }
        
        public void setDefaultTtl(int defaultTtl) {
            this.defaultTtl = defaultTtl;
        }
        
        public int getStatisticsTtl() {
            return statisticsTtl;
        }
        
        public void setStatisticsTtl(int statisticsTtl) {
            this.statisticsTtl = statisticsTtl;
        }
    }
}