- P0: 实例访问控制全线接入权限组 (829测试) - P1: permissions字段激活 + 操作级权限检查 (843测试) - 前端: 删除数据权限页面, 权限组合并为唯一入口 - 新增: CodeMirror编辑器 + 查询模板 + 慢查询分析 - 新增: MongoDB管理页面 + Dashboard增强 - 修复: Pydantic V2迁移 + 前端TS错误修复
56 lines
2.4 KiB
Python
56 lines
2.4 KiB
Python
"""审批流程模型 — 支持多级、并行、条件审批。"""
|
|
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, ForeignKey, func
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class WorkflowDefinition(Base):
|
|
"""审批流程定义模板。"""
|
|
__tablename__ = "workflow_definitions"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(100), nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
is_default = Column(Boolean, default=False)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
|
|
steps = relationship("WorkflowStep", back_populates="workflow",
|
|
order_by="WorkflowStep.step_number",
|
|
cascade="all, delete-orphan")
|
|
|
|
|
|
class WorkflowStep(Base):
|
|
"""审批步骤定义。"""
|
|
__tablename__ = "workflow_steps"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
workflow_id = Column(Integer, ForeignKey("workflow_definitions.id"), nullable=False)
|
|
step_number = Column(Integer, nullable=False)
|
|
name = Column(String(100), nullable=False)
|
|
step_type = Column(String(20), nullable=False, default="serial") # serial / parallel / any_one
|
|
approver_role = Column(String(20), nullable=True) # admin / dba / manager
|
|
approver_ids = Column(Text, nullable=True) # JSON list of specific user ids
|
|
is_required = Column(Boolean, default=True)
|
|
timeout_hours = Column(Integer, default=24)
|
|
auto_approve_on_timeout = Column(Boolean, default=False)
|
|
|
|
workflow = relationship("WorkflowDefinition", back_populates="steps")
|
|
|
|
|
|
class TicketApproval(Base):
|
|
"""工单审批实例(运行时记录)。"""
|
|
__tablename__ = "ticket_approvals"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
ticket_id = Column(Integer, ForeignKey("tickets.id"), nullable=False)
|
|
step_number = Column(Integer, nullable=False)
|
|
step_name = Column(String(100), nullable=True)
|
|
approver_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
|
approver_role = Column(String(20), nullable=True)
|
|
action = Column(String(20), default="pending") # pending / approved / rejected / transferred / skipped
|
|
comment = Column(Text, nullable=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|