package com.cm.common.plugin.dao.database.table;

import com.cm.common.plugin.pojo.dtos.database.table.TableColumnDTO;
import com.cm.common.plugin.pojo.dtos.database.table.TableDTO;
import com.cm.common.plugin.pojo.vos.database.table.TableColumnVO;
import com.cm.common.plugin.pojo.vos.database.table.TableOldColumnVO;

import java.sql.Connection;
import java.util.List;
import java.util.Map;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: ITableDao
 * @Description: //TODO
 * @Author: WangGeng
 * @Date: 2019/11/15 10:22
 * @Version: 1.0
 **/
public interface ITableDao {

    /**
     * 建表
     *
     * @param connection
     * @param databaseName
     * @param tableName
     * @param tableColumns
     */
    void saveTable(Connection connection, String databaseName, String tableName, List<TableColumnVO> tableColumns);

    /**
     * 删表
     *
     * @param connection
     * @param databaseName
     * @param tableName
     */
    void removeTable(Connection connection, String databaseName, String tableName);

    /**
     * 加列
     *
     * @param connection
     * @param databaseName
     * @param tableName
     * @param tableColumnVO
     */
    void saveTableColumn(Connection connection, String databaseName, String tableName, TableColumnVO tableColumnVO);

    /**
     * 删列
     *
     * @param connection
     * @param databaseName
     * @param tableName
     * @param columnName
     */
    void removeTableColumn(Connection connection, String databaseName, String tableName, String columnName);

    /**
     * 修改列
     *
     * @param connection
     * @param databaseName
     * @param tableName
     * @param tableOldColumnVO
     */
    void updateTableColumn(Connection connection, String databaseName, String tableName, TableOldColumnVO tableOldColumnVO);

    /**
     * 修改列属性
     *
     * @param connection
     * @param databaseName
     * @param tableName
     * @param tableColumnVO
     */
    void updateTableColumnType(Connection connection, String databaseName, String tableName, TableColumnVO tableColumnVO);

    /**
     * 表列列表
     *
     * @param connection
     * @param params
     * @return
     */
    List<TableColumnDTO> listTableColumns(Connection connection, Map<String, Object> params);

    /**
     * 表list
     *
     * @param connection
     * @param params
     * @return
     */
    List<TableDTO> listTables(Connection connection, Map<String, Object> params);

    /**
     * 通过表名获取表
     *
     * @param connection
     * @param databaseName
     * @param tableName
     * @return
     */
    TableDTO getTableByTableName(Connection connection, String databaseName, String tableName);

}
