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

interface createFileVolume {
  appCode: string;
  volumeCode: string;
  volumeName: string;
  volumeDescription: string;
  storageCode: string;
}
interface editFileVolume {
  eid: string;
  appCode: string;
  volumeCode: string;
  volumeName: string;
  volumeDescription: string;
  storageCode: string;
}

interface editApplication {
  eid: string;
  appCode: string;
  appName: string;
  appDescription: string;
}

interface createApplication {
  appCode: string;
  appName: string;
  appDescription: string;
}

interface deleteFileVolume {
  EID: string;
}

interface fileList {
  eid: string;
  appCode: string;
  volumeCode: string;
  filePath: string;
  fileShowName: string;
  fileDescription: string;
  versionCode: string;
  metaInfo: string;
  expiresOn: string;
  isgeneralfile: string;
}

interface createExtensions {
  eid: string;
  extensionName: string; //插件名称
  extensionDescription: string; //插件描述
  extensionId: string; //插string;件标识
  serviceCode: string; //服务标识
  inUse: string; //是否启用
  fileTypes: string; //文件类型
}

interface createStorage {
  eid: string;
  storageName: string; //存储名称
  storageDescription: string; //存储描述
  states: string; //状态
  accAddress: string; //地址
  accUser: string; //用户
  accPwd: string; //密码
}

/* 
新建文件卷
*/

export async function createFileVolume(params: createFileVolume) {
  return await useHttp({
    method: 'post',
    url: '/api/file/fileVolume/createFileVolume',
    params,
  });
}
/* 
编辑文件卷
*/

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

/* 
删除文件卷
*/

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

/* 
新建文件卷获取主存储集群数据
*/

export async function duplicationStrategy() {
  return await useHttp({
    method: 'get',
    url: '/api/file/storage/getOtherStrategy',
  });
}
/* 
编辑文件卷回显主集群数据
*/

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

//删除历史版本

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

//替换当前版本

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

// 新增应用仓库

export async function createApplication(params: createApplication) {
  return await useHttp({
    method: 'post',
    url: '/api/file/applications/createApplication',
    params,
  });
}

// 编辑应用仓库

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

// 删除应用仓库
export async function deleteApplication(eid: string) {
  return await useHttp({
    method: 'delete',
    url: `/api/file/applications/${eid}`,
  });
}

// 新建文件信息保存

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

// 编辑文件信息保存

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

// 删除文件信息列表

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

// 存储结构禁用

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

// 存储结构启用
export async function changeStateEnable(eid: string) {
  return await useHttp({
    method: 'get',
    url: `/api/file/storage/changeStateEnable/${eid}`,
  });
}

// 传输策略启用
export async function transferEnable(eid: string) {
  return await useHttp({
    method: 'get',
    url: `/api/file/transfer/changeStateEnable/${eid}`,
  });
}
// 传输策略禁用
export async function transferDisable(eid: string) {
  return await useHttp({
    method: 'get',
    url: `/api/file/transfer/changeStateDisable/${eid}`,
  });
}

// 插件管理新增保存
export async function createExtensions(params: createExtensions) {
  return await useHttp({
    method: 'post',
    url: '/api/file/transfer/createExtensions',
    params,
  });
}
// 插件管理编辑保存

export async function editExtensions(params: createExtensions) {
  return await useHttp({
    method: 'put',
    url: '/api/file/transfer/editExtensions',
    params,
  });
}

// 存储结构新增保存

export async function createStorage(params: createStorage) {
  return await useHttp({
    method: 'post',
    url: '/api/file/storage/createStorage',
    params,
  });
}
// 存储结构编辑保存
export async function editStorage(params: createStorage) {
  return await useHttp({
    method: 'put',
    url: '/api/file/storage/editStorage',
    params,
  });
}

// 存储结构管理删除
export async function deleteStorage(eid: string) {
  return await useHttp({
    method: 'delete',
    url: `/api/file/storage/Storage/${eid}`,
  });
}
