import { CACHE_SESSION_CRYPTO_API } from '@/constants/cache-keys-constants';
import { sessionGet } from '@/utils/cache-session-utils';
import { request } from '@/plugins/http-fetch';

/**
 * 获取下拉框数据
 * @returns object
 */
export function getBakFile() {
  return request({
    url: '/lm/table/list',
    method: 'GET',
  });
}

/**
 * 获取对应类型的文件列表
 * @param query 查询参数
 * @returns object
 */
export function getBakFileList(query: Record<string, any>) {
  return request({
    url: '/lm/file/list',
    method: 'GET',
    params: query,
  });
}

/**
 * 下载远端文件
 * @param query 查询参数
 * @returns object
 */
export function downFile(query: Record<string, any>) {
  return request({
    url: `/lm/file/${query.fileName}`,
    method: 'GET',
    params: query,
    responseType: 'blob',
    timeout: 180_000,
  });
}

/**
 * 删除远端获取文件
 * @param query 查询参数
 * @returns object
 */
export function delFile(query: Record<string, any>) {
  return request({
    url: `/lm/file/${query.fileName}`,
    method: 'DELETE',
    params: query,
  });
}
