package com.purui.prims.headless.core.adaptor.db;

import com.purui.prims.headless.api.pojo.enums.EngineType;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据库适配器，支持doris/mysql
 * @author charlie
 * @date   2024/6/25
 */
public class DbAdaptorFactory {

    private static Map<String, DbAdaptor> dbAdaptorMap;

    static {
        dbAdaptorMap = new HashMap<>();
        dbAdaptorMap.put(EngineType.CLICKHOUSE.getName(), new ClickHouseAdaptor());
        dbAdaptorMap.put(EngineType.MYSQL.getName(), new MysqlAdaptor());
        dbAdaptorMap.put(EngineType.H2.getName(), new H2Adaptor());
        dbAdaptorMap.put(EngineType.POSTGRESQL.getName(), new PostgresqlAdaptor());
        dbAdaptorMap.put(EngineType.DORIS.getName(), new DorisAdaptor());
        dbAdaptorMap.put(EngineType.OTHER.getName(), new DefaultDbAdaptor());
    }

    public static DbAdaptor getEngineAdaptor(String engineType) {
        return dbAdaptorMap.get(engineType);
    }

}
