feat: Implement API routers for user, tag, vas, webdav, and slave functionalities

- Added user authentication and registration endpoints with JWT support.
- Created tag management routes for creating and deleting tags.
- Implemented value-added service (VAS) endpoints for managing storage packs and orders.
- Developed WebDAV account management routes for creating, updating, and deleting accounts.
- Introduced slave router for handling file uploads, downloads, and aria2 task management.
- Enhanced JWT utility functions for token creation and secret key management.
- Established lifespan management for FastAPI application startup and shutdown processes.
- Integrated password handling utilities with Argon2 hashing and two-factor authentication support.
This commit is contained in:
2025-12-19 18:04:34 +08:00
parent 11b67bde6d
commit 51b6de921b
30 changed files with 223 additions and 534 deletions

View File

@@ -8,6 +8,7 @@ from .base import TableBase, SQLModelBase, UUIDTableBase
if TYPE_CHECKING:
from .user import User
from .policy import Policy
# ==================== Base 模型 ====================
@@ -70,6 +71,10 @@ class GroupResponse(GroupBase, GroupOptionsBase):
# ==================== 数据库模型 ====================
# GroupPolicyLink 定义在 policy.py 中以避免循环导入
from .policy import GroupPolicyLink
class GroupOptions(GroupOptionsBase, TableBase, table=True):
"""用户组选项模型"""
@@ -104,9 +109,6 @@ class Group(GroupBase, UUIDTableBase, table=True):
name: str = Field(max_length=255, unique=True)
"""用户组名"""
policies: str | None = Field(default=None, max_length=255)
"""允许的策略ID列表逗号分隔"""
max_storage: int = Field(default=0, sa_column_kwargs={"server_default": "0"})
"""最大存储空间(字节)"""
@@ -128,6 +130,12 @@ class Group(GroupBase, UUIDTableBase, table=True):
sa_relationship_kwargs={"uselist": False}
)
# 多对多关系:用户组可以关联多个存储策略
policies: list["Policy"] = Relationship(
back_populates="groups",
link_model=GroupPolicyLink,
)
# 关系:一个组可以有多个用户
user: list["User"] = Relationship(
back_populates="group",