mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
refactor(api): 渠道与存储管理端点通用化,端点层零目标特色
- schemas 新增公共 ManageRequest(target+action+params) 与 StorageAction 词汇表
- endpoint 层收敛为 POST /notification/manage、/storage/manage 两个通用接口,
不再定义任何渠道/存储特定的名称、参数与响应字段,前端上送参数原样透传
- chain 层 manage_channel/manage_storage 接受字符串标识纯透明转发,
StorageChain 移除全部特色管理方法
- FileManagerModule 新增 storage_manage 统一入口,模块返回归一化为
{success, message, data};wechatclawbot channel_manage 同步归一化,
路由标识兼容枚举名/值/对象
- dashboard 与 agentopsassistant 的用量查询改走 manage_storage(usage)
- 新增 10 项存储契约守护测试,通知侧补充 3 项链透传与字符串路由测试,
API 守护测试对 ManageRequest 开放映射按设计豁免
This commit is contained in:
+11
-38
@@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple, List, Dict
|
||||
from typing import Any, Optional, List, Dict
|
||||
|
||||
from app import schemas
|
||||
from app.chain import ChainBase
|
||||
@@ -13,35 +13,20 @@ class StorageChain(ChainBase):
|
||||
存储处理链
|
||||
"""
|
||||
|
||||
def save_config(self, storage: str, conf: dict) -> None:
|
||||
def manage_storage(self, storage: str, action: str, **params: Any) -> Dict[str, Any]:
|
||||
"""
|
||||
保存存储配置
|
||||
"""
|
||||
self.run_module("save_config", storage=storage, conf=conf)
|
||||
对指定网盘存储执行管理动作
|
||||
|
||||
def reset_config(self, storage: str) -> None:
|
||||
"""
|
||||
重置存储配置
|
||||
"""
|
||||
self.run_module("reset_config", storage=storage)
|
||||
不包含任何存储特定逻辑:存储标识、动作语义与参数解释全部封闭在
|
||||
实现 storage_manage 契约的模块内部
|
||||
|
||||
def generate_qrcode(self, storage: str) -> Optional[Tuple[dict, str]]:
|
||||
:param storage: 存储类型标识,用于模块路由
|
||||
:param action: 通用管理动作标识,具体语义由存储实现解释
|
||||
:param params: 表单与动作参数,原样透传给模块
|
||||
:return: 统一结构 {"success": bool, "message": ..., "data": ...}
|
||||
"""
|
||||
生成二维码
|
||||
"""
|
||||
return self.run_module("generate_qrcode", storage=storage)
|
||||
|
||||
def generate_auth_url(self, storage: str) -> Optional[Tuple[dict, str]]:
|
||||
"""
|
||||
生成 OAuth2 授权 URL
|
||||
"""
|
||||
return self.run_module("generate_auth_url", storage=storage)
|
||||
|
||||
def check_login(self, storage: str, **kwargs) -> Optional[Tuple[dict, str]]:
|
||||
"""
|
||||
登录确认
|
||||
"""
|
||||
return self.run_module("check_login", storage=storage, **kwargs)
|
||||
result = self.run_module("storage_manage", storage=storage, action=action, **params)
|
||||
return result or {"success": False, "message": "该存储类型未启用或不支持此管理动作"}
|
||||
|
||||
def list_files(self, fileitem: schemas.FileItem, recursion: bool = False) -> Optional[List[schemas.FileItem]]:
|
||||
"""
|
||||
@@ -136,18 +121,6 @@ class StorageChain(ChainBase):
|
||||
last_snapshot_time=last_snapshot_time, max_depth=max_depth,
|
||||
previous_snapshot=previous_snapshot)
|
||||
|
||||
def storage_usage(self, storage: str) -> Optional[schemas.StorageUsage]:
|
||||
"""
|
||||
存储使用情况
|
||||
"""
|
||||
return self.run_module("storage_usage", storage=storage)
|
||||
|
||||
def support_transtype(self, storage: str) -> Optional[dict]:
|
||||
"""
|
||||
获取支持的整理方式
|
||||
"""
|
||||
return self.run_module("support_transtype", storage=storage)
|
||||
|
||||
def is_bluray_folder(self, fileitem: Optional[schemas.FileItem]) -> bool:
|
||||
"""
|
||||
检查是否蓝光目录
|
||||
|
||||
Reference in New Issue
Block a user