package cn.axzo.msg.center.notices.client.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;

import javax.sql.DataSource;

/**
 * 数据库配置
 *
 * @author zhaoyong_sh
 * @see DatasourceConfig
 * @since 2021-05-27 16:27
 */
@Configuration
public class DatasourceConfig {

  @Bean(name = "transactionTemplate")
  public TransactionTemplate transactionTemplate(DataSource dataSource) {
    TransactionTemplate transactionTemplate = new TransactionTemplate();
    DataSourceTransactionManager platformTransactionManager = new DataSourceTransactionManager();
    platformTransactionManager.setDataSource(dataSource);
    transactionTemplate.setTransactionManager(platformTransactionManager);
    return transactionTemplate;
  }

}
