package com.chy.borrow.config;

import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.IDbQuery;
import com.baomidou.mybatisplus.generator.config.querys.*;
import org.springframework.stereotype.Component;

/**
 * @version 1.0.0
 * @time 2021/8/3 13:23
 * @auther zk
 */
@Component
public class MyDataSourceConfig extends DataSourceConfig {

    @Override
    public IDbQuery getDbQuery() {
        switch(this.getDbType()) {
            case ORACLE:
                setDbQuery(new OracleQuery());
                break;
            case SQL_SERVER:
                setDbQuery(new SqlServerQuery());
                break;
            case POSTGRE_SQL:
                setDbQuery(new MyPostgreSqlQuery());
                break;
            case DB2:
                setDbQuery(new DB2Query());
                break;
            case MARIADB:
                setDbQuery(new MariadbQuery());
                break;
            case H2:
                setDbQuery(new H2Query());
                break;
            case SQLITE:
                setDbQuery(new SqliteQuery());
                break;
            case DM:
                // 重新指定自定义的DMQuery
                setDbQuery(new MyPostgreSqlQuery());
                break;
            case KINGBASE_ES:
                setDbQuery(new KingbaseESQuery());
                break;
            default:
                setDbQuery(new MySqlQuery());
        }
        return super.getDbQuery();
    }
}