All checks were successful
continuous-integration/drone/push Build is passing
- 新增告警模块 (alerts): 告警规则配置与触发 - 新增成本管理模块 (cost): 成本统计与分析 - 新增配额模块 (quota): 配额管理与限制 - 新增微信模块 (wechat): 微信相关功能接口 - 新增缓存服务 (cache): Redis 缓存封装 - 新增请求日志中间件 (request_logger) - 新增异常处理和链路追踪中间件 - 更新 dashboard 前端展示 - 更新 SDK stats_client 功能
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""配置管理"""
|
||
import os
|
||
from functools import lru_cache
|
||
from pydantic_settings import BaseSettings
|
||
from typing import Optional
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
"""应用配置"""
|
||
# 应用信息
|
||
APP_NAME: str = "000-platform"
|
||
APP_VERSION: str = "0.1.0"
|
||
DEBUG: bool = False
|
||
|
||
# 数据库
|
||
DATABASE_URL: str = "mysql+pymysql://scrm_reader:ScrmReader2024Pass@47.107.71.55:3306/new_qiqi"
|
||
|
||
# Redis
|
||
REDIS_URL: str = "redis://localhost:6379/0"
|
||
REDIS_PREFIX: str = "platform:"
|
||
|
||
# API Key(内部服务调用)
|
||
API_KEY: str = "platform_api_key_2026"
|
||
|
||
# 管理员账号
|
||
ADMIN_USERNAME: str = "admin"
|
||
ADMIN_PASSWORD_HASH: str = "" # bcrypt hash
|
||
|
||
# JWT
|
||
JWT_SECRET: str = "platform_jwt_secret_2026_change_in_prod"
|
||
JWT_ALGORITHM: str = "HS256"
|
||
JWT_EXPIRE_HOURS: int = 24
|
||
|
||
# 配置加密密钥
|
||
CONFIG_ENCRYPT_KEY: str = "platform_config_key_32bytes!!"
|
||
|
||
# 企业微信配置
|
||
WECHAT_ACCESS_TOKEN_EXPIRE: int = 7000 # access_token缓存时间(秒),企微有效期7200秒
|
||
WECHAT_JSAPI_TICKET_EXPIRE: int = 7000 # jsapi_ticket缓存时间(秒)
|
||
|
||
class Config:
|
||
env_file = ".env"
|
||
extra = "ignore"
|
||
|
||
|
||
@lru_cache()
|
||
def get_settings() -> Settings:
|
||
return Settings()
|