Files

57 lines
1.7 KiB
Python

from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
app_name: str = "甘肃省房地产价格评估行业协会"
cors_origins: str = (
"http://127.0.0.1:13000,http://localhost:13000,"
"http://127.0.0.1:13006,http://localhost:13006"
)
jwt_secret: str = ""
jwt_expire_minutes: int = 120
# 门户会员令牌(专家答疑等),默认 7 天;工作人员仍用 jwt_expire_minutes。
jwt_member_expire_minutes: int = 10080
api_payload_encrypt: bool = False
api_payload_aes_key: str = ""
api_ip_blacklist: str = ""
database_url: str = ""
redis_host: str = "127.0.0.1"
redis_port: int = 6379
redis_db: int = 0
redis_password: str = ""
redis_timeout_sec: int = 30
redis_ssl_enabled: bool = False
minio_endpoint: str = ""
minio_access_key: str = ""
minio_secret_key: str = ""
minio_bucket_public: str = "gsfdc-public"
minio_bucket_private: str = "gsfdc-private"
minio_secure: bool = False
minio_base_url: str = ""
field_aes_key: str = ""
gaode_key: str = ""
gaode_security_js_code: str = ""
smtp_host: str = ""
smtp_port: int = 465
smtp_user: str = ""
smtp_password: str = ""
smtp_sender: str = ""
smtp_use_ssl: bool = True
@property
def cors_origin_list(self) -> list[str]:
return [item.strip() for item in self.cors_origins.split(",") if item.strip()]
@property
def blocked_ips(self) -> set[str]:
return {item.strip() for item in self.api_ip_blacklist.split(",") if item.strip()}
@lru_cache
def get_settings() -> Settings:
return Settings()