import os
import platform

class Config:
    """Base configuration class"""
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
    JSON_AS_ASCII = False
    
    # Platform specific configurations
    PLATFORM = platform.system().lower()
    
    # File paths
    if PLATFORM == 'windows':
        FILE_PATH = os.environ.get('FILE_PATH') or 'C:/temp/'
    elif PLATFORM == 'linux':
        FILE_PATH = os.environ.get('FILE_PATH') or '/tmp/'
    
    # Upload configurations
    UPLOAD_FOLDER = f"{FILE_PATH}resource_uploads/"
    ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'xlsx', 'xls', 'csv'}
    
    # MinIO configurations - 原配置
    """
    MINIO_HOST = os.environ.get('MINIO_HOST') or 'minio.citupro.com'
    MINIO_USER = os.environ.get('MINIO_USER') or 'default-user'
    MINIO_PASSWORD = os.environ.get('MINIO_PASSWORD') or 'default-password'
    MINIO_SECURE = True
    """
    
    # MinIO configurations - 新配置
    MINIO_HOST = '192.168.3.143:9000'
    MINIO_USER = 'citu-dataops-acc-key'
    MINIO_PASSWORD = 'citu-dataops-secret-key'
    MINIO_SECURE = False  # 内网环境，设置为 False
    
    # Bucket configurations - 原配置
    """
    BUCKET_NAME = os.environ.get('BUCKET_NAME') or 'dev'
    if PLATFORM == 'windows':
        PREFIX = 'dataops-test'
    elif PLATFORM == 'linux':
        PREFIX = 'dataops'
    """
    
    # Bucket configurations - 新配置
    BUCKET_NAME = 'dataops-test'
    PREFIX = ''  # 由于 bucket_name 已经包含了所需信息，PREFIX 可以置空
    
    # 新增端口配置基类设置
    PORT = 5500  # 默认端口

    # 修改后（PostgreSQL配置）
     
    # SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:citupgdba@192.168.3.143:5432/dataops'
    # 本地开发环境
    SQLALCHEMY_DATABASE_URI = 'postgresql://postgres:dataOps@192.168.3.143:5432/dataops'
    SQLALCHEMY_ENGINE_OPTIONS = {
        'pool_pre_ping': True,
        'pool_recycle': 300,
        'pool_size': 10,
        'max_overflow': 20
    } 
   
    # 修改后（PostgreSQL配置）


    # Neo4j配置段
     

    NEO4J_URI = "bolt://192.168.3.143:7687"
    NEO4J_HTTP_URI = "http://192.168.3.143:7474"
    NEO4J_USER = "neo4j"
    NEO4J_PASSWORD = "cituneo4j"
    NEO4J_ENCRYPTED = False  # 内网环境可关闭加密 

  
class DevelopmentConfig(Config):
    """Development configuration"""
    DEBUG = True
    PORT = 5500  # 开发环境保持5500

class ProductionConfig(Config):
    """Production configuration"""
    DEBUG = False
    PORT = 80  # 生产环境使用标准HTTP端口

# Configuration dictionary
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
} 