import { http } from "@/utils/http";

type Result = {
  code: number;
  message: string;
  data?: any;
};

type ResultTable = {
  code: number;
  message: string;
  data?: {
    list: Array<any>;
    total: number;
    pageSize: number;
    currentPage: number;
  };
};

export const getRoleList = (data: {
  page?: number;
  pageSize?: number;
  name?: string;
  code?: string;
}) => {
  return http.request<ResultTable>("post", "/role", { data });
};

export const getAllRoles = () => {
  return http.request<Result>("get", "/role/list-all-role");
};

export const addRole = (data: any) => {
  return http.request<Result>("post", "/role/add", { data });
};

export const updateRole = (data: any) => {
  return http.request<Result>("post", "/role/update", { data });
};

export const deleteRole = (id: number) => {
  return http.request<Result>("delete", `/role/${id}`);
};
