import os

class Config:
    # 基础配置
    SECRET_KEY = os.getenv("SECRET_KEY", "vision-ai-secret-key")
    
    # PostgreSQL 配置
    SQLALCHEMY_DATABASE_URI = "postgresql://user_xREpkJ:password_DZz8DQ@331002.xyz:2022/ai_vision"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # Redis 配置
    REDIS_URL = "redis://:redis_WWjNyb@331002.xyz:2020/0"
    
    # Session 配置
    PERMANENT_SESSION_LIFETIME = 604800  # 7 天 (单位：秒)
    SESSION_COOKIE_SECURE = False        # 开发环境或非 HTTPS 生产环境设为 False
    SESSION_COOKIE_HTTPONLY = True       # 防止 XSS 获取 Cookie
    
    # MinIO 配置
    MINIO = {
        "endpoint": "http://331002.xyz:9000",
        "access_key": "l0VlsxrkASbXN2YSQrJk",
        "secret_key": "ZK8nXHieorl3fpbssUMGGfr8zZmbpXB5gAbma3z1",
        "bucket": "images",
        "public_url": "http://331002.xyz:9000/images/"
    }
    
    # AI API 配置
    AI_API = "https://ai.t8star.cn/v1/images/generations"
    CHAT_API = "https://ai.comfly.chat/v1/chat/completions"
    
    # 试用模式配置
    TRIAL_API = "https://ai.comfly.chat/v1/images/generations"
    TRIAL_KEY = "sk-Rr8L5noW8Qga7K4jmey3yYZYL1a4SlhlNlo5iZrwqJRK1Pa1"
    PREMIUM_KEY = "sk-168trRxnemem6nTpQn1rbmJ4SFKLwTMsZ0G6uk5OipP7FKAY"
    
    DICT_URL = "https://nas.4x4g.com:10011/api/common/sys/dict"
    PLATFORM = "lingmao"
    
    # 阿里云短信配置
    ALIBABA_CLOUD_ACCESS_KEY_ID = "LTAI5tAbHKxmPKVPYsABEdyq"
    ALIBABA_CLOUD_ACCESS_KEY_SECRET = "v6URREddBqvGfwZrWH1DWoxs3w6RxZ"
    SMS_SIGN_NAME = "速通互联验证码"
    SMS_TEMPLATE_CODE = "100001"
    SMS_NEED_PARAM = False  # 该模板需要参数，如使用系统赠送模板请改为 False
    
    # 支付宝配置 (待填)
    ALIPAY_APP_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AB
-----END PUBLIC KEY-----"""  # 支付宝公钥
    ALIPAY_RETURN_URL = "http://331002.xyz:2010/payment/return"  # 支付成功跳转地址
    ALIPAY_NOTIFY_URL = "http://331002.xyz:2010/payment/notify"  # 支付异步通知地址
    ALIPAY_DEBUG = False  # 是否使用沙箱环境

    # 开发模式配置
    DEV_MODE = False  # True=开发模式（固定验证码），False=生产模式（真实短信）
    DEV_SMS_CODE = "888888"  # 开发模式下的固定验证码
