import { defHttp } from '/@/utils/http/axios';
import {
  PageParams,
  RentListGetResultModel,
  SceneEditParam,
  SceneDownloadParam,
  GetDownloadProcessModel,
  SceneDownloadModel,
  patchcoldStoragedParam,
  collaborateParam,
  unCollaborateParam,
  collaborateDetailParam,
  GenOBJParam,
} from './model';
import { Result } from '/#/axios';

enum Api {
  pageList = '/service/manage_jp/scene/list',
  generateSceneEditToken = '/service/manage_jp/platform/generateSceneEditToken',
  downloadSceneData = '/service/manage_jp/user/scene/downloadScene',
  getDownloadProcess = '/service/manage_jp/user/scene/downloadProcess',
  addDownloadNum = '/service/manage_jp/scene/addDownloadNum',
  checkDownload = '/service/manage_jp/user/scene/checkDownload',
  delete = '/service/manage_jp/user/scene/delete',
  upgradeToV4 = '/service/manage_jp/scene/upgradeToV4',
  sceneCopy = 'service/manage_jp/scene/copyScene',
  coldStorage = 'service/manage_jp/storage/coldStorage',
  collaborate = 'service/manage_jp/contractor/collaborate',
  unCollaborate = 'service/manage_jp/contractor/unCollaborate',
  unCollaborateList = 'service/manage_jp/contractor/details',
  genOBJ = 'service/manage_jp/scene/generateObjFile',
  updateMapShow = 'service/manage_jp/scene/updateMapShow',
  checkE57 = 'service/manage_jp/user/scene/checkDownLoadE57',
  downloadE57 = 'service/manage_jp/user/scene/downSceneE57',
  getDownloadProcessE57 = 'service/manage_jp/user/scene/downloadProcessE57',
}

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

export const ListApi = (params: PageParams) =>
  defHttp.post<RentListGetResultModel>({
    url: Api.pageList,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const DeleteApi = (params: string) =>
  defHttp.post<Result>({
    url: Api.delete,
    params: {
      sceneNum: params,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const sceneCopy = (params: string) =>
  defHttp.post<Result>({
    url: Api.sceneCopy,
    params: {
      num: params,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const UpgradeToV4 = (params: string) =>
  defHttp.get<Result>({
    url: Api.upgradeToV4,
    params: {
      num: params,
    },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const downloadSceneDataAPi = (params: SceneDownloadParam) =>
  defHttp.get<SceneDownloadModel>({
    url: Api.downloadSceneData,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const getDownloadProcessApi = (params: SceneDownloadParam) =>
  defHttp.get<GetDownloadProcessModel>({
    url: Api.getDownloadProcess,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

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

export const addDownloadNumApi = (params: SceneDownloadParam) =>
  defHttp.get<Result>({
    url: Api.addDownloadNum,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const checkDownloadApi = (params: SceneDownloadParam) =>
  defHttp.get<SceneDownloadModel>({
    url: Api.checkDownload,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const patchcoldStorageApi = (params: patchcoldStoragedParam) =>
  defHttp.post<Result>({
    url: Api.coldStorage,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const addCollaborateApi = (params: collaborateParam) =>
  defHttp.post<Result>({
    url: Api.collaborate,
    params,

    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const unCollaborateApi = (params: unCollaborateParam) =>
  defHttp.post<Result>({
    url: Api.unCollaborate,
    params,

    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const getUnCollaborateDetailApi = (params: collaborateDetailParam) =>
  defHttp.post<Result>({
    url: Api.unCollaborateList,
    params,

    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const generateObjFileAPI = (params: GenOBJParam) =>
  defHttp.post<Result>({
    url: Api.genOBJ,
    params,

    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const updateMapShowApi = (params: { num: string; mapShow: number }) =>
  defHttp.post<Result>(
    {
      url: Api.updateMapShow,
      data: params,
      headers: {
        // @ts-ignore,
        ignoreCancelToken: true,
      },
    },
    {
      isTransformResponse: false,
    },
  );
export const checkDownloadE57Api = (params: Pick<SceneDownloadParam, 'num'>) =>
  defHttp.get<SceneDownloadModel>({
    url: Api.checkE57,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const downloadSceneDataE57APi = (params: SceneDownloadParam) =>
  defHttp.get<SceneDownloadModel>({
    url: Api.downloadE57,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const getE57DownloadProcessApi = (params: Pick<SceneDownloadParam, 'num'>) =>
  defHttp.get<GetDownloadProcessModel>({
    url: Api.getDownloadProcessE57,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
