Files
campus_spider/app/config/settings.py
T
2026-07-28 15:01:44 +08:00

55 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""项目配置,通过环境变量或项目根目录下的 .env 文件覆盖。"""
env: str = "dev"
# ──────────── MySQL(业务库)────────────
db_host: str = "192.168.31.105"
db_port: int = 3306
db_user: str = "root"
db_password: str = "123456"
db_name: str = "offerpie"
mysql_pool_size: int = 10
mysql_max_overflow: int = 10
# 连接池获取连接的等待超时(秒)
db_pool_timeout: int = 30
# 火山引擎(OpenAI 兼容风格)
volcengine_api_key: str = ""
volcengine_base_url: str = "https://ark.cn-beijing.volces.com/api/v3"
# ClaudeAnthropic 风格)
anthropic_api_key: str = ""
anthropic_base_url: str = ""
# ──────────── 阿里云 OSS ────────────
oss_access_key_id: str = ""
oss_access_key_secret: str = ""
oss_endpoint: str = "oss-cn-guangzhou.aliyuncs.com"
oss_bucket: str = "offerpie"
oss_upload_dir: str = "company/logo"
oss_domain: str = "https://offerpie.oss-cn-guangzhou.aliyuncs.com"
# ──────────── 日志 ────────────
logging_level: str = "INFO"
log_file_name: str = "spider.log"
@property
def mysql_url(self) -> str:
from urllib.parse import quote
return (
f"mysql+pymysql://{self.db_user}:{quote(self.db_password, safe='')}"
f"@{self.db_host}:{self.db_port}/{self.db_name}"
)
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=False,
extra="ignore",
)