- 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.
24 lines
736 B
Python
24 lines
736 B
Python
|
|
from typing import TYPE_CHECKING, Optional
|
|
from sqlmodel import Field, Relationship, Index
|
|
from .base import TableBase
|
|
from datetime import datetime
|
|
|
|
if TYPE_CHECKING:
|
|
from .file import File
|
|
|
|
class SourceLink(TableBase, table=True):
|
|
"""链接模型"""
|
|
|
|
__table_args__ = (
|
|
Index("ix_sourcelink_file_name", "file_id", "name"),
|
|
)
|
|
|
|
name: str = Field(max_length=255, description="链接名称")
|
|
downloads: int = Field(default=0, sa_column_kwargs={"server_default": "0"}, description="通过此链接的下载次数")
|
|
|
|
# 外键
|
|
file_id: int = Field(foreign_key="file.id", index=True, description="关联的文件ID")
|
|
|
|
# 关系
|
|
file: "File" = Relationship(back_populates="source_links") |