Add unit tests for models and services
- Implemented unit tests for Object model including folder and file creation, properties, and path retrieval. - Added unit tests for Setting model covering creation, unique constraints, and type enumeration. - Created unit tests for User model focusing on user creation, uniqueness, and group relationships. - Developed unit tests for Login service to validate login functionality, including 2FA and token generation. - Added utility tests for JWT creation and verification, ensuring token integrity and expiration handling. - Implemented password utility tests for password generation, hashing, and TOTP verification.
This commit is contained in:
6
routers/__init__.py
Normal file
6
routers/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from .api import router as api_router
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(api_router)
|
||||
7
routers/api/__init__.py
Normal file
7
routers/api/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from .v1 import router as v1_router
|
||||
|
||||
router = APIRouter(prefix="/api")
|
||||
|
||||
router.include_router(v1_router)
|
||||
45
routers/api/v1/__init__.py
Normal file
45
routers/api/v1/__init__.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from .admin import admin_router
|
||||
from .admin import admin_aria2_router
|
||||
from .admin import admin_file_router
|
||||
from .admin import admin_group_router
|
||||
from .admin import admin_policy_router
|
||||
from .admin import admin_share_router
|
||||
from .admin import admin_task_router
|
||||
from .admin import admin_vas_router
|
||||
|
||||
from .callback import callback_router
|
||||
from .directory import directory_router
|
||||
from .download import download_router
|
||||
from .file import file_router
|
||||
from .object import object_router
|
||||
from .share import share_router
|
||||
from .site import site_router
|
||||
from .slave import slave_router
|
||||
from .user import user_router
|
||||
from .vas import vas_router
|
||||
from .webdav import webdav_router
|
||||
|
||||
router = APIRouter(prefix="/v1")
|
||||
|
||||
router.include_router(admin_router)
|
||||
router.include_router(admin_aria2_router)
|
||||
router.include_router(admin_file_router)
|
||||
router.include_router(admin_group_router)
|
||||
router.include_router(admin_policy_router)
|
||||
router.include_router(admin_share_router)
|
||||
router.include_router(admin_task_router)
|
||||
router.include_router(admin_vas_router)
|
||||
|
||||
router.include_router(callback_router)
|
||||
router.include_router(directory_router)
|
||||
router.include_router(download_router)
|
||||
router.include_router(file_router)
|
||||
router.include_router(object_router)
|
||||
router.include_router(share_router)
|
||||
router.include_router(site_router)
|
||||
router.include_router(slave_router)
|
||||
router.include_router(user_router)
|
||||
router.include_router(vas_router)
|
||||
router.include_router(webdav_router)
|
||||
@@ -73,7 +73,7 @@ def router_admin_get_summary() -> ResponseBase:
|
||||
获取站点概况信息,包括用户数、分享数、文件数等。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含站点概况信息的响应模型。
|
||||
ResponseBase: 包含站点概况信息的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -88,7 +88,7 @@ def router_admin_get_news() -> ResponseBase:
|
||||
获取社区新闻信息,包括最新的动态和公告。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含社区新闻信息的响应模型。
|
||||
ResponseBase: 包含社区新闻信息的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -103,7 +103,7 @@ def router_admin_update_settings() -> ResponseBase:
|
||||
更新站点设置,包括站点名称、描述等。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含更新结果的响应模型。
|
||||
ResponseBase: 包含更新结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -118,7 +118,7 @@ def router_admin_get_settings() -> ResponseBase:
|
||||
获取站点设置,包括站点名称、描述等。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含站点设置的响应模型。
|
||||
ResponseBase: 包含站点设置的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -133,7 +133,7 @@ def router_admin_get_groups() -> ResponseBase:
|
||||
获取用户组列表,包括每个用户组的名称和权限信息。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含用户组列表的响应模型。
|
||||
ResponseBase: 包含用户组列表的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -151,7 +151,7 @@ def router_admin_get_group(group_id: int) -> ResponseBase:
|
||||
group_id (int): 用户组ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含用户组信息的响应模型。
|
||||
ResponseBase: 包含用户组信息的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -175,7 +175,7 @@ def router_admin_get_group_members(
|
||||
page_size (int, optional): 每页显示的成员数量,默认为20。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含用户组成员列表的响应模型。
|
||||
ResponseBase: 包含用户组成员列表的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -190,7 +190,7 @@ def router_admin_create_group() -> ResponseBase:
|
||||
创建一个新的用户组,设置名称和权限等信息。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含创建结果的响应模型。
|
||||
ResponseBase: 包含创建结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -208,7 +208,7 @@ def router_admin_update_group(group_id: int) -> ResponseBase:
|
||||
group_id (int): 用户组ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含更新结果的响应模型。
|
||||
ResponseBase: 包含更新结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -226,7 +226,7 @@ def router_admin_delete_group(group_id: int) -> ResponseBase:
|
||||
group_id (int): 用户组ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含删除结果的响应模型。
|
||||
ResponseBase: 包含删除结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -245,7 +245,7 @@ async def router_admin_get_user(session: SessionDep, user_id: int) -> ResponseBa
|
||||
user_id (int): 用户ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含用户信息的响应模型。
|
||||
ResponseBase: 包含用户信息的响应模型。
|
||||
"""
|
||||
user = await User.get_exist_one(session, user_id)
|
||||
return ResponseBase(data=user.to_public().model_dump())
|
||||
@@ -270,7 +270,7 @@ async def router_admin_get_users(
|
||||
page_size (int): 每页显示的用户数量,默认为20。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含用户列表的响应模型。
|
||||
ResponseBase: 包含用户列表的响应模型。
|
||||
"""
|
||||
offset = (page - 1) * page_size
|
||||
users: list[User] = await User.get(
|
||||
@@ -298,7 +298,7 @@ async def router_admin_create_user(
|
||||
创建一个新的用户,设置用户名、密码等信息。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含创建结果的响应模型。
|
||||
ResponseBase: 包含创建结果的响应模型。
|
||||
"""
|
||||
existing_user = await User.get(session, User.username == user.username)
|
||||
if existing_user:
|
||||
@@ -323,7 +323,7 @@ def router_admin_update_user(user_id: int) -> ResponseBase:
|
||||
user_id (int): 用户ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含更新结果的响应模型。
|
||||
ResponseBase: 包含更新结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -341,7 +341,7 @@ def router_admin_delete_user(user_id: int) -> ResponseBase:
|
||||
user_id (int): 用户ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含删除结果的响应模型。
|
||||
ResponseBase: 包含删除结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -365,7 +365,7 @@ def router_admin_get_file_list() -> ResponseBase:
|
||||
获取文件列表,包括文件名称、大小、上传时间等。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含文件列表的响应模型。
|
||||
ResponseBase: 包含文件列表的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -383,7 +383,7 @@ def router_admin_preview_file(file_id: int) -> ResponseBase:
|
||||
file_id (int): 文件ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含文件预览内容的响应模型。
|
||||
ResponseBase: 包含文件预览内容的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -403,7 +403,7 @@ def router_admin_ban_file(file_id: int) -> ResponseBase:
|
||||
file_id (int): 文件ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含删除结果的响应模型。
|
||||
ResponseBase: 包含删除结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -421,7 +421,7 @@ def router_admin_delete_file(file_id: int) -> ResponseBase:
|
||||
file_id (int): 文件ID。
|
||||
|
||||
Returns:
|
||||
ResponseModel: 包含删除结果的响应模型。
|
||||
ResponseBase: 包含删除结果的响应模型。
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ def router_callback_qq() -> ResponseBase:
|
||||
Handle QQ OAuth callback and return user information.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the QQ OAuth callback.
|
||||
ResponseBase: A model containing the response data for the QQ OAuth callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -84,7 +84,7 @@ def router_callback_alipay() -> ResponseBase:
|
||||
Handle Alipay payment callback and return payment status.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Alipay payment callback.
|
||||
ResponseBase: A model containing the response data for the Alipay payment callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -98,7 +98,7 @@ def router_callback_wechat() -> ResponseBase:
|
||||
Handle WeChat Pay payment callback and return payment status.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the WeChat Pay payment callback.
|
||||
ResponseBase: A model containing the response data for the WeChat Pay payment callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -112,7 +112,7 @@ def router_callback_stripe() -> ResponseBase:
|
||||
Handle Stripe payment callback and return payment status.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Stripe payment callback.
|
||||
ResponseBase: A model containing the response data for the Stripe payment callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -145,7 +145,7 @@ def router_callback_custom(order_no: str, id: str) -> ResponseBase:
|
||||
id (str): The ID associated with the payment.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the custom payment callback.
|
||||
ResponseBase: A model containing the response data for the custom payment callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -163,7 +163,7 @@ def router_callback_remote(session_id: str, key: str) -> ResponseBase:
|
||||
key (str): The key for the uploaded file.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the remote upload callback.
|
||||
ResponseBase: A model containing the response data for the remote upload callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -180,7 +180,7 @@ def router_callback_qiniu(session_id: str) -> ResponseBase:
|
||||
session_id (str): The session ID for the upload.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Qiniu Cloud upload callback.
|
||||
ResponseBase: A model containing the response data for the Qiniu Cloud upload callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -197,7 +197,7 @@ def router_callback_tencent(session_id: str) -> ResponseBase:
|
||||
session_id (str): The session ID for the upload.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Tencent Cloud upload callback.
|
||||
ResponseBase: A model containing the response data for the Tencent Cloud upload callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -214,7 +214,7 @@ def router_callback_aliyun(session_id: str) -> ResponseBase:
|
||||
session_id (str): The session ID for the upload.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Aliyun upload callback.
|
||||
ResponseBase: A model containing the response data for the Aliyun upload callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -231,7 +231,7 @@ def router_callback_upyun(session_id: str) -> ResponseBase:
|
||||
session_id (str): The session ID for the upload.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Upyun upload callback.
|
||||
ResponseBase: A model containing the response data for the Upyun upload callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -248,7 +248,7 @@ def router_callback_aws(session_id: str) -> ResponseBase:
|
||||
session_id (str): The session ID for the upload.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the AWS S3 upload callback.
|
||||
ResponseBase: A model containing the response data for the AWS S3 upload callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -265,7 +265,7 @@ def router_callback_onedrive_finish(session_id: str) -> ResponseBase:
|
||||
session_id (str): The session ID for the upload.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the OneDrive upload completion callback.
|
||||
ResponseBase: A model containing the response data for the OneDrive upload completion callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -279,7 +279,7 @@ def router_callback_onedrive_auth() -> ResponseBase:
|
||||
Handle OneDrive authorization callback and return authorization status.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the OneDrive authorization callback.
|
||||
ResponseBase: A model containing the response data for the OneDrive authorization callback.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -293,6 +293,6 @@ def router_callback_google_auth() -> ResponseBase:
|
||||
Handle Google OAuth completion callback and return authorization status.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Google OAuth completion callback.
|
||||
ResponseBase: A model containing the response data for the Google OAuth completion callback.
|
||||
"""
|
||||
pass
|
||||
@@ -2,11 +2,18 @@ from fastapi import APIRouter, Depends
|
||||
from middleware.auth import SignRequired
|
||||
from models.response import ResponseBase
|
||||
|
||||
download_router = APIRouter(
|
||||
prefix="/download",
|
||||
tags=["download"]
|
||||
)
|
||||
|
||||
aria2_router = APIRouter(
|
||||
prefix="/aria2",
|
||||
tags=["aria2"]
|
||||
)
|
||||
|
||||
download_router.include_router(aria2_router)
|
||||
|
||||
@aria2_router.post(
|
||||
path='/url',
|
||||
summary='创建URL下载任务',
|
||||
@@ -18,7 +25,7 @@ def router_aria2_url() -> ResponseBase:
|
||||
Create a URL download task endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the URL download task.
|
||||
ResponseBase: A model containing the response data for the URL download task.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -36,7 +43,7 @@ def router_aria2_torrent(id: str) -> ResponseBase:
|
||||
id (str): The ID of the torrent to download.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the torrent download task.
|
||||
ResponseBase: A model containing the response data for the torrent download task.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -54,7 +61,7 @@ def router_aria2_select(gid: str) -> ResponseBase:
|
||||
gid (str): The GID of the download task.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the re-selection of files.
|
||||
ResponseBase: A model containing the response data for the re-selection of files.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -72,7 +79,7 @@ def router_aria2_delete(gid: str) -> ResponseBase:
|
||||
gid (str): The GID of the download task to delete.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the deletion of the download task.
|
||||
ResponseBase: A model containing the response data for the deletion of the download task.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -87,7 +94,7 @@ def router_aria2_downloading() -> ResponseBase:
|
||||
Get currently downloading tasks endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for currently downloading tasks.
|
||||
ResponseBase: A model containing the response data for currently downloading tasks.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -102,6 +109,6 @@ def router_aria2_finished() -> ResponseBase:
|
||||
Get finished tasks endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for finished tasks.
|
||||
ResponseBase: A model containing the response data for finished tasks.
|
||||
"""
|
||||
pass
|
||||
@@ -45,7 +45,7 @@ def router_file_source(id: str, name: str) -> ResponseBase:
|
||||
name (str): The name of the file.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file with a redirect.
|
||||
ResponseBase: A model containing the response data for the file with a redirect.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -62,7 +62,7 @@ def router_file_download(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to download.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file download.
|
||||
ResponseBase: A model containing the response data for the file download.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -79,7 +79,7 @@ def router_file_archive_download(sessionID: str) -> ResponseBase:
|
||||
sessionID (str): The session ID for the archive.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the archived files download.
|
||||
ResponseBase: A model containing the response data for the archived files download.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -97,7 +97,7 @@ def router_file_upload(sessionID: str, index: int, file: UploadFile) -> Response
|
||||
index (int): The index of the file being uploaded.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data.
|
||||
ResponseBase: A model containing the response data.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -112,7 +112,7 @@ def router_file_upload_session() -> ResponseBase:
|
||||
Create an upload session endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the upload session.
|
||||
ResponseBase: A model containing the response data for the upload session.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -130,7 +130,7 @@ def router_file_upload_session_delete(sessionID: str) -> ResponseBase:
|
||||
sessionID (str): The session ID to delete.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the deletion.
|
||||
ResponseBase: A model containing the response data for the deletion.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -145,7 +145,7 @@ def router_file_upload_session_clear() -> ResponseBase:
|
||||
Clear all upload sessions endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for clearing all sessions.
|
||||
ResponseBase: A model containing the response data for clearing all sessions.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -163,7 +163,7 @@ def router_file_update(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to update.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file update.
|
||||
ResponseBase: A model containing the response data for the file update.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -178,7 +178,7 @@ def router_file_create() -> ResponseBase:
|
||||
Create a blank file endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file creation.
|
||||
ResponseBase: A model containing the response data for the file creation.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -196,7 +196,7 @@ def router_file_download(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to download.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file download session.
|
||||
ResponseBase: A model containing the response data for the file download session.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -214,7 +214,7 @@ def router_file_preview(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to preview.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file preview.
|
||||
ResponseBase: A model containing the response data for the file preview.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -232,7 +232,7 @@ def router_file_content(id: str) -> ResponseBase:
|
||||
id (str): The ID of the text file.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the text file content.
|
||||
ResponseBase: A model containing the response data for the text file content.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -250,7 +250,7 @@ def router_file_doc(id: str) -> ResponseBase:
|
||||
id (str): The ID of the Office document.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the Office document preview URL.
|
||||
ResponseBase: A model containing the response data for the Office document preview URL.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -268,7 +268,7 @@ def router_file_thumb(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to get the thumbnail for.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file thumbnail.
|
||||
ResponseBase: A model containing the response data for the file thumbnail.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -286,7 +286,7 @@ def router_file_source(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to get the external link for.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file external link.
|
||||
ResponseBase: A model containing the response data for the file external link.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -304,7 +304,7 @@ def router_file_archive(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to archive.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the archived files.
|
||||
ResponseBase: A model containing the response data for the archived files.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -322,7 +322,7 @@ def router_file_compress(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to compress.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file compression task.
|
||||
ResponseBase: A model containing the response data for the file compression task.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -340,7 +340,7 @@ def router_file_decompress(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to decompress.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file extraction task.
|
||||
ResponseBase: A model containing the response data for the file extraction task.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -358,7 +358,7 @@ def router_file_relocate(id: str) -> ResponseBase:
|
||||
id (str): The ID of the file to relocate.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file relocation task.
|
||||
ResponseBase: A model containing the response data for the file relocation task.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -377,6 +377,6 @@ def router_file_search(type: str, keyword: str) -> ResponseBase:
|
||||
keyword (str): The keyword to search for.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the file search.
|
||||
ResponseBase: A model containing the response data for the file search.
|
||||
"""
|
||||
pass
|
||||
@@ -118,7 +118,7 @@ def router_object_copy() -> ResponseBase:
|
||||
Copy an object endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the object copy.
|
||||
ResponseBase: A model containing the response data for the object copy.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -133,7 +133,7 @@ def router_object_rename() -> ResponseBase:
|
||||
Rename an object endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the object rename.
|
||||
ResponseBase: A model containing the response data for the object rename.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -151,6 +151,6 @@ def router_object_property(id: str) -> ResponseBase:
|
||||
id (str): The ID of the object to retrieve properties for.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the object properties.
|
||||
ResponseBase: A model containing the response data for the object properties.
|
||||
"""
|
||||
pass
|
||||
306
routers/api/v1/share/__init__.py
Normal file
306
routers/api/v1/share/__init__.py
Normal file
@@ -0,0 +1,306 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from middleware.auth import SignRequired
|
||||
from models.response import ResponseBase
|
||||
|
||||
share_router = APIRouter(
|
||||
prefix='/share',
|
||||
tags=["share"],
|
||||
)
|
||||
|
||||
@share_router.get(
|
||||
path='/{info}/{id}',
|
||||
summary='获取分享',
|
||||
description='Get shared content by info type and ID.',
|
||||
)
|
||||
def router_share_get(info: str, id: str) -> ResponseBase:
|
||||
"""
|
||||
Get shared content by info type and ID.
|
||||
|
||||
Args:
|
||||
info (str): The type of information being shared.
|
||||
id (str): The ID of the shared content.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing shared content information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.put(
|
||||
path='/download/{id}',
|
||||
summary='创建文件下载会话',
|
||||
description='Create a file download session by ID.',
|
||||
)
|
||||
def router_share_download(id: str) -> ResponseBase:
|
||||
"""
|
||||
Create a file download session by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the file to be downloaded.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing download session information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='preview/{id}',
|
||||
summary='预览分享文件',
|
||||
description='Preview shared file by ID.',
|
||||
)
|
||||
def router_share_preview(id: str) -> ResponseBase:
|
||||
"""
|
||||
Preview shared file by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the file to be previewed.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing preview information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/doc/{id}',
|
||||
summary='取得Office文档预览地址',
|
||||
description='Get Office document preview URL by ID.',
|
||||
)
|
||||
def router_share_doc(id: str) -> ResponseBase:
|
||||
"""
|
||||
Get Office document preview URL by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the Office document.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing the document preview URL.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/content/{id}',
|
||||
summary='获取文本文件内容',
|
||||
description='Get text file content by ID.',
|
||||
)
|
||||
def router_share_content(id: str) -> ResponseBase:
|
||||
"""
|
||||
Get text file content by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the text file.
|
||||
|
||||
Returns:
|
||||
str: The content of the text file.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/list/{id}/{path:path}',
|
||||
summary='获取目录列文件',
|
||||
description='Get directory listing by ID and path.',
|
||||
)
|
||||
def router_share_list(id: str, path: str = '') -> ResponseBase:
|
||||
"""
|
||||
Get directory listing by ID and path.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the directory.
|
||||
path (str): The path within the directory.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing directory listing information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/search/{id}/{type}/{keywords}',
|
||||
summary='分享目录搜索',
|
||||
description='Search within a shared directory by ID, type, and keywords.',
|
||||
)
|
||||
def router_share_search(id: str, type: str, keywords: str) -> ResponseBase:
|
||||
"""
|
||||
Search within a shared directory by ID, type, and keywords.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the shared directory.
|
||||
type (str): The type of search (e.g., file, folder).
|
||||
keywords (str): The keywords to search for.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing search results.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.post(
|
||||
path='/archive/{id}',
|
||||
summary='归档打包下载',
|
||||
description='Archive and download shared content by ID.',
|
||||
)
|
||||
def router_share_archive(id: str) -> ResponseBase:
|
||||
"""
|
||||
Archive and download shared content by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the content to be archived.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing archive download information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/readme/{id}',
|
||||
summary='获取README文本文件内容',
|
||||
description='Get README text file content by ID.',
|
||||
)
|
||||
def router_share_readme(id: str) -> ResponseBase:
|
||||
"""
|
||||
Get README text file content by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the README file.
|
||||
|
||||
Returns:
|
||||
str: The content of the README file.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/thumb/{id}/{file}',
|
||||
summary='获取缩略图',
|
||||
description='Get thumbnail image by ID and file name.',
|
||||
)
|
||||
def router_share_thumb(id: str, file: str) -> ResponseBase:
|
||||
"""
|
||||
Get thumbnail image by ID and file name.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the shared content.
|
||||
file (str): The name of the file for which to get the thumbnail.
|
||||
|
||||
Returns:
|
||||
str: A Base64 encoded string of the thumbnail image.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.post(
|
||||
path='/report/{id}',
|
||||
summary='举报分享',
|
||||
description='Report shared content by ID.',
|
||||
)
|
||||
def router_share_report(id: str) -> ResponseBase:
|
||||
"""
|
||||
Report shared content by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the shared content to report.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing report submission information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/search',
|
||||
summary='搜索公共分享',
|
||||
description='Search public shares by keywords and type.',
|
||||
)
|
||||
def router_share_search_public(keywords: str, type: str = 'all') -> ResponseBase:
|
||||
"""
|
||||
Search public shares by keywords and type.
|
||||
|
||||
Args:
|
||||
keywords (str): The keywords to search for.
|
||||
type (str): The type of search (e.g., all, file, folder).
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing search results for public shares.
|
||||
"""
|
||||
pass
|
||||
|
||||
#####################
|
||||
# 需要登录的接口
|
||||
#####################
|
||||
|
||||
@share_router.post(
|
||||
path='/',
|
||||
summary='创建新分享',
|
||||
description='Create a new share endpoint.',
|
||||
dependencies=[Depends(SignRequired)]
|
||||
)
|
||||
def router_share_create() -> ResponseBase:
|
||||
"""
|
||||
Create a new share endpoint.
|
||||
|
||||
Returns:
|
||||
ResponseBase: A model containing the response data for the new share creation.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.get(
|
||||
path='/',
|
||||
summary='列出我的分享',
|
||||
description='Get a list of shares.',
|
||||
dependencies=[Depends(SignRequired)]
|
||||
)
|
||||
def router_share_list() -> ResponseBase:
|
||||
"""
|
||||
Get a list of shares.
|
||||
|
||||
Returns:
|
||||
ResponseBase: A model containing the response data for the list of shares.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.post(
|
||||
path='/save/{id}',
|
||||
summary='转存他人分享',
|
||||
description='Save another user\'s share by ID.',
|
||||
dependencies=[Depends(SignRequired)]
|
||||
)
|
||||
def router_share_save(id: str) -> ResponseBase:
|
||||
"""
|
||||
Save another user's share by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the share to be saved.
|
||||
|
||||
Returns:
|
||||
ResponseBase: A model containing the response data for the saved share.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.patch(
|
||||
path='/{id}',
|
||||
summary='更新分享信息',
|
||||
description='Update share information by ID.',
|
||||
dependencies=[Depends(SignRequired)]
|
||||
)
|
||||
def router_share_update(id: str) -> ResponseBase:
|
||||
"""
|
||||
Update share information by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the share to be updated.
|
||||
|
||||
Returns:
|
||||
ResponseBase: A model containing the response data for the updated share.
|
||||
"""
|
||||
pass
|
||||
|
||||
@share_router.delete(
|
||||
path='/{id}',
|
||||
summary='删除分享',
|
||||
description='Delete a share by ID.',
|
||||
dependencies=[Depends(SignRequired)]
|
||||
)
|
||||
def router_share_delete(id: str) -> ResponseBase:
|
||||
"""
|
||||
Delete a share by ID.
|
||||
|
||||
Args:
|
||||
id (str): The ID of the share to be deleted.
|
||||
|
||||
Returns:
|
||||
ResponseBase: A model containing the response data for the deleted share.
|
||||
"""
|
||||
pass
|
||||
@@ -23,7 +23,7 @@ def router_slave_ping() -> ResponseBase:
|
||||
Test route for checking connectivity.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model indicating success.
|
||||
ResponseBase: A response model indicating success.
|
||||
"""
|
||||
from utils.conf.appmeta import BackendVersion
|
||||
return ResponseBase(data=BackendVersion)
|
||||
@@ -42,7 +42,7 @@ def router_slave_post(data: str) -> ResponseBase:
|
||||
data (str): The data to be uploaded.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model indicating success.
|
||||
ResponseBase: A response model indicating success.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -60,7 +60,7 @@ def router_slave_download(speed: int, path: str, name: str) -> ResponseBase:
|
||||
name (str): The name of the file to be downloaded.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model containing download information.
|
||||
ResponseBase: A response model containing download information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -98,7 +98,7 @@ def router_slave_source(speed: int, path: str, name: str) -> ResponseBase:
|
||||
name (str): The name of the file to be linked.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model containing the external link for the file.
|
||||
ResponseBase: A response model containing the external link for the file.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -134,7 +134,7 @@ def router_slave_thumb(id: str) -> ResponseBase:
|
||||
id (str): The ID of the thumbnail image.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model containing the Base64 encoded thumbnail image.
|
||||
ResponseBase: A response model containing the Base64 encoded thumbnail image.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -152,7 +152,7 @@ def router_slave_delete(path: str) -> ResponseBase:
|
||||
path (str): The path of the file to be deleted.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model indicating success or failure of the deletion.
|
||||
ResponseBase: A response model indicating success or failure of the deletion.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -182,7 +182,7 @@ def router_slave_aria2_get(gid: str = None) -> ResponseBase:
|
||||
gid (str): The GID of the Aria2 task.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model containing the task information.
|
||||
ResponseBase: A response model containing the task information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -202,7 +202,7 @@ def router_slave_aria2_add(gid: str, url: str, options: dict = None) -> Response
|
||||
options (dict, optional): Additional options for the task.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model indicating success or failure of the task addition.
|
||||
ResponseBase: A response model indicating success or failure of the task addition.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -220,6 +220,6 @@ def router_slave_aria2_remove(gid: str) -> ResponseBase:
|
||||
gid (str): The GID of the Aria2 task to be removed.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A response model indicating success or failure of the task removal.
|
||||
ResponseBase: A response model indicating success or failure of the task removal.
|
||||
"""
|
||||
pass
|
||||
@@ -18,7 +18,7 @@ def router_tag_create_filter() -> ResponseBase:
|
||||
Create a file classification tag.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the created tag.
|
||||
ResponseBase: A model containing the response data for the created tag.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -33,7 +33,7 @@ def router_tag_create_link() -> ResponseBase:
|
||||
Create a directory shortcut tag.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the created tag.
|
||||
ResponseBase: A model containing the response data for the created tag.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -51,6 +51,6 @@ def router_tag_delete(id: str) -> ResponseBase:
|
||||
id (str): The ID of the tag to be deleted.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the deletion operation.
|
||||
ResponseBase: A model containing the response data for the deletion operation.
|
||||
"""
|
||||
pass
|
||||
@@ -274,8 +274,8 @@ async def router_user_me(
|
||||
"""
|
||||
获取用户信息.
|
||||
|
||||
:return: response.ResponseModel containing user information.
|
||||
:rtype: response.ResponseModel
|
||||
:return: response.ResponseBase containing user information.
|
||||
:rtype: response.ResponseBase
|
||||
"""
|
||||
# 加载 group 及其 options 关系
|
||||
group = await models.Group.get(
|
||||
|
||||
@@ -18,7 +18,7 @@ def router_vas_pack() -> ResponseBase:
|
||||
Get information about storage packs and quotas.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for storage packs and quotas.
|
||||
ResponseBase: A model containing the response data for storage packs and quotas.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -33,7 +33,7 @@ def router_vas_product() -> ResponseBase:
|
||||
Get product information along with payment details.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for products and payment information.
|
||||
ResponseBase: A model containing the response data for products and payment information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -48,7 +48,7 @@ def router_vas_order() -> ResponseBase:
|
||||
Create an order for a product.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the created order.
|
||||
ResponseBase: A model containing the response data for the created order.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -66,7 +66,7 @@ def router_vas_order_get(id: str) -> ResponseBase:
|
||||
id (str): The ID of the order to retrieve information for.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the specified order.
|
||||
ResponseBase: A model containing the response data for the specified order.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -84,7 +84,7 @@ def router_vas_redeem(code: str) -> ResponseBase:
|
||||
code (str): The redemption code to retrieve information for.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the specified redemption code.
|
||||
ResponseBase: A model containing the response data for the specified redemption code.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -99,6 +99,6 @@ def router_vas_redeem_post() -> ResponseBase:
|
||||
Redeem a redemption code for a product or service.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the redeemed code.
|
||||
ResponseBase: A model containing the response data for the redeemed code.
|
||||
"""
|
||||
pass
|
||||
@@ -19,7 +19,7 @@ def router_webdav_accounts() -> ResponseBase:
|
||||
Get account information for WebDAV.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the account information.
|
||||
ResponseBase: A model containing the response data for the account information.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -34,7 +34,7 @@ def router_webdav_create_account() -> ResponseBase:
|
||||
Create a new WebDAV account.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the created account.
|
||||
ResponseBase: A model containing the response data for the created account.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -52,7 +52,7 @@ def router_webdav_delete_account(id: str) -> ResponseBase:
|
||||
id (str): The ID of the account to be deleted.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the deletion operation.
|
||||
ResponseBase: A model containing the response data for the deletion operation.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -67,7 +67,7 @@ def router_webdav_create_mount() -> ResponseBase:
|
||||
Create a new WebDAV mount point.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the created mount point.
|
||||
ResponseBase: A model containing the response data for the created mount point.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -85,7 +85,7 @@ def router_webdav_delete_mount(id: str) -> ResponseBase:
|
||||
id (str): The ID of the mount point to be deleted.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the deletion operation.
|
||||
ResponseBase: A model containing the response data for the deletion operation.
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -103,6 +103,6 @@ def router_webdav_update_account(id: str) -> ResponseBase:
|
||||
id (str): The ID of the account to be updated.
|
||||
|
||||
Returns:
|
||||
ResponseModel: A model containing the response data for the updated account.
|
||||
ResponseBase: A model containing the response data for the updated account.
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user