1e3dc11d59
feat(test-suite): 新增测试套件模块,包含API测试客户端和测试配置 fix(api): 修复数据库实体和仓库的删除操作返回值 style(api): 统一数据库表名和字段命名 perf(api): 添加缓存注解提升配置查询性能 test(api): 添加H2测试数据库配置支持 chore: 清理旧的测试文件和脚本
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
"""
|
|
字典管理 API 客户端
|
|
"""
|
|
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class DictionaryAPI:
|
|
"""字典管理 API 客户端"""
|
|
|
|
def __init__(self, client: AsyncClient):
|
|
self.client = client
|
|
|
|
async def get_dictionary_list(self):
|
|
"""获取字典列表"""
|
|
return await self.client.get('/api/dictionary')
|
|
|
|
async def get_dictionary_by_id(self, dictionary_id):
|
|
"""根据ID获取字典"""
|
|
return await self.client.get(f'/api/dictionary/{dictionary_id}')
|
|
|
|
async def create_dictionary(self, dictionary_data):
|
|
"""创建字典"""
|
|
return await self.client.post('/api/dictionary', json=dictionary_data)
|
|
|
|
async def update_dictionary(self, dictionary_id, dictionary_data):
|
|
"""更新字典"""
|
|
return await self.client.put(f'/api/dictionary/{dictionary_id}', json=dictionary_data)
|
|
|
|
async def delete_dictionary(self, dictionary_id):
|
|
"""删除字典"""
|
|
return await self.client.delete(f'/api/dictionary/{dictionary_id}')
|