- Updated README to include KodBox in project vision. - Added model descriptions for clarity in Download, File, Folder, Group, Node, Order, Policy, Redeem, Report, Request, Response, Setting, Share, SourceLink, StoragePack, Tag, Task, User, and WebDAV. - Changed optional fields from Optional[...] to the new union type syntax (e.g., str | None). - Improved foreign key references in models for consistency. - Refactored relationships in models to use singular forms where appropriate. - Updated login service to reflect changes in request model types.
23 lines
815 B
Python
23 lines
815 B
Python
|
|
from typing import Optional, TYPE_CHECKING
|
|
from datetime import datetime
|
|
from sqlmodel import Field, Relationship, Column, func, DateTime
|
|
from .base import TableBase
|
|
from datetime import datetime
|
|
|
|
if TYPE_CHECKING:
|
|
from .user import User
|
|
|
|
class StoragePack(TableBase, table=True):
|
|
"""容量包模型"""
|
|
|
|
name: str = Field(max_length=255, description="容量包名称")
|
|
active_time: datetime | None = Field(default=None, description="激活时间")
|
|
expired_time: datetime | None = Field(default=None, index=True, description="过期时间")
|
|
size: int = Field(description="容量包大小(字节)")
|
|
|
|
# 外键
|
|
user_id: int = Field(foreign_key="user.id", index=True, description="所属用户ID")
|
|
|
|
# 关系
|
|
user: "User" = Relationship(back_populates="storage_packs") |