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

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

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

/**
 * 查询菜单下拉框
 * @param data
 */
export async function getMenuIdsByRoleIds(data: any) {
  return requestClient.get<any>(`${prefix}get-menu-ids-by-role-ids`, {
    params: {
      role_id: data.id,
    },
  });
}

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

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

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

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