Files
novalon-manage-system/e2e_tests/api/menu_api.py
T
张翔 dc53a233b9 refactor(domain): 将领域模型移动到common模块
重构项目结构,将分散在各模块的领域模型统一移动到manage-common模块
更新相关依赖和引用路径
调整docker-compose配置和测试标记
添加新的Playwright测试配置
优化Dockerfile构建过程
2026-03-13 19:58:57 +08:00

46 lines
1.5 KiB
Python

"""
菜单管理API
"""
from typing import Dict, Any, List
from httpx import AsyncClient, Response
from .base_api import BaseAPI
class MenuAPI(BaseAPI):
"""菜单管理API"""
def __init__(self, client: AsyncClient):
super().__init__(client, "/api/menus")
async def create_menu(self, menu_data: Dict[str, Any]) -> Response:
"""创建菜单"""
return await self.post("", json=menu_data)
async def get_menu_by_id(self, menu_id: int) -> Response:
"""根据ID获取菜单"""
return await self.get(f"/{menu_id}")
async def get_all_menus(self) -> Response:
"""获取所有菜单"""
return await self.get("")
async def get_menu_tree(self) -> Response:
"""获取菜单树"""
return await self.get("/tree")
async def update_menu(self, menu_id: int, menu_data: Dict[str, Any]) -> Response:
"""更新菜单"""
return await self.put(f"/{menu_id}", json=menu_data)
async def delete_menu(self, menu_id: int) -> Response:
"""删除菜单"""
return await self.delete(f"/{menu_id}")
async def get_menus_by_parent(self, parent_id: int) -> Response:
"""根据父菜单ID获取子菜单"""
return await self.get("", params={"parentId": parent_id})
async def get_menus_by_type(self, menu_type: str) -> Response:
"""根据菜单类型获取菜单"""
return await self.get("", params={"menuType": menu_type})