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

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.TableVO;

import java.util.List;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: IDynamicTableService
 * @Description: 动态表格
 * @Author: WangGeng
 * @Date: 2019/12/3 10:54 下午
 * @Version: 1.0
 **/
public interface IDynamicTableService {

    /**
     * 动态表前缀
     */
    String DYNAMIC_TABLE_PREFIX = "dynamic_";

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

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

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

    /**
     * 删列
     *
     * @param tableName
     * @param deleteDynamicFormField
     * @throws RemoveException
     */
    void deleteTableColumnType(String tableName, String deleteDynamicFormField) 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;

}
