attachment.py 1.1 KB

1234567891011121314151617181920212223
  1. from datetime import datetime
  2. from sqlalchemy import BigInteger, DateTime, Integer, SmallInteger, String, func
  3. from sqlalchemy.orm import Mapped, mapped_column
  4. from app.database import Base
  5. from app.models.base import SoftDeleteMixin
  6. class Attachment(Base, SoftDeleteMixin):
  7. __tablename__ = "bx_attachment"
  8. id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
  9. biz_type: Mapped[str] = mapped_column(String(32), nullable=False)
  10. biz_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
  11. file_name: Mapped[str] = mapped_column(String(256), nullable=False)
  12. file_path: Mapped[str] = mapped_column(String(512), nullable=False)
  13. file_type: Mapped[str | None] = mapped_column(String(128))
  14. file_size: Mapped[int | None] = mapped_column(BigInteger)
  15. attach_type: Mapped[str] = mapped_column(String(32), default="attachment", server_default="attachment")
  16. sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default="0")
  17. create_by: Mapped[str | None] = mapped_column(String(64))
  18. create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())