import { requestClient } from '#/api/request';

const prefix = 'menu/';

/**
 * 分页查询用户列表
 * @param data
 */
export async function getMenuList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

/**
 * 查询菜单下拉框
 * @param data
 */
export async function getMenuOption(data: any) {
  return requestClient.get<any>(`${prefix}option`, {
    params: {
      ...data,
      is_select: true,
    },
  });
}

/**
 * 查询菜单树形下拉框
 */
export async function getMenuTreeOption() {
  return requestClient.get<any>(`${prefix}tree-option`, {
    params: {
      is_select: true,
    },
  });
}

/**
 * 获取详情
 * @param id
 */
export async function getMenuInfo(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

/**
 * 新增角色
 * @param data
 */
export async function createMenu(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

/**
 * 编辑角色
 * @param data
 */
export async function updateMenu(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

/**
 * 删除角色
 * @param data
 */
export async function deleteMenu(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}
