c50ccd258f
refactor(tests): 将e2e_tests迁移到tests_suite和api_integration_tests style: 为Java类添加文档注释 docs: 更新.gitignore和配置文件 test: 添加性能测试和Playwright测试脚本 chore: 清理旧测试文件和配置
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
"""
|
|
字典管理API封装
|
|
"""
|
|
|
|
from typing import Dict, Any, Optional
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class DictTypeAPI:
|
|
"""字典类型API"""
|
|
|
|
def __init__(self, client: AsyncClient):
|
|
self.client = client
|
|
self.base_path = "/api/dict/types"
|
|
|
|
async def get_all(self) -> Any:
|
|
"""获取所有字典类型"""
|
|
return await self.client.get(self.base_path)
|
|
|
|
async def get_by_id(self, dict_id: int) -> Any:
|
|
"""根据ID获取字典类型"""
|
|
return await self.client.get(f"{self.base_path}/{dict_id}")
|
|
|
|
async def create(self, data: Dict[str, Any]) -> Any:
|
|
"""创建字典类型"""
|
|
return await self.client.post(self.base_path, json=data)
|
|
|
|
async def update(self, dict_id: int, data: Dict[str, Any]) -> Any:
|
|
"""更新字典类型"""
|
|
return await self.client.put(f"{self.base_path}/{dict_id}", json=data)
|
|
|
|
async def delete(self, dict_id: int) -> Any:
|
|
"""删除字典类型"""
|
|
return await self.client.delete(f"{self.base_path}/{dict_id}")
|
|
|
|
|
|
class DictDataAPI:
|
|
"""字典数据API"""
|
|
|
|
def __init__(self, client: AsyncClient):
|
|
self.client = client
|
|
self.base_path = "/api/dict/data"
|
|
|
|
async def get_all(self) -> Any:
|
|
"""获取所有字典数据"""
|
|
return await self.client.get(self.base_path)
|
|
|
|
async def get_by_id(self, data_id: int) -> Any:
|
|
"""根据ID获取字典数据"""
|
|
return await self.client.get(f"{self.base_path}/{data_id}")
|
|
|
|
async def get_by_type(self, dict_type: str) -> Any:
|
|
"""根据字典类型获取字典数据"""
|
|
return await self.client.get(f"{self.base_path}/type/{dict_type}")
|
|
|
|
async def create(self, data: Dict[str, Any]) -> Any:
|
|
"""创建字典数据"""
|
|
return await self.client.post(self.base_path, json=data)
|
|
|
|
async def update(self, data_id: int, data: Dict[str, Any]) -> Any:
|
|
"""更新字典数据"""
|
|
return await self.client.put(f"{self.base_path}/{data_id}", json=data)
|
|
|
|
async def delete(self, data_id: int) -> Any:
|
|
"""删除字典数据"""
|
|
return await self.client.delete(f"{self.base_path}/{data_id}")
|