workflow.py 1.2 KB

123456789101112131415161718192021222324252627
  1. from sqlalchemy import BigInteger, ForeignKey, Integer, SmallInteger, String
  2. from sqlalchemy.orm import Mapped, mapped_column, relationship
  3. from app.models.base import BaseModel, SoftDeleteMixin
  4. class WorkflowDef(BaseModel, SoftDeleteMixin):
  5. __tablename__ = "bx_workflow_def"
  6. biz_type: Mapped[str] = mapped_column(String(32), nullable=False)
  7. wf_name: Mapped[str] = mapped_column(String(128), nullable=False)
  8. status: Mapped[int] = mapped_column(SmallInteger, nullable=False, default=1, server_default="1")
  9. remark: Mapped[str | None] = mapped_column(String(512))
  10. nodes: Mapped[list["WorkflowNode"]] = relationship(back_populates="workflow_def")
  11. class WorkflowNode(BaseModel):
  12. __tablename__ = "bx_workflow_node"
  13. wf_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("bx_workflow_def.id"), nullable=False)
  14. node_name: Mapped[str] = mapped_column(String(128), nullable=False)
  15. node_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default="0")
  16. approver_id: Mapped[int | None] = mapped_column(BigInteger)
  17. approver_name: Mapped[str | None] = mapped_column(String(64))
  18. workflow_def: Mapped["WorkflowDef"] = relationship(back_populates="nodes")