import { responsesmodel, LoadDataBaseInfoModel, AddOrUpdateFormModel } from './model/dbsourceModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  // 分页获取列表数据
  Get_LoadDataBaseInfo = '/api/DataSource/LoadDataBaseInfo',
  // 获取数据源列名
  Get_GetDataColName = '/api/DataSource/GetDataColName',
  // 新增或者修改数据源
  Post_AddOrUpdateForm = '/api/DataSource/AddOrUpdateForm',
  // 删除数据源
  Post_DeleteEntity = '/api/DataSource/DeleteEntity',
}

// 分页获取列表数据
export function fun_LoadDataBaseInfo(params) {
  return defHttp.get<LoadDataBaseInfoModel>({
    url: Api.Get_LoadDataBaseInfo,
    params,
  });
}

// 获取数据源列名
export function fun_GetDataColName(params) {
  return defHttp.get<responsesmodel>({
    url: Api.Get_GetDataColName + '?code=' + params.code,
  });
}

// 新增数据源
export function fun_AddForm(params: AddOrUpdateFormModel) {
  return defHttp.post<responsesmodel>({
    url: Api.Post_AddOrUpdateForm,
    params,
  });
}

// 修改数据源
export function fun_UpdateForm(params: AddOrUpdateFormModel) {
  return defHttp.post<responsesmodel>({
    url: Api.Post_AddOrUpdateForm + '?id=' + params.id,
    params,
  });
}

// 删除数据源
export function fun_DeleteEntity(params) {
  return defHttp.post<responsesmodel>({
    url: Api.Post_DeleteEntity + '?keyValue=' + params.keyValue,
  });
}
