refactor(backend): 重命名后端项目为 gym-manage-api,修改包名为 cn.novalon.gym.manage
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
字典管理 API 客户端
|
||||
"""
|
||||
|
||||
from httpx import AsyncClient
|
||||
|
||||
|
||||
class DictTypeAPI:
|
||||
"""字典类型 API 客户端"""
|
||||
|
||||
def __init__(self, client: AsyncClient):
|
||||
self.client = client
|
||||
|
||||
async def get_type_list(self, page: int = 0, size: int = 10):
|
||||
"""获取字典类型列表"""
|
||||
return await self.client.get(f'/api/dict/types?page={page}&size={size}')
|
||||
|
||||
async def get_type_by_id(self, dict_type_id: int):
|
||||
"""根据ID获取字典类型"""
|
||||
return await self.client.get(f'/api/dict/types/{dict_type_id}')
|
||||
|
||||
async def create(self, dict_type_data):
|
||||
"""创建字典类型"""
|
||||
return await self.client.post('/api/dict/types', json=dict_type_data)
|
||||
|
||||
async def update(self, dict_type_id: int, dict_type_data):
|
||||
"""更新字典类型"""
|
||||
return await self.client.put(f'/api/dict/types/{dict_type_id}', json=dict_type_data)
|
||||
|
||||
async def delete(self, dict_type_id: int):
|
||||
"""删除字典类型"""
|
||||
return await self.client.delete(f'/api/dict/types/{dict_type_id}')
|
||||
|
||||
|
||||
class DictDataAPI:
|
||||
"""字典数据 API 客户端"""
|
||||
|
||||
def __init__(self, client: AsyncClient):
|
||||
self.client = client
|
||||
|
||||
async def get_dict_list(self, page: int = 0, size: int = 10):
|
||||
"""获取字典数据列表"""
|
||||
return await self.client.get(f'/api/dict?page={page}&size={size}')
|
||||
|
||||
async def get_dict_by_id(self, dict_id: int):
|
||||
"""根据ID获取字典数据"""
|
||||
return await self.client.get(f'/api/dict/{dict_id}')
|
||||
|
||||
async def create(self, dict_data):
|
||||
"""创建字典数据"""
|
||||
return await self.client.post('/api/dict', json=dict_data)
|
||||
|
||||
async def update(self, dict_id: int, dict_data):
|
||||
"""更新字典数据"""
|
||||
return await self.client.put(f'/api/dict/{dict_id}', json=dict_data)
|
||||
|
||||
async def delete(self, dict_id: int):
|
||||
"""删除字典数据"""
|
||||
return await self.client.delete(f'/api/dict/{dict_id}')
|
||||
|
||||
|
||||
class DictAPI(DictTypeAPI, DictDataAPI):
|
||||
"""字典管理 API (组合)"""
|
||||
pass
|
||||
Reference in New Issue
Block a user