You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.9 KiB
Python

from sqlalchemy import ForeignKey, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.base_model import ModelMixin, TenantMixin, UserMixin
class EnergyReportReviewModel(ModelMixin, TenantMixin, UserMixin):
"""能源报告审核任务模型。"""
__tablename__: str = "energy_report_review"
__table_args__: dict[str, str] = {"comment": "能源报告审核任务表"}
__loader_options__: list[str] = [
"template",
"file",
"reviewer",
"created_by",
"updated_by",
"deleted_by",
"tenant_by",
]
task_name: Mapped[str] = mapped_column(String(128), nullable=False, comment="任务名称", index=True)
template_id: Mapped[int] = mapped_column(
Integer,
ForeignKey("energy_report_template.id", ondelete="RESTRICT", onupdate="CASCADE"),
nullable=False,
index=True,
comment="能源报告模板ID",
)
file_id: Mapped[int] = mapped_column(
Integer,
ForeignKey("common_file.id", ondelete="RESTRICT", onupdate="CASCADE"),
nullable=False,
index=True,
comment="审核文档文件ID",
)
status: Mapped[int] = mapped_column(Integer, default=0, nullable=False, comment="状态 0:待审查 1:已审查 2:审查失败", index=True)
reviewer_id: Mapped[int | None] = mapped_column(
Integer,
ForeignKey("sys_user.id", ondelete="SET NULL", onupdate="CASCADE"),
nullable=True,
index=True,
comment="审查人ID",
)
description: Mapped[str | None] = mapped_column(Text, default=None, nullable=True, comment="描述")
template = relationship("EnergyReportTemplateModel", lazy="selectin", foreign_keys=[template_id], uselist=False)
file = relationship("FileModel", lazy="selectin", foreign_keys=[file_id], uselist=False)
reviewer = relationship("UserModel", lazy="selectin", foreign_keys=[reviewer_id], uselist=False)