35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""fin_customer_profile 客户画像主表 ORM 模型。"""
|
|||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from decimal import Decimal
|
||
|
|
|
||
|
|
from sqlalchemy import JSON, BigInteger, DateTime, Integer, Numeric, String, func
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from model.base import Base
|
||
|
|
|
||
|
|
|
||
|
|
class FinCustomerProfile(Base):
|
||
|
|
__tablename__ = "fin_customer_profile"
|
||
|
|
__table_args__ = {"comment": "客户画像主表(RAG/GraphRAG 个性化推荐核心上下文)"}
|
||
|
|
|
||
|
|
customer_id: Mapped[int] = mapped_column(
|
||
|
|
BigInteger, primary_key=True, autoincrement=False
|
||
|
|
)
|
||
|
|
risk_level: Mapped[str | None] = mapped_column(String(16))
|
||
|
|
risk_score: Mapped[int | None] = mapped_column(Integer)
|
||
|
|
investment_experience: Mapped[str | None] = mapped_column(String(16))
|
||
|
|
annual_income_range: Mapped[str | None] = mapped_column(String(32))
|
||
|
|
total_assets: Mapped[Decimal | None] = mapped_column(Numeric(18, 2))
|
||
|
|
asset_allocation: Mapped[dict | None] = mapped_column(JSON)
|
||
|
|
product_preference: Mapped[dict | None] = mapped_column(JSON)
|
||
|
|
customer_level: Mapped[str | None] = mapped_column(String(16))
|
||
|
|
confidence_score: Mapped[Decimal] = mapped_column(
|
||
|
|
Numeric(5, 2), server_default="0.50"
|
||
|
|
)
|
||
|
|
profile_version: Mapped[int] = mapped_column(Integer, server_default="1")
|
||
|
|
update_time: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime, server_default=func.now(), onupdate=func.now()
|
||
|
|
)
|