""" 字典管理API """ from typing import Dict, Any from httpx import AsyncClient, Response from .base_api import BaseAPI class DictionaryAPI(BaseAPI): """字典管理API""" def __init__(self, client: AsyncClient): super().__init__(client, "/api/dictionaries") async def create_dictionary(self, dict_data: Dict[str, Any]) -> Response: """创建字典""" return await self.post("", json=dict_data) async def get_dictionary_by_id(self, dict_id: int) -> Response: """根据ID获取字典""" return await self.get(f"/{dict_id}") async def get_dictionaries_by_type(self, dict_type: str) -> Response: """根据类型获取字典""" return await self.get(f"/type/{dict_type}") async def get_all_dictionaries(self) -> Response: """获取所有字典""" return await self.get("") async def update_dictionary(self, dict_id: int, dict_data: Dict[str, Any]) -> Response: """更新字典""" return await self.put(f"/{dict_id}", json=dict_data) async def delete_dictionary(self, dict_id: int) -> Response: """删除字典""" return await self.delete(f"/{dict_id}") async def check_type_and_code_exists(self, dict_type: str, code: str) -> Response: """检查类型和编码是否存在""" return await self.get("/check/exists", params={"type": dict_type, "code": code})