import { defHttp } from '/@/utils/http/axios';
import {
  IDataManagerModel,
  IEnableOrDisableModel,
  TDataManagerModelQuery,
} from './model/dataManagerModel';

enum DataManagerApi {
  DATA_MANAGER_CONVERT_ADD_OR_EDIT = '/convert/config',
  DATA_MANAGER_CONVERT_DELETE = '/convert/config',
  DATA_MANAGER_CONVERT_POST_CHECK_NAME = '/convert/check/config',
  DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED = '/convert/update/config',
  DATA_MANAGER_CONVERT_GET = '/convert',
}

// 转换配置分页查询
export const getConvertApi = (params: TDataManagerModelQuery) => {
  params.nodeType = 1;
  return defHttp.get<TDataManagerModelQuery>({
    url: DataManagerApi.DATA_MANAGER_CONVERT_GET,
    params,
  });
};

// 添加或修改转换配置
export const postAddConvertApi = (params: IDataManagerModel) => {
  return defHttp.post<IDataManagerModel>({
    url: DataManagerApi.DATA_MANAGER_CONVERT_ADD_OR_EDIT,
    params,
  });
};

//删除转换配置
export const deleteConvertApi = (ids: string[]) => {
  return defHttp.delete({
    url: DataManagerApi.DATA_MANAGER_CONVERT_DELETE,
    data: {
      ids: ids,
    },
  });
};

// 查询配置名称是否存在
export const isExistDataManagerNameApi = (check: {}) => {
  return defHttp.post({
    url: DataManagerApi.DATA_MANAGER_CONVERT_POST_CHECK_NAME,
    data: check,
  });
};

// 启用或者禁用配置
export const isEnableOrDisableApi = (params: IEnableOrDisableModel) => {
  params.nodeType = 1;
  return defHttp.post<IEnableOrDisableModel>({
    url: DataManagerApi.DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED,
    params,
  });
};
