import { defHttp } from '@/utils/http/axios';
import {AccountListGetResultModel,AccountListItem,AccountParams } from './model/index';

enum Api {
  GETDATABASETABLEPAGE_LIST = '/api/SysDatabaseLink/LoadDataBaseInfo', //获取数据库
  ADDDATABASETABLE = '/api/SysDatabaseLink/AddBaseLinkForm', //新增数据库
  EDITDATABASETABLE = '/api/SysDatabaseLink/UpdateBaseLink?keyValue=', //编辑数据库
  DELETEDATABASETABLE = '/api/SysDatabaseLink/DeleteBaseLink?id=', //删除数据库
  GETDATABASEDETAIL = '/api/SysDatabaseLink/GetDataBaseForm', //编辑时获取详情数据
  TEStCONNECTTION = '/api/SysDatabaseLink/TestConnection', //测试连接串是否正确
}


/**
 * @description: Get sample options value
 */

 
export const getDataBasePageList = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.GETDATABASETABLEPAGE_LIST, params });  
 
export const getDataBaseDetail = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.GETDATABASEDETAIL, params });   
  
export const testDataBaseConnection = (params: AccountParams) =>
  defHttp.get<AccountListGetResultModel>({ url: Api.TEStCONNECTTION, params });    

 
export const addDataBaseInfo = (params: AccountListItem) =>
  defHttp.post<AccountListGetResultModel>({ url: Api.ADDDATABASETABLE, params }); 

export const editDataBaseInfo = (params: AccountListItem) =>
  defHttp.post<AccountListGetResultModel>({ url: Api.EDITDATABASETABLE+params.databaseLinkId,params }); 

export const delDataBaseInfo = (params: AccountListItem) =>
  defHttp.post<AccountListGetResultModel>({ url: Api.DELETEDATABASETABLE+params.id, params }); 

 


 