package com.ywt.config.jpa;

import com.ywt.core.SqlHelper;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.stereotype.Component;

@Component
public class Beans {

//    @Value("${service.agent.rest.addr}")
//    private String restServiceAgent;



    /**
     * 引用 ywt_center 库的 JdbcTemplate
     */
    @Autowired
    @Qualifier("ywtCenterJdbcTemplate")
    private JdbcTemplate ywtCenterJdbcTemplate;

    /**
     * 引用 glasses 库的 JdbcTemplate
     */
    @Autowired
    @Qualifier("glassesJdbcTemplate")
    private JdbcTemplate glassesJdbcTemplate;




    @Bean(name = "sqlHelperYwtCenter")
    public SqlHelper getSqlHelperYwtCenter() {
        return new SqlHelper(ywtCenterJdbcTemplate);
    }

    /**
     * 优先使用 glasses 库
     * @return
     */
    @Bean(name = "sqlHelperGlasses")
    @Primary
    public SqlHelper getSqlHelperGlasses() {
        return new SqlHelper(glassesJdbcTemplate);
    }

}