Files
offerpie_job_cleaner/app/config/settings.py
T
2026-07-03 17:27:18 +08:00

87 lines
3.1 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"
# ──────────── PostgreSQL(本地,app_job_data 源库)────────────
pg_host: str = "192.168.31.51"
pg_port: int = 5432
pg_user: str = "postgres"
pg_password: str = ""
pg_db: str = "postgres"
pg_pool_size: int = 10
pg_max_overflow: int = 20
# ──────────── 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 = 20
# ──────────── AI 供应商 ────────────
# 火山引擎(OpenAI 兼容风格)
volcengine_api_key: str = "fd065993-bee2-4f31-8bf2-56d5d3012c02"
volcengine_base_url: str = "https://ark.cn-beijing.volces.com/api/v3"
# ClaudeAnthropic 风格)
anthropic_api_key: str = "sk-43ccdb29caa7e9ebe0db8ac0958c63f6d3a2d62e59064d3d26d94332055a9bc9"
anthropic_base_url: str = "https://code.warpdevloper.cloud"
# ──────────── 岗位清洗参数 ────────────
clean_batch_size: int = 100
clean_concurrency: int = 80
clean_interval_seconds: int = 200
clean_total_limit: int = 0 # 累计清洗总数上限,达到后停止清洗任务;0 = 不限制
# ──────────── 公司补充参数 ────────────
company_batch_size: int = 20
company_concurrency: int = 10
company_interval_seconds: int = 300
# ──────────── 岗位下架参数 ────────────
job_expire_days: int = 7
# ──────────── 阿里云 OSS ────────────
oss_access_key_id: str = ""
oss_access_key_secret: str = ""
oss_endpoint: str = "oss-cn-guangzhou.aliyuncs.com"
oss_bucket: str = "offerpie"
# 固定上传目录(对象 key 前缀)
oss_upload_dir: str = "company/logo"
# 下载访问域名
oss_domain: str = "https://offerpie.oss-cn-guangzhou.aliyuncs.com"
# ──────────── 日志 ────────────
logging_level: str = "INFO"
log_file_name: str = "cleaner.log"
@property
def pg_url(self) -> str:
from urllib.parse import quote
return (
f"postgresql+asyncpg://{self.pg_user}:{quote(self.pg_password, safe='')}"
f"@{self.pg_host}:{self.pg_port}/{self.pg_db}"
)
@property
def mysql_url(self) -> str:
from urllib.parse import quote
return (
f"mysql+asyncmy://{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",
)