import { defHttp } from '/@/utils/http/axios';
import { PageParams, ListGetResultModel, UpdateItem, DeleteItem } from './model';
import { Result, UploadFileParams } from '/#/axios';

enum Api {
  selectAll = '/zfb-api/zfb/rotation/selectAll',
  recommend = '/zfb-api/zfb/recommend/selectByType',
  update = '/zfb-api/zfb/rotation/update',
  save = '/zfb-api/zfb/rotation/save',
  delete = '/zfb-api/zfb/rotation/delete',
  uploadFile = '/zfb-api/zfb/house/upload',
  padssave = '/zfb-api/zfb/recommend/save',
  padsupdate = '/zfb-api/zfb/recommend/update',
  padsdelete = '/zfb-api/zfb/recommend/delete',
}

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

export const ListApi = (params: PageParams) =>
  defHttp.post<ListGetResultModel>({
    url: Api.selectAll,
    params,

    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const RecommendDeleteApi = (params: DeleteItem) =>
  defHttp.post<Result>({
    url: Api.padsdelete,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const RecommendListApi = (params: DeleteItem) =>
  defHttp.post<ListGetResultModel>({
    url: Api.recommend,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const itemUpdateApi = (params: UpdateItem) =>
  defHttp.post<ListGetResultModel>({
    url: Api.update,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const itemSaveApi = (params: UpdateItem) =>
  defHttp.post<ListGetResultModel>({
    url: Api.save,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const itemDeletelApi = (params: DeleteItem) =>
  defHttp.post<ListGetResultModel>({
    url: Api.delete,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export function uploadApi(
  params: UploadFileParams,
  // onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<Result>(
    {
      url: Api.uploadFile,
      // onUploadProgress,
    },
    params,
  );
}

export const padsUpdateApi = (params: UpdateItem) =>
  defHttp.post<ListGetResultModel>({
    url: Api.padsupdate,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const padsSaveApi = (params: UpdateItem) =>
  defHttp.post<ListGetResultModel>({
    url: Api.padssave,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
