import { get, post, upload } from '@/api/request';

const env = import.meta.env;
const PREFIX = env.VITE_API_PREFIX_DATA;

/**
 * 添加新的仿真参数库分类的参数对象
 * @param params parameterLibraryId 参数库id parameterLibraryCategoryId 参数分类id parameterLibraryCategoryObjectName 参数对象名 fileName 文件名 file
 * @returns
 */
export const addLibraryCategoryObjectApi = (params: any) => {
  return upload(`${PREFIX}simulationParameterLibrary/addLibraryCategoryObject`, params);
};

/**
 * 删除仿真参数库数据
 * @param params type 1:仿真参数库 2:仿真参数库分类 3:仿真参数库分类参数对象 id 仿真参数库id/仿真参数库分类id/仿真参数库分类参数对象id
 * @returns
 */
export const deleteSimulationParameterApi = (params: any) => {
  return post(`${PREFIX}simulationParameterLibrary/deleteSimulationParameter`, params);
};

/**
 * 获取仿真参数库分类参数对象
 * @param params ObjectId 参数对象id
 * @returns
 */
export const getSimulationParameterLibraryCategoryObjectApi = (params: any) => {
  return get(
    `${PREFIX}simulationParameterLibrary/getSimulationParameterLibraryCategoryObject`,
    params
  );
};

/**
 * 添加新的仿真参数库分类
 * @param params parameterLibraryId 仿真参数库ID parameterLibraryCategoryName 仿真参数库分类名
 * @returns
 */
export const addLibraryCategoryApi = (params: any) => {
  return get(`${PREFIX}simulationParameterLibrary/addLibraryCategory`, params);
};

/**
 * 添加新的仿真参数库
 * @param params parameterLibraryName 仿真参数库名
 * @returns
 */
export const addLibraryApi = (params: any) => {
  return get(`${PREFIX}simulationParameterLibrary/addLibrary`, params);
};

/**
 * 获取仿真参数库展示树
 * @param params type 1：模型库/2：模型库分类/3：参数对象 id 传对应模型库id/模型库分类id/参数对象id，不传查所有的模型库
 * @returns
 */
export const getSimulationParameterTreeApi = (params: any) => {
  return get(`${PREFIX}simulationParameterLibrary/getSimulationParameterTree`, params);
};

// 编辑参数库
export const editSimulationParameterApi = (params: any) => {
  return post(`${PREFIX}simulationParameterLibrary/editSimulationParameter`, params);
};

// 编辑参数对象
export const updateSimulationParameterValuesApi = (params: any) => {
  return post(`${PREFIX}simulationParameterLibrary/updateSimulationParameterValues`, params);
};
