package cn.gov.customs.data.config;

import javax.sql.DataSource;

/*
 * @Description:
 * @Author: wq
 * @Date: 2025/12/3.
 */

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource("classpath:application.yml")
public class DataSourceConfig {
	//个人理解该注解主要用于表明优先性，当使用@Autowired时没有特殊标明的话，默认使用这个bean
    @Bean(name = "primaryDataSource")
    @Primary
    @Qualifier("primaryDataSource")
    @ConfigurationProperties(prefix = "spring.primary.datasource")
    public DataSource primaryDatasource() {
        return DataSourceBuilder.create().build();
    }

    //个人理解该注解主要用于表明优先性，当使用@Autowired时没有特殊标明的话，默认使用这个bean
    @Bean(name = "iedgDataSource")
    @Qualifier("iedgDataSource")
    @ConfigurationProperties(prefix = "spring.iedg.datasource")
    public DataSource iedgDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "appDataSource")
    @Qualifier("appDataSource")
    @ConfigurationProperties(prefix = "spring.app.datasource")
    public DataSource appDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "h2018appDataSource")
    @Qualifier("h2018appDataSource")
    @ConfigurationProperties(prefix = "spring.h2018app.datasource")
    public DataSource h2018appDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "h2018DataSource")
    @Qualifier("h2018DataSource")
    @ConfigurationProperties(prefix = "spring.h2018.datasource")
    public DataSource h2018DataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "rh2kDataSource")
    @Qualifier("rh2kDataSource")
    @ConfigurationProperties(prefix = "spring.rh2k.datasource")
    public DataSource rh2kDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "inspectDataSource")
    @Qualifier("inspectDataSource")
    @ConfigurationProperties(prefix = "spring.inspect.datasource")
    public DataSource inspectDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "zmqdDataSource")
    @Qualifier("zmqdDataSource")
    @ConfigurationProperties(prefix = "spring.zmqd.datasource")
    public DataSource zmqdDataSource() {
        return DataSourceBuilder.create().build();
    }
    
}
