import { get, post, PUBLISH_SERVICE, CITY_SERVICE } from '@/services/index';

/**
 * @数据库初始化
 */

/**
 * 数据库测试连接
 * @param {*} params
 * {
 * ip:'',
 * dbName:'',
 * userName:'',
 * password:'',
 * }
 */
// 测试数据库连接
export const connectionTest = params => post(`${PUBLISH_SERVICE}/DBManager/TestConnetions`, params);

// 获取数据库配置信息
export const getDataBaseConfigNew = params =>
  get(`${PUBLISH_SERVICE}/DBManager/GetDataBaseConfig`, params);

// 获取数据库连接记录

export const getConnRecordNew = params => get(`${PUBLISH_SERVICE}/DBManager/GetConnRecord`, params);

// 保存数据库连接
// export const saveConnection = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_SaveConnection`, params);
export const saveConnectionNew = params =>
  get(`${PUBLISH_SERVICE}/DBManager/SaveConnection`, params);

// 获取数据库列表

// export const getDataBaseList = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_GetDataBaseList`, params);
export const getDataBaseList = params =>
  get(`${PUBLISH_SERVICE}/DBManager/getDataBaseList`, params);

// 数据库初始化
// export const initDBv4 = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_InitDBv4`, params);
export const initDBv4new = params => get(`${PUBLISH_SERVICE}/DBManager/InitDB`, params);

// 更新描述
// export const updateConnDesc = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_UpdateConnDesc`, params);
export const updateConnDescNew = params =>
  get(`${PUBLISH_SERVICE}/DBManager/UpdateConnDesc`, params);

// 获取日志
// export const getInitDBLog = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_GetInitDBLog`, params);
export const getInitDBLogNew = params => get(`${PUBLISH_SERVICE}/DBManager/GetInitDBLog`, params);

// 删除初始化日志
export const deleteInitDBLog = params => get(`${CITY_SERVICE}/OMS.svc/S_DeleteInitDBLog`, params);
export const deleteInitDBLogNew = params =>
  get(`${PUBLISH_SERVICE}/DBManager/DeleteInitDBLog`, params);

// 设置数据库初始化类型
export const setTableSQLDirName = params =>
  get(`${PUBLISH_SERVICE}/DBManager/SetTableSQLDirName`, params);

// 删除数据库连接记录
// export const deleteConn = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_DeleteConn`, params);
export const deleteConnNew = params => get(`${PUBLISH_SERVICE}/DBManager/DeleteConnection`, params);

/**
 *
 * @解决方案管理
 */
// 切换解决方案配置
export const getSolutionList = params => get(`${CITY_SERVICE}/OMS.svc/W4_GetSolutionList`, params);

export const publishGetSolutionList = params =>
  get(`${PUBLISH_SERVICE}/PlatformCenter/GetSolutionList`, params);
// 切换解决方案
export const changeSolution = params => get(`${CITY_SERVICE}/OMS.svc/W4_ChangeSolution`, params);

/**
 *
 * @数据库标准化管理
 */
// 检查数据库表
// export const tableCheck = params =>
//   get(`${CITY_SERVICE}/OMS.svc/TableCheck`, params);
export const tableCheckNew = params => get(`${PUBLISH_SERVICE}/DBManager/GetTableCheck`, params);

// 获取数据库升级记录
// export const databaseStandardGetLog = params =>
//   get(`${CITY_SERVICE}/OMS.svc/DatabaseStandard_GetLog`, params);
export const databaseStandardGetLogNew = params =>
  get(`${PUBLISH_SERVICE}/DBManager/GetUpdateDBLog`, params);

// 更新
export const updateDateBase = params => get(`${PUBLISH_SERVICE}/DBManager/UpdateDataBase`, params);

// 更新
export const newUpdateDateBase = params =>
  post(`${PUBLISH_SERVICE}/DBManager/UpdateDataBase`, params);

/**
 * @数据库连接配置
 */

// export const deleteConnString = params =>
//   get(`${CITY_SERVICE}/OMS.svc/S_DeleteConnString`, params);
// SQL数据库连接
export const getSQLServerConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetSQLServerConnString`, params);
// 新增SQLServer数据库连接
export const addSQLServerConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_AddSQLServerConnString`, params);
// 删除SQL连接
export const editSQLServerConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_EditSQLServerConnString`, params);
// SQL数据库测试连接
export const getSQLServerConnectionTest = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetSQLServerConnectionTest`, params, {
    timeout: 30000,
  });
/**
 * @Oracle数据库
 */
// Oracle连接记录
export const getOracleConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetOracleConnString`, params);
// 新增Oracle连接
export const addOracleConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_AddOracleConnString`, params);
// 编辑Oracle连接
export const editOracleConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_EditOracleConnString`, params);
// 测试连接
export const getOracleConnectionTest = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetOracleConnectionTest`, params, {
    timeout: 30000,
  });

/**
 * @MongoDB连接
 */
// MongoDB连接记录
export const getMongoDBConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetMongoDBConnString`, params);
// 新增连接配置
export const addMongoDBConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_AddMongoDBConnString`, params);
// 编辑分享
export const editMongoDBConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_EditMongoDBConnString`, params);
// 测试连接
export const getMongoDBConnectionTest = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_MongoDBConnectionTest`, params, {
    timeout: 30000,
  });
/**
 * @MySQL连接
 */
// MySQL连接记录
export const getMySQLConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetMySQLConnString`, params);
// 新增配置连接
export const addMySQLConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_AddMySQLConnString`, params);
// 测试连接
export const getMySQLConnectionTest = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_GetMySQLConnectionTest`, params);
// 编辑
export const editMySQLConnString = params =>
  get(`${CITY_SERVICE}/OMS.svc/S_EditMySQLConnString`, params, {
    timeout: 300000,
  });

// 获取数据库链接字符串
export const GetConnString = params => get(`${PUBLISH_SERVICE}/DBManager/GetConnString`, params);
// 添加数据库链接字符串
export const AddConnString = params => get(`${PUBLISH_SERVICE}/DBManager/AddConnString`, params);
// 编辑数据库链接字符串
export const EditConnString = params => get(`${PUBLISH_SERVICE}/DBManager/EditConnString`, params);
// 删除数据库连接
export const DeleteConnString = params =>
  get(`${PUBLISH_SERVICE}/DBManager/DeleteConnString`, params);
export const GetConnTest = params => get(`${PUBLISH_SERVICE}/DBManager/GetConnectionTest`, params);

// 接口鉴权
export const AuthSetting = params => get(`${PUBLISH_SERVICE}/WebSite/AuthSetting`, params);
export const GetAuthSet = params => get(`${PUBLISH_SERVICE}/WebSite/GetAuthSet`, params);
export const AddUserAuthSetting = params =>
  get(`${PUBLISH_SERVICE}/WebSite/AddUserAuthSetting`, params);
export const GetUserAuthSet = params => get(`${PUBLISH_SERVICE}/WebSite/GetUserAuthSet`, params);

// 获取产品列表
export const GetProductList = params => post(`${PUBLISH_SERVICE}/DBManager/GetProductList`, params);
// 获取产品列表清单
export const GetProductListByLicense = params =>
  get(`${PUBLISH_SERVICE}/DBManager/GetProductListByLicense`, params);
// 判断License是否已使用
export const GetLicenseStatus = params =>
  get(`${PUBLISH_SERVICE}/DBManager/GetLicenseStatus`, params);
// 获取产品方案配置
export const GetDbProduct = params => post(`${PUBLISH_SERVICE}/DBManager/GetDbProduct`, params);
// 数据库初始化
export const InitAddDataBase = params =>
  post(`${PUBLISH_SERVICE}/DBManager/InitAddDataBase`, params);
// 二次初始化
export const InitEditDataBase = params =>
  post(`${PUBLISH_SERVICE}/DBManager/InitEditDataBase`, params);

// 保存主站配置
export const SaveMainServer = params => get(`${PUBLISH_SERVICE}/DBManager/SaveMainServer`, params);
// 获取主站配置
export const GetMainServer = params => get(`${PUBLISH_SERVICE}/DBManager/GetMainServer`, params);
// 删除主站配置
export const DeleteMainServer = params =>
  get(`${PUBLISH_SERVICE}/DBManager/DeleteMainServer`, params);
// 测试主站连接
export const GetUrlConnectionTest = params =>
  get(`${PUBLISH_SERVICE}/DBManager/GetUrlConnectionTest`, params);

export const CheckConnection = params =>
  post(`${PUBLISH_SERVICE}/DBManager/CheckConnection`, params);

export const CheckDatabaseIsExist = params =>
  post(`${PUBLISH_SERVICE}/DBManager/CheckDatabaseIsExist`, params);
// 给平台管理员赋值所有菜单权限
export const SetAdminMenuToRole = params =>
  get(`${PUBLISH_SERVICE}/UserCenter/SetAdminMenuToRole`, params);

export const NewInitAddDataBase = params =>
  post(`${PUBLISH_SERVICE}/DBManager/NewInitAddDataBase`, params);

// 获取追加产品
export const GetLicenseDifference = params =>
  post(`${PUBLISH_SERVICE}/DBManager/GetLicenseDifference`, params);
