package com.nantian.cloud.query.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 * @author suixin
 * @date 2022/2/19
 */
public class JdbcTemplateDataSourceConfig {
    /**
     * @Description: JdbcTemplate主数据源ds1数据源
     * @Author: suixin
     * @Date: 2022/2/19
     * @Return: org.springframework.jdbc.core.JdbcTemplate
     * @Param: [dataSource]
     */
    @Primary
    @Bean(name = "ds1JdbcTemplate")
    public JdbcTemplate ds1JdbcTemplate(@Qualifier("dataSource1") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    /**
     * @Description: JdbcTemplate第二个ds2数据源
     * @Author: suixin
     * @Date: 2022/2/19
     * @Return: org.springframework.jdbc.core.JdbcTemplate
     * @Param: [dataSource]
     */
    @Bean(name = "ds2JdbcTemplate")
    public JdbcTemplate ds2JdbcTemplate(@Qualifier("dataSource2") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    /**
     * @Description: JdbcTemplate第三个ds3数据源
     * @Author: suixin
     * @Date: 2022/2/19
     * @Return: org.springframework.jdbc.core.JdbcTemplate
     * @Param: [dataSource]
     */
    @Bean(name = "ds3JdbcTemplate")
    public JdbcTemplate ds3JdbcTemplate(@Qualifier("dataSource3") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}
