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

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

export interface treeData {
  type: string;
  productLine: string;
  // name: string;
  loadAll: boolean;
  objectType: string;
  treeViewName: string;
  userDept: string;
  userGroup: string;
  userId: string;
}

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

export async function storageListAPI() {
  return await useHttp({
    method: 'get',
    url: '/api/file/storage/getVolumeAcquireDuplicationStrategy',
  });
}

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

export interface saveData {
  eid: string;
  mainStorageName: string;
  mainStorageId: string; //主存储集群标识
  duplicationParam: string; //调度参数
  duplicationMode: string; //启动方式
  inUse: string; //启用中
  expiresMode: string; //过期策略
  blockMode: string; //阻塞模式
  expiresTimeLong: string; //任务超时时间
  mayFailTime: string; //默认重试次数
  // eslint-disable-next-line @typescript-eslint/ban-types
  sequenceList: {};
}

export async function saveDataAPI(params: saveData) {
  return await useHttp({
    url: '/api/file/duplicationStrategy/saveDuplicationStrategy',
    method: 'post',
    params,
  });
}

export async function showListAPI(storageId) {
  return await useHttp({
    url: `/api/file/orgStorage/${storageId}`,
    method: 'get',
  });
}

export interface saveList {
  storageId: string;
  organizationIds: string[];
}

export async function saveDataListAPI(params: saveList) {
  return await useHttp({
    url: '/api/file/orgStorage/saveOrgStorage',
    method: 'post',
    params,
  });
}

export async function getDuplicationAPI() {
  return await useHttp({
    url: '/api/file/duplicationStrategy/getDuplicationStrategy',
    method: 'get',
  });
}

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