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

import com.cm.common.exception.RemoveException;
import com.cm.common.exception.SaveException;
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 com.cm.common.plugin.pojo.vos.database.table.TableColumnVO;
import com.cm.common.plugin.pojo.vos.database.table.TableOldColumnVO;
import com.cm.common.plugin.pojo.vos.database.table.TableVO;
import com.cm.common.result.SuccessResult;

import java.util.List;
import java.util.Map;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: TableController
 * @Description: 数据库表处理
 * @Author: WangGeng
 * @Date: 2019-11-14 10:43
 * @Version: 1.0
 **/
public interface ITableService {

    /**
     * 新增表
     *
     * @param tableVO
     * @return
     * @throws SearchException
     * @throws SaveException
     */
    SuccessResult saveTable(TableVO tableVO) throws SearchException, SaveException;

    /**
     * 新增表
     *
     * @param tableVO
     * @throws SaveException
     */
    void createTable(TableVO tableVO) throws SaveException;

    /**
     * 删表
     *
     * @param tableName
     * @return
     * @throws RemoveException
     */
    SuccessResult removeTable(String tableName) throws RemoveException;

    /**
     * 加列
     *
     * @param tableName
     * @param tableColumnVO
     * @return
     * @throws SaveException
     */
    SuccessResult saveTableColumn(String tableName, TableColumnVO tableColumnVO) throws SaveException;

    /**
     * 删列
     *
     * @param tableName
     * @param columnName
     * @return
     * @throws RemoveException
     */
    SuccessResult removeTableColumn(String tableName, String columnName) throws RemoveException;

    /**
     * 修改列
     *
     * @param tableName
     * @param tableOldColumnVO
     * @return
     * @throws UpdateException
     */
    SuccessResult updateTableColumn(String tableName, TableOldColumnVO tableOldColumnVO) throws UpdateException;

    /**
     * 修改表列类型
     *
     * @param tableName
     * @param tableColumnVO
     * @return
     * @throws UpdateException
     */
    SuccessResult updateTableColumnType(String tableName, TableColumnVO tableColumnVO) throws UpdateException;

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

    /**
     * 表列表
     *
     * @param params
     * @return
     * @throws SearchException
     */
    List<TableDTO> listTables(Map<String, Object> params) throws SearchException;

    /**
     * 表详情
     *
     * @param params
     * @return
     * @throws SearchException
     */
    List<TableColumnDTO> listTableColumns(Map<String, Object> params) throws SearchException;

}
