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.

36 lines
1.6 KiB
Python

from sqlalchemy import ForeignKey, Integer, String, Text, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.base_model import ModelMixin, TenantMixin, UserMixin
class EnergyReportTemplateModel(ModelMixin, TenantMixin, UserMixin):
"""能源报告模板模型。"""
__tablename__: str = "energy_report_template"
__table_args__ = (UniqueConstraint("tenant_id", "template_name"), {"comment": "能源报告模板表"})
__loader_options__: list[str] = [
"file",
"created_by",
"updated_by",
"deleted_by",
"tenant_by",
]
template_name: Mapped[str] = mapped_column(String(128), nullable=False, comment="模板名称", index=True)
template_type: Mapped[str] = mapped_column(String(64), nullable=False, comment="模板类型", index=True)
version: Mapped[str | None] = mapped_column(String(32), default=None, nullable=True, comment="模板版本")
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:停用", index=True)
order: Mapped[int] = mapped_column(Integer, default=999, nullable=False, comment="显示排序")
description: Mapped[str | None] = mapped_column(Text, default=None, nullable=True, comment="描述")
file = relationship("FileModel", lazy="selectin", foreign_keys=[file_id], uselist=False)