import { defHttp } from '/@/utils/http/axios';
import { PageParams, RentListGetResultModel } from './model';
import { Result } from '/#/axios';

enum Api {
  pageList = '/basic-api/goods/list',
  ref = '/basic-api/specification/list',
  unSale = '/basic-api/goods/unSale',
  enSale = '/basic-api/goods/enSale',
  delete = '/basic-api/goods/delete',
  info = '/basic-api/goods/info/',
  update = '/basic-api/goods/update',
  save = '/basic-api/goods/save',
  queryAll = '/basic-api/specification/queryAll',
}

/**
 * @description: Get sample list value
 */

export const queryAll = (params?: PageParams) =>
  defHttp.post<RentListGetResultModel>({
    url: Api.queryAll,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const ListApi = (params: PageParams) =>
  defHttp.post<RentListGetResultModel>({
    url: Api.pageList,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const InfoApi = (params: string) =>
  defHttp.post<any>({
    url: Api.info + params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const UnSaleApi = (params: string[]) =>
  defHttp.post<Result>({
    url: Api.unSale,
    data: params.join(','),
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const SaveSaleApi = (params: any) =>
  defHttp.post<Result>({
    url: Api.save,
    data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const UpdateSaleApi = (params: any) =>
  defHttp.post<Result>({
    url: Api.update,
    data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const EnSaleApi = (params: string[]) =>
  defHttp.post<Result>({
    url: Api.enSale,
    data: params.join(','),
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const DeleteApi = (params: string[]) =>
  defHttp.post<Result>({
    url: Api.delete,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
