// import request from '@/utils/request';
import { useHttp } from '@crami/http';
import { commonApi } from '@/api/commonApi/index';

interface uploadFile {
  eid: string;
  filePath: string;
  fileShowName: string;
  fileDescription: string;
  versionCode: string;
  metaInfo: string;
}

interface uploadFinished {
  eid: string;
  storageId: string;
  bucketCode: string;
  objectCode: string;
  fileId: string;
  templateUrl: string;
  fileShowName: string;
  versionCode: string;
}

interface downloadUrl {
  fileId: string;
}

export interface MetaData {
  type: string;
  productLine: string;
  name: string;
  mode: string;
}

export async function getByProjectAndType(params: MetaData) {
  return await useHttp({
    url: commonApi().studioCache.getMetaInfo.url,
    method: commonApi().studioCache.getMetaInfo.method,
    params,
  });
}

export async function uploadFile(params: uploadFile) {
  return await useHttp({
    url: '/api/file/applicationFile/template/uploadUrl',
    method: 'post',
    params,
  });
}

export async function uploadFinished(params: uploadFinished) {
  return await useHttp({
    url: '/api/file/applicationFile/template/uploadFinished',
    method: 'put',
    params,
  });
}

export async function downloadUrl(fileId: string) {
  return await useHttp({
    url: `/api/file/applicationFile/template/downloadUrl/${fileId}`,
    method: 'get',
  });
}

export async function uploadMessage(eid: string) {
  return await useHttp({
    url: `/api/file/applicationFile/getOneFile/${eid}`,
    method: 'get',
  });
}


