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 getAdminList = (data: {
  page?: number;
  pageSize?: number;
  username?: string;
  phone?: string;
  roleIds?: string;
  status?: number;
}) => {
  return http.request<ResultTable>("post", "/user", { data });
};

export const getAdminById = (id: number) => {
  return http.request<Result>("get", `/user/${id}`);
};

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

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

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

export const resetPassword = (data: { id: number; newPassword: string }) => {
  return http.request<Result>("post", "/user/reset-password", { data });
};

export const getAdminStatistics = () => {
  return http.request<Result>("get", "/user/statistics");
};
