"""
菜单管理 API 客户端
"""

from httpx import AsyncClient


class MenuAPI:
    """菜单管理 API 客户端"""
    
    def __init__(self, client: AsyncClient):
        self.client = client
    
    async def get_menu_list(self):
        """获取菜单列表"""
        return await self.client.get('/api/menus')
    
    async def get_menu_tree(self):
        """获取菜单树"""
        return await self.client.get('/api/menus/tree')
    
    async def get_menu_by_id(self, menu_id):
        """根据ID获取菜单"""
        return await self.client.get(f'/api/menus/{menu_id}')
    
    async def create_menu(self, menu_data):
        """创建菜单"""
        return await self.client.post('/api/menus', json=menu_data)
    
    async def update_menu(self, menu_id, menu_data):
        """更新菜单"""
        return await self.client.put(f'/api/menus/{menu_id}', json=menu_data)
    
    async def delete_menu(self, menu_id):
        """删除菜单"""
        return await self.client.delete(f'/api/menus/{menu_id}')
    
    async def get_user_menus(self, user_id):
        """获取用户菜单"""
        return await self.client.get(f'/api/menus/user/{user_id}')
    
    async def get_user_menus_by_role(self, role_id):
        """获取角色菜单"""
        return await self.client.get(f'/api/menus/role/{role_id}')
