feat: Enhance models and README with additional features and improvements
- 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.
This commit is contained in:
@@ -9,7 +9,8 @@ if TYPE_CHECKING:
|
||||
from .download import Download
|
||||
|
||||
class Task(TableBase, table=True):
|
||||
__tablename__ = 'tasks'
|
||||
"""任务模型"""
|
||||
|
||||
__table_args__ = (
|
||||
CheckConstraint("progress BETWEEN 0 AND 100", name="ck_task_progress_range"),
|
||||
)
|
||||
@@ -17,11 +18,11 @@ class Task(TableBase, table=True):
|
||||
status: int = Field(default=0, sa_column_kwargs={"server_default": "0"}, description="任务状态: 0=排队中, 1=处理中, 2=完成, 3=错误")
|
||||
type: int = Field(description="任务类型")
|
||||
progress: int = Field(default=0, sa_column_kwargs={"server_default": "0"}, description="任务进度 (0-100)")
|
||||
error: Optional[str] = Field(default=None, description="错误信息")
|
||||
props: Optional[str] = Field(default=None, description="任务属性 (JSON格式)")
|
||||
error: str | None = Field(default=None, description="错误信息")
|
||||
props: str | None = Field(default=None, description="任务属性 (JSON格式)")
|
||||
|
||||
# 外键
|
||||
user_id: int = Field(foreign_key="users.id", index=True, description="所属用户ID")
|
||||
user_id: int = Field(foreign_key="user.id", index=True, description="所属用户ID")
|
||||
|
||||
# 关系
|
||||
user: "User" = Relationship(back_populates="tasks")
|
||||
|
||||
Reference in New Issue
Block a user