refactor(backend): 重命名后端项目为 gym-manage-api,修改包名为 cn.novalon.gym.manage

This commit is contained in:
张翔
2026-04-17 18:35:50 +08:00
parent 666189b676
commit deb961c427
916 changed files with 108360 additions and 38328 deletions
+57
View File
@@ -0,0 +1,57 @@
"""
文件管理 API 客户端
"""
from httpx import AsyncClient
import io
class FileAPI:
"""文件管理 API 客户端"""
def __init__(self, client: AsyncClient):
self.client = client
async def get_file_list(self):
"""获取文件列表"""
return await self.client.get('/api/files')
async def get_file_by_id(self, file_id):
"""根据ID获取文件"""
return await self.client.get(f'/api/files/{file_id}')
async def upload(self, file_path, upload_user):
"""上传文件"""
with open(file_path, 'rb') as f:
return await self.client.post('/api/files/upload', json={'file': file_path, 'uploadUser': upload_user})
async def upload_file(self, file_content, filename, upload_user="test_user"):
"""上传文件(内存方式)"""
files = {'file': (filename, file_content, 'text/plain')}
headers = {'X-Username': upload_user}
return await self.client.post('/api/files/upload', files=files, headers=headers)
async def download(self, file_id):
"""下载文件"""
return await self.client.get(f'/api/files/{file_id}/download')
async def delete(self, file_id):
"""删除文件"""
return await self.client.delete(f'/api/files/{file_id}')
async def get_file_info(self, file_id):
"""获取文件信息(别名)"""
return await self.get_file_by_id(file_id)
async def download_file(self, file_id):
"""下载文件(别名)"""
return await self.download(file_id)
async def delete_file(self, file_id):
"""删除文件(别名)"""
return await self.delete(file_id)
class SysFileAPI(FileAPI):
"""系统文件 API (别名)"""
pass