content: package com.fit2cloud.autoconfigure;
  
  
  import com.baomidou.mybatisplus.annotation.DbType;
  import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
  import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
  import com.zaxxer.hikari.HikariDataSource;
  import org.mybatis.spring.annotation.MapperScan;
  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.Primary;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  
  @MapperScan(basePackages = {"com.fit2cloud.dao.mapper", "com.fit2cloud.base.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory")
  @EnableTransactionManagement
  public class DatabaseConfig {
  
      /* 数据源 */
      @Bean
      @Primary
      @ConfigurationProperties("ce.datasource")
      public DataSourceProperties primaryDataSourceProperties() {
          return new DataSourceProperties();
      }
  
      @Bean
      @Primary
      @ConfigurationProperties("ce.datasource.hikari")
      public HikariDataSource firstDataSource(DataSourceProperties properties) {
          return properties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
      }
  
  
      @Bean
      public MybatisPlusInterceptor mybatisPlusInterceptor() {
          MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
          interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));//分页
          return interceptor;
      }
  
  }
  