package com.cm.common.plugin.service.database;

import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.common.result.SuccessResult;

import java.util.Map;

/**
 * @ClassName: IDatabaseService
 * @Description: 数据库
 * @Author: WangGeng
 * @Date: 2019-07-14 18:20
 * @Version: 1.0
 **/
public interface IDatabaseService {

    /**
     * 连接
     */
    String DATABASE_CONNECTION = "DATABASE_CONNECTION";
    /**
     * 数据库名称
     */
    String DATABASE_NAME = "DATABASE_NAME";
    /**
     * mysql数据库
     */
    String DATABASE_MYSQL = "mysql";

    /**
     * mysql数据库驱动
     */
    String DATABASE_MYSQL_DRIVER_CLASS = "com.mysql.jdbc.Driver";


    /**
     * 保存数据库连接
     *
     * @param params
     * @return
     * @throws SaveException
     * @throws RemoveException
     * @throws SearchException
     */
    SuccessResult saveConnection(Map<String, Object> params) throws SaveException, RemoveException, SearchException;

    /**
     * 打开数据库连接
     *
     * @param params
     * @throws SaveException
     * @throws RemoveException
     * @throws SearchException
     */
    void openConnection(Map<String, Object> params) throws SaveException, RemoveException, SearchException;

    /**
     * 删除数据库链接
     *
     * @param params
     * @return
     * @throws RemoveException
     * @throws SearchException
     */
    SuccessResult removeConnection(Map<String, Object> params) throws RemoveException, SearchException;

}
