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 syncDevices = () => {
  return http.request<Result>("post", "/sync/devices");
};

export const syncProducts = () => {
  return http.request<Result>("post", "/sync/products");
};

export const getSyncRecords = (params: {
  syncType?: string;
  status?: number;
  page?: number;
  pageSize?: number;
}) => {
  return http.request<ResultTable>("get", "/sync/records", { params });
};

export const getSyncLogs = (recordId: number, params: {
  page?: number;
  pageSize?: number;
}) => {
  return http.request<ResultTable>("get", `/sync/logs/${recordId}`, { params });
};

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