import { MenuBO, MenuTreeVO } from '@/api/interface/system/menu'
import http from '@/axios'
class MenuApi {
  static getMenuList = (): Promise<ResultData<any>> => {
    return http.get<Menu.MenuOptions[]>({ url: '/system/menu/getRouters' })
  }

  /**
   * @name 查询树结构
   * @returns returns
   */
  static tree = (): Promise<ResultData<any>> => {
    return http.get<MenuTreeVO>({ url: '/system/menu/tree' })
  }

  /**
   * @name 查询列表
   * @returns returns
   */
  static list = (params: MenuBO): Promise<ResultData<any>> => {
    return http.get<Menu.MenuOptions[]>({ url: '/system/menu/list', params })
  }

  /**
   * @name 添加
   * @returns returns
   */
  static add = (data: MenuBO): Promise<ResultData<any>> => {
    return http.post({ url: '/system/menu/add', data })
  }
  /**
   * @name 更新
   * @returns returns
   */
  static edit = (data: MenuBO): Promise<ResultData<any>> => {
    return http.put({ url: '/system/menu/edit', data })
  }

  /**
   * @name 删除
   * @returns returns
   */
  static delete = (data: string[]): Promise<ResultData<any>> => {
    return http.delete({ url: '/system/menu/delete', data })
  }
}
export default MenuApi
