Files
MincedPad/backend/app/models.py
T
2026-07-14 12:40:26 +08:00

36 lines
1.6 KiB
Python

from datetime import datetime
from sqlalchemy import Boolean, DateTime, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.db import Base
class Item(Base):
__tablename__ = "items"
id: Mapped[int] = mapped_column(primary_key=True)
slug: Mapped[str] = mapped_column(String(32), unique=True, index=True)
kind: Mapped[str] = mapped_column(String(16)) # text|file
title: Mapped[str] = mapped_column(String(255), default="")
body: Mapped[str | None] = mapped_column(Text, nullable=True)
file_name: Mapped[str | None] = mapped_column(String(512), nullable=True)
file_path: Mapped[str | None] = mapped_column(String(512), nullable=True)
mime: Mapped[str | None] = mapped_column(String(128), nullable=True)
size_bytes: Mapped[int | None] = mapped_column(Integer, nullable=True)
is_public: Mapped[bool] = mapped_column(Boolean, default=True)
burn_after_read: Mapped[bool] = mapped_column(Boolean, default=False)
expires_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
created_ip: Mapped[str] = mapped_column(String(64), default="")
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
view_count: Mapped[int] = mapped_column(Integer, default=0)
burned: Mapped[bool] = mapped_column(Boolean, default=False)
class BannedIP(Base):
__tablename__ = "banned_ips"
ip: Mapped[str] = mapped_column(String(64), primary_key=True)
reason: Mapped[str] = mapped_column(String(255), default="")
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)