package com.cm.common.plugin.dao.dynamic;

import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.common.plugin.pojo.dtos.database.table.TableColumnDTO;
import com.cm.common.plugin.pojo.dtos.database.table.TableDTO;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: IDynamicTableDao
 * @Description: 动态表格
 * @Author: WangGeng
 * @Date: 2019/12/3 11:01 下午
 * @Version: 1.0
 **/
@Repository
public interface IDynamicTableDao {
    /**
     * 建表
     *
     * @param createTableSQL
     * @throws UpdateException
     */
    void createTable(String createTableSQL) throws UpdateException;

    /**
     * 加列
     *
     * @param toString
     * @throws UpdateException
     */
    void saveTableColumn(String toString) throws UpdateException;

    /**
     * 修改列属性
     *
     * @param toString
     * @throws UpdateException
     */
    void updateTableColumnType(String toString) throws UpdateException;

    /**
     * 删列
     *
     * @param toString
     * @throws RemoveException
     */
    void deleteTableColumnType(String toString) throws RemoveException;

    /**
     * 通过表名获取表
     *
     * @param tableName
     * @return
     * @throws SearchException
     */
    TableDTO getTableByTableName(String tableName) throws SearchException;

    /**
     * 表详情
     *
     * @param tableName
     * @return
     * @throws SearchException
     */
    List<TableColumnDTO> listTableColumns(String tableName) throws SearchException;

}
