31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""advisor_todo 投顾待办表 ORM(事件/定时/计算三类来源统一承载)。
|
|||
|
|
|
||
|
|
幂等唯一键 uk_todo(todo_type, customer_id, biz_id) 由 DDL 维护;应用层在写入前
|
||
|
|
以相同三元组查询去重,避免重复建待办。
|
||
|
|
"""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
from sqlalchemy import BigInteger, DateTime, String, func
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from model.base import Base
|
||
|
|
|
||
|
|
|
||
|
|
class AdvisorTodo(Base):
|
||
|
|
__tablename__ = "advisor_todo"
|
||
|
|
__table_args__ = {"comment": "投顾待办表(事件/定时/计算三类来源统一承载)"}
|
||
|
|
|
||
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||
|
|
todo_type: Mapped[str] = mapped_column(String(32))
|
||
|
|
customer_id: Mapped[int | None] = mapped_column(BigInteger)
|
||
|
|
advisor_id: Mapped[int] = mapped_column(BigInteger)
|
||
|
|
source: Mapped[str] = mapped_column(String(32))
|
||
|
|
biz_id: Mapped[str | None] = mapped_column(String(64))
|
||
|
|
priority: Mapped[str] = mapped_column(String(8), server_default="普通")
|
||
|
|
status: Mapped[str] = mapped_column(String(16), server_default="待处理")
|
||
|
|
due_at: Mapped[datetime | None] = mapped_column(DateTime)
|
||
|
|
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||
|
|
handle_time: Mapped[datetime | None] = mapped_column(DateTime)
|