package org.example.Impl.Sql.factory;

import org.example.Impl.Sql.dmImpl.DmAllInOneSqlProvider;
import org.example.Impl.Sql.kingbaseImpl.KingbaseAllInOneSqlProvider;
import org.example.Impl.Sql.provider.AllInOneSqlProvider;
import org.example.ModuleApi.ModuleAjaxApi.mapper.CRMapper;
import org.example.ModuleApi.ModuleAjaxApi.mapper.DMCrmMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

@Service
public class AllInOneSqlFactory {
    @Autowired
    CRMapper crMapper;
    @Autowired
    DMCrmMapper dmCrmMapper;
    @Autowired
    JdbcTemplate jdbcTemplate;

    public  AllInOneSqlProvider createProvider(String databaseType) {
        if ("kingbase".equals(databaseType)) {
            return new KingbaseAllInOneSqlProvider(crMapper,jdbcTemplate); // 实现统一接口的人大金仓实例
        } else if ("dm".equals(databaseType)) {
            return new DmAllInOneSqlProvider(dmCrmMapper,jdbcTemplate); // 实现统一接口的达梦实例
        } else {
            throw new IllegalArgumentException("不支持的数据库类型：" + databaseType);
        }
    }
}
