50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
"""Plan 套餐模型。"""
|
||
|
||
from sqlalchemy import Boolean, Integer, String, Text
|
||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||
|
||
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||
|
||
|
||
class Plan(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||
"""用户套餐(免费/基础/专业等)。
|
||
|
||
技术审查 §2.2:plans 表。
|
||
"""
|
||
|
||
__tablename__ = "plans"
|
||
|
||
code: Mapped[str] = mapped_column(
|
||
String(32),
|
||
unique=True,
|
||
nullable=False,
|
||
comment="套餐代码 (free/basic/pro)",
|
||
)
|
||
name: Mapped[str] = mapped_column(
|
||
String(64),
|
||
nullable=False,
|
||
comment="套餐名称",
|
||
)
|
||
storage_quota: Mapped[int] = mapped_column(
|
||
Integer,
|
||
nullable=False,
|
||
comment="存储配额 (字节)",
|
||
)
|
||
max_file_size: Mapped[int] = mapped_column(
|
||
Integer,
|
||
nullable=False,
|
||
comment="单文件大小上限 (字节)",
|
||
)
|
||
is_active: Mapped[bool] = mapped_column(
|
||
Boolean,
|
||
default=True,
|
||
nullable=False,
|
||
comment="是否可用",
|
||
)
|
||
|
||
# 关系
|
||
users = relationship("User", back_populates="plan", lazy="selectin")
|
||
|
||
def __repr__(self) -> str:
|
||
return f"<Plan {self.code!r} ({self.name!r})>"
|