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.
41 lines
1.6 KiB
Python
41 lines
1.6 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 EnergyReportChapterModel(ModelMixin, TenantMixin, UserMixin):
|
|
"""能源报告章节模型。"""
|
|
|
|
__tablename__: str = "energy_report_chapter"
|
|
__table_args__: dict[str, str] = {"comment": "能源报告章节标注表"}
|
|
__loader_options__: list[str] = [
|
|
"template",
|
|
"rule",
|
|
"created_by",
|
|
"updated_by",
|
|
"deleted_by",
|
|
"tenant_by",
|
|
]
|
|
|
|
template_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("energy_report_template.id", ondelete="CASCADE", onupdate="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
comment="能源报告模板ID",
|
|
)
|
|
chapter_name: Mapped[str] = mapped_column(String(128), nullable=False, comment="章节名称", index=True)
|
|
chapter_order: Mapped[int] = mapped_column(Integer, default=999, nullable=False, comment="章节排序")
|
|
rule_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("rule_list.id", ondelete="RESTRICT", onupdate="CASCADE"),
|
|
nullable=False,
|
|
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)
|
|
rule = relationship("RuleModel", lazy="selectin", foreign_keys=[rule_id], uselist=False)
|