package com.simuwang.base.config;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class DataSourceConfiguration {
    public static final String DATA_DAQ_PROPERTIES = "spring.datasource.data-daq";
    public static final String DS_DATA_DAQ = "spring.datasource.data-daq.hikari";

    @Primary
    @Bean(name = DATA_DAQ_PROPERTIES)
    @ConfigurationProperties(prefix = DATA_DAQ_PROPERTIES)
    public DataSourceProperties daqDataSourceProperties() {
        return new DataSourceProperties();
    }

    @Primary
    @Bean(name = DS_DATA_DAQ)
    @ConfigurationProperties(prefix = DS_DATA_DAQ)
    public HikariDataSource dataTrustDataSource() {
        return daqDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
    }
}
