"""biz_work_order 工单表 ORM 模型。""" from __future__ import annotations from datetime import datetime from typing import Any from sqlalchemy import BigInteger, DateTime, JSON, String, func from sqlalchemy.orm import Mapped, mapped_column from model.base import Base class BizWorkOrder(Base): """客户工单状态记录。""" __tablename__ = "biz_work_order" __table_args__ = {"comment": "通用业务工单表"} id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True) work_order_no: Mapped[str] = mapped_column(String(32), nullable=False) order_type: Mapped[str] = mapped_column(String(32), nullable=False) sub_type: Mapped[str | None] = mapped_column(String(32), nullable=True) customer_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True) submitter_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True) handler_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True) current_node: Mapped[str] = mapped_column(String(32), nullable=False) priority: Mapped[str] = mapped_column(String(8), nullable=False) status: Mapped[str] = mapped_column(String(16), nullable=False) biz_content: Mapped[dict[str, Any] | None] = mapped_column(JSON, nullable=True) create_time: Mapped[datetime] = mapped_column( DateTime, server_default=func.now(), nullable=False ) update_time: Mapped[datetime] = mapped_column( DateTime, server_default=func.now(), onupdate=func.now(), nullable=False )