Files
Mutual_Fund/model/fin_customer_profile.py
T

33 lines
1.5 KiB
Python

"""fin_customer_profile 客户画像主表 ORM 模型。"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any
from sqlalchemy import BigInteger, DateTime, Integer, JSON, 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(一对一关联 sys_user.id),非自增 id
customer_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
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[str, Any] | None] = mapped_column(JSON)
product_preference: Mapped[dict[str, Any] | 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()
)