Files
amb_rag/backend/app/models/plan.py
T
2026-09-01 12:24:43 +08:00

50 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""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.2plans 表。
"""
__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})>"