model.py 1.1 KB

12345678910111213141516171819202122232425
  1. from sqlalchemy import JSON, String, UniqueConstraint
  2. from sqlalchemy.orm import Mapped, mapped_column
  3. from app.core.base_model import ModelMixin, UserMixin
  4. class WorkflowModel(ModelMixin, UserMixin):
  5. """
  6. 工作流定义:Vue Flow 画布序列化 + Prefect 运行时执行
  7. """
  8. __tablename__: str = "task_workflow"
  9. __table_args__ = (UniqueConstraint("code", name="uq_task_workflow_code"), {"comment": "工作流定义表"})
  10. __loader_options__: list[str] = ["created_by", "updated_by"]
  11. name: Mapped[str] = mapped_column(String(128), nullable=False, comment="流程名称")
  12. code: Mapped[str] = mapped_column(String(64), nullable=False, comment="流程编码")
  13. workflow_status: Mapped[str] = mapped_column(
  14. String(32),
  15. nullable=False,
  16. default="draft",
  17. comment="流程状态: draft/published/archived",
  18. )
  19. nodes: Mapped[list | None] = mapped_column(JSON, nullable=True, comment="Vue Flow nodes JSON")
  20. edges: Mapped[list | None] = mapped_column(JSON, nullable=True, comment="Vue Flow edges JSON")