package com.elab.core.spring.config;

import com.elab.core.dao.BasicBaseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 * 基础dao层配置
 * <p>
 * author ： liukx
 *
 * @time ： 2020/4/2 - 10:58
 */
@Configuration
public class BasicDaoConfig {

//    @Autowired(required = false)
//    private List<SQLEventHandler> sqlEventHandlerList;
//
//    @Autowired(required = false)
//    private CheckSqlProcess checkSqlProcess;

    @Bean
    public JdbcTemplate jdbcTemplate(@Autowired DataSource dataSource) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(dataSource);
        return jdbcTemplate;
    }

    @Bean
    public BasicBaseDao basicBaseDao(@Autowired JdbcTemplate jdbcTemplate) {
        BasicBaseDao basicBaseDao = new BasicBaseDao();
        basicBaseDao.setJdbcTemplate(jdbcTemplate);
//        basicBaseDao.setSqlEventHandlerList(sqlEventHandlerList);
//        basicBaseDao.setCheckSqlProcess(checkSqlProcess);
        return basicBaseDao;
    }
}
