import http from '@/api'

// 获取路由
export const getRoutersApi = () => {
  return http.get<Menu.MenuOptions[]>('/system/menu/getRouters', {}, { loading: false })
}

/**
 * @name 查询菜单列表
 * @param query 参数
 * @returns 返回列表
 */
export const listMenuApi = (query?: any) => {
  return http.get<any>('/system/menu/list', query, { loading: true })
}

/**
 * @name 查询菜单详细
 * @param menuId menuId
 * @returns returns
 */
export const getMenuApi = (menuId: any) => {
  return http.get<any>(`/system/menu/${menuId}`)
}

/**
 * @name 新增菜单
 * @param data data
 * @returns returns
 */
export const addMenuApi = (data: any) => {
  return http.post<any>('/system/menu', data, { loading: false })
}

/**
 * @name 修改菜单
 * @param data data
 * @returns returns
 */
export const updateMenuApi = (data: any) => {
  return http.put<any>('/system/menu', data, { loading: false })
}

/**
 * @name 删除菜单
 * @param menuId menuId
 * @returns returns
 */
export const delMenuApi = (menuId: any) => {
  return http.delete<any>(`/system/menu/${menuId}`)
}

/**
 * @name 下载模板
 * @returns returns
 */
export const importTemplateApi = () => {
  return http.downloadPost('/system/menu/importTemplate', {})
}

/**
 * @name 导入数据
 * @returns returns
 */
export const importDataApi = (data: any) => {
  return http.post('/system/menu/importData', data)
}

/**
 * @name 导出数据
 * @returns returns
 */
export const exportApi = (data: any) => {
  return http.downloadPost('/system/menu/export', data)
}

/**
 * @name 查询菜单下拉树结构
 * @returns returns
 */
export const treeSelectApi = () => {
  return http.get<any>(`/system/menu/treeselect`)
}

/**
 * @name 根据角色ID查询菜单下拉树结构
 * @param roleId roleId
 * @returns returns
 */
export const roleMenuTreeselectApi = (roleId: any) => {
  return http.get<any>(`/system/menu/roleMenuTreeselect/${roleId}`)
}
