"""打印模板模型（发货单 / 发票）"""
from sqlalchemy import BigInteger, ForeignKey, String, Text, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column

from app.core.models.base import Base, TenantMixin, TimestampMixin


class PrintTemplate(Base, TenantMixin, TimestampMixin):
    __tablename__ = "print_templates"
    __table_args__ = (
        UniqueConstraint("tenant_id", "template_key", name="uk_print_template"),
        {
            "mysql_engine": "InnoDB",
            "mysql_charset": "utf8mb4",
            "mysql_collate": "utf8mb4_unicode_ci",
        },
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
    template_key: Mapped[str] = mapped_column(
        String(20), nullable=False, comment="slip | invoice",
    )
    content: Mapped[str] = mapped_column(Text, nullable=False, comment="HTML 模板内容")
