42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
"""投顾 Agent 草稿 ORM 模型。"""
|
|||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from decimal import Decimal
|
||
|
|
|
||
|
|
from sqlalchemy import BigInteger, CheckConstraint, DateTime, JSON, Numeric, String, Text, func
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from common.common_const import DRAFT_STATUS_DRAFT
|
||
|
|
from model.base import Base
|
||
|
|
|
||
|
|
|
||
|
|
class AdvisorDraft(Base):
|
||
|
|
__tablename__ = "advisor_draft"
|
||
|
|
__table_args__ = (
|
||
|
|
CheckConstraint(
|
||
|
|
"status IN ('draft', 'discarded')",
|
||
|
|
name="ck_advisor_draft_status",
|
||
|
|
),
|
||
|
|
{"comment": "投顾 Agent 草稿(不存 sent,不生成交易指令)"},
|
||
|
|
)
|
||
|
|
|
||
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||
|
|
draft_id: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
||
|
|
customer_id: Mapped[int] = mapped_column(BigInteger, index=True)
|
||
|
|
advisor_id: Mapped[int] = mapped_column(BigInteger, index=True)
|
||
|
|
intent: Mapped[str] = mapped_column(String(32), index=True)
|
||
|
|
title: Mapped[str] = mapped_column(String(128))
|
||
|
|
content: Mapped[str] = mapped_column(Text)
|
||
|
|
structured_data: Mapped[dict | None] = mapped_column(JSON)
|
||
|
|
status: Mapped[str] = mapped_column(String(16), default=DRAFT_STATUS_DRAFT, index=True)
|
||
|
|
deviation: Mapped[Decimal | None] = mapped_column(Numeric(10, 4))
|
||
|
|
disclaimer_ok: Mapped[bool] = mapped_column(default=False)
|
||
|
|
warning: Mapped[str | None] = mapped_column(String(512))
|
||
|
|
create_time: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime, server_default=func.now(), index=True
|
||
|
|
)
|
||
|
|
update_time: Mapped[datetime] = mapped_column(
|
||
|
|
DateTime, server_default=func.now(), onupdate=func.now()
|
||
|
|
)
|