from __future__ import annotations from sqlalchemy import BigInteger, Boolean, Index, Integer, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base, SoftDeleteMixin, TimestampMixin class HomeMaterialWatermark(Base, TimestampMixin, SoftDeleteMixin): """首页素材水印图片库。""" __tablename__ = "home_material_watermarks" __table_args__ = ( Index("idx_home_material_watermarks_active", "deleted_at", "is_active", "created_at"), Index("idx_home_material_watermarks_default", "deleted_at", "is_default"), ) id: Mapped[str] = mapped_column(String(32), primary_key=True) name: Mapped[str] = mapped_column(String(128), nullable=False, index=True, comment="水印名称") file_url: Mapped[str] = mapped_column(Text, nullable=False, comment="水印图片URL") storage_path: Mapped[str] = mapped_column(Text, nullable=False, comment="水印图片本地路径") file_name: Mapped[str | None] = mapped_column(String(255), nullable=True, comment="原始文件名") file_size_bytes: Mapped[int] = mapped_column(BigInteger, default=0, server_default="0", nullable=False, comment="文件大小") width: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="水印图片宽度") height: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="水印图片高度") is_default: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false", nullable=False, index=True, comment="是否默认水印") is_active: Mapped[bool] = mapped_column(Boolean, default=True, server_default="true", nullable=False, index=True, comment="是否启用") created_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="创建管理员ID") updated_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="更新管理员ID")