feat: add system quality improvement plan and implementation

This commit is contained in:
张翔
2026-03-12 18:20:50 +08:00
parent c8646974d8
commit fe2e4110dd
238 changed files with 21864 additions and 2026 deletions
+41
View File
@@ -0,0 +1,41 @@
"""
文件管理API封装
"""
from typing import Dict, Any
from httpx import AsyncClient
class SysFileAPI:
"""文件管理API"""
def __init__(self, client: AsyncClient):
self.client = client
self.base_path = "/api/files"
async def get_all(self) -> Any:
"""获取所有文件"""
return await self.client.get(self.base_path)
async def get_by_id(self, file_id: int) -> Any:
"""根据ID获取文件信息"""
return await self.client.get(f"{self.base_path}/{file_id}")
async def upload(self, file_path: str, create_by: str = "test") -> Any:
"""上传文件"""
with open(file_path, "rb") as f:
files = {"file": f}
data = {"createBy": create_by}
return await self.client.post(f"{self.base_path}/upload", files=files, data=data)
async def download(self, file_name: str) -> Any:
"""下载文件"""
return await self.client.get(f"{self.base_path}/download/{file_name}")
async def preview(self, file_name: str) -> Any:
"""预览文件"""
return await self.client.get(f"{self.base_path}/preview/{file_name}")
async def delete(self, file_id: int) -> Any:
"""删除文件"""
return await self.client.delete(f"{self.base_path}/{file_id}")