- 新增多个 API 路由:`/api/customers`, `/api/products`, `/api/advisors`, `/api/compliance`, `/api/staff`,支持客户信息、产品详情、理财师客户列表、合规判定及员工上下文查询。 - 引入平台服务层,封装核心只读操作,支持数据脱敏功能。 - 更新依赖注入,确保各 API 路由的权限控制与数据访问一致性。 - 添加相应的单元测试,确保新接口的功能完整性与稳定性。 此更新为代销平台提供了基础的 REST API 支持,增强了系统的可扩展性与可维护性。
79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
"""环境配置(从 .env 读取,见 .env.example)。"""
|
||
|
||
from decimal import Decimal
|
||
|
||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||
|
||
app_env: str = "development"
|
||
|
||
mysql_host: str = "127.0.0.1"
|
||
mysql_port: int = 3306
|
||
mysql_database: str = "jinrong_agent"
|
||
mysql_core_database: str = "jinrong_core"
|
||
mysql_user: str = "root"
|
||
mysql_password: str = ""
|
||
|
||
redis_url: str = "redis://127.0.0.1:6379/0"
|
||
|
||
neo4j_uri: str = "bolt://localhost:7687"
|
||
neo4j_user: str = "neo4j"
|
||
neo4j_password: str = ""
|
||
|
||
milvus_uri: str = "./data/milvus.db"
|
||
|
||
ollama_base_url: str = "http://127.0.0.1:11434"
|
||
embed_model: str = "bge-m3"
|
||
embed_dim: int = 1024
|
||
embed_timeout_seconds: float = 60.0
|
||
|
||
deepseek_api_key: str = ""
|
||
deepseek_base_url: str = "https://api.deepseek.com"
|
||
|
||
# ===== JWT(T-01 · JWT 手册 §4/§11)=====
|
||
jwt_public_key_path: str = ""
|
||
jwt_dev_secret: str = "change-me-in-dev-only"
|
||
jwt_dev_algorithm: str = "HS256"
|
||
jwt_dev_expire_hours: int = 8
|
||
jwt_issuer: str = "https://idp.jinrong.internal"
|
||
jwt_audience: str = "agent-gateway"
|
||
|
||
# ===== Risk 阈值(默认值=冻结规则 · docs/PRD/附-风控规则表.md)=====
|
||
risk_large_amount: Decimal = Decimal("500000")
|
||
risk_daily_total: Decimal = Decimal("500000")
|
||
risk_freq_count: int = 3
|
||
risk_probe_window_minutes: int = 5
|
||
risk_probe_count: int = 3
|
||
risk_probe_amount: Decimal = Decimal("400000")
|
||
risk_small_amount: Decimal = Decimal("10000")
|
||
risk_small_count: int = 3
|
||
risk_aml_default_threshold: Decimal = Decimal("0.85")
|
||
|
||
# ===== 风控追加 v1.1(FR-8/9/10 · PRD §4A · C4~C6 共用)=====
|
||
risk_concentration_threshold: float = 0.80
|
||
risk_escalation_scan_minutes: int = 15
|
||
risk_escalation_l1_hours: int = 4
|
||
risk_escalation_l2_hours: int = 24
|
||
risk_escalation_aml_l1_hours: int = 1
|
||
risk_escalation_aml_l2_hours: int = 4
|
||
risk_agent_behavior_scan_minutes: int = 30
|
||
risk_agent_behavior_a_window_hours: int = 24
|
||
risk_agent_behavior_a_count: int = 3
|
||
risk_agent_behavior_b_window_hours: int = 72
|
||
risk_agent_behavior_b_count: int = 5
|
||
risk_agent_behavior_c_window_hours: int = 24
|
||
risk_agent_behavior_c_count: int = 10
|
||
|
||
# ===== 输入防护(T-03 · F-03)=====
|
||
guard_rate_limit_max: int = 30
|
||
guard_rate_limit_window_seconds: int = 60
|
||
|
||
# ===== 代销平台 API(v0.1)=====
|
||
platform_response_desensitize: bool = False
|
||
|
||
|
||
settings = Settings()
|