package net.tccn.base.dbq.jdbc.api;

import net.tccn.base.IService;

import java.util.Date;
import java.util.List;

/**
 * Created by liangxianyou at 2019/3/12 14:07.
 */
public interface DbSource extends IService {

    void setDbAccount(DbAccount dbAccount);
    void setCatalog(String catelog);

    <T> List<T> queryList(String sql, Class<T> type);

    <T> T find(String sql, Class<T> type);

    <T> T findColumn(String sql, Class<T> type);

    //待实现
    default <T> void save(String tableName, T t) {}

    //待实现
    default <T> void update(String tableName, T t) {}

    default int findInt(String sql) {
        return findColumn(sql, int.class);
    }
    default long findLong(String sql) {
        return findColumn(sql, long.class);
    }
    default double findDouble(String sql) {
        return findColumn(sql, double.class);
    }
    default Date findDate(String sql) {
        return findColumn(sql, Date.class);
    }

    void createTable(String sql);
    void dropTable(String tableName);

    boolean exetute(String sql);

    int exetuteUpdate(String sql);
}
