import { GenericApi, DwLayout, FileApi } from "@/api/interface/index";
import { PORT1, PORT_DL } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 获取 通用接口：查询
 * @param params 请求参数
 * @param dwname 布局名称
 */
export const CommonDynamicSelect = (params: GenericApi.ReqCommonDynamicSelect, dwname?: string) => {
  return http.postCommonDynamic<GenericApi.ResCommonDynamicSelect>(PORT1 + `/CommonDynamicSelect`, params, dwname);
};

/**
 * @name 数据交互 通用调用uo
 */
export const CommonBill = (params: GenericApi.CommonClass) => {
  return http.postCommonBill<GenericApi.ResCommonBill>(PORT1 + `/CommonBill`, params);
};

/**
 * @name 获取 用户布局习惯
 */
export const GetDwLyoutApi = (params: DwLayout.ReqGetDwLayout) => {
  return http.post<DwLayout.ResGetDwLayout>(PORT1 + `/GetSysUserFileString`, params);
};

/**
 * @name 提交 用户布局习惯
 */
export const SetDwLyoutApi = (params: DwLayout.ReqSetDwLayout) => {
  return http.post(PORT1 + `/SetSysUserFileString`, params);
};

/**
 * @name 获取 文件分类
 */
export const GetFileClass = (params: FileApi.ReqFileClass) => {
  return http.post<FileApi.ResFileClass>(PORT1 + `/GetFileClass`, params);
};

/**
 * @name 获取 附件数据
 */
export const GetFjFile = (params: FileApi.ReqFileData) => {
  return http.post<FileApi.ResFileData>(PORT1 + `/GetFjFile`, params);
};

/**
 * @name 获取 md5转换附件
 */
export const GetCacheFile = (params: FileApi.ReqCacheFile) => {
  return http.post<FileApi.ResCacheFile>(PORT1 + `/GetCacheFile`, params);
};

/**
 * @name 下载 md5转换附件
 */
export const DownloadCacheFile = (params: FileApi.ReqCacheFile) => {
  return http.get<FileApi.ResCacheFile>(PORT_DL + `/GetCacheFile`, params, { responseType: "blob" });
};

/**
 * @name 上传 附件
 */
export const UploadFile = (params: FileApi.ReqUploadFile) => {
  return http.post(PORT1 + `/UploadL1File`, params);
};

export const GetFormulaCompute = (params: GenericApi.ReqFormulaCompute) => {
  return http.post<GenericApi.ResFormulaCompute>(PORT1 + `/GetFormulaCompute`, params);
};
