//package com.inkasso.config;
//
//import com.baomidou.mybatisplus.annotation.IdType;
//import com.baomidou.mybatisplus.core.MybatisConfiguration;
//import com.baomidou.mybatisplus.core.config.GlobalConfig;
//import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
//import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//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.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.core.io.support.ResourcePatternResolver;
//import org.springframework.transaction.PlatformTransactionManager;
//
//import javax.annotation.Resource;
//import javax.sql.DataSource;
//
///**
// * @author 张超
// * @date 2021/4/13
// */
//@Configuration
//@MapperScan(basePackages = {"com.inkasso.heavycar.*.dao"}, sqlSessionTemplateRef = "sqlTemplate2")
//public class MybatisPlusTwoConfig {
//
//    @Resource(name = "heavyCarDataSource")
//    private DataSource dataSource;
//
////    @Autowired
////    private MetaObjectHandler metaObjectHandler;
//
//    @Autowired
//    private MybatisPlusInterceptor mybatisPlusInterceptor;
//
//
//    @Bean(name = "sqlFactory2")
//    public SqlSessionFactory sqlSessionFactory()
//            throws Exception {
//        MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
//        factoryBean.setDataSource(dataSource);
//        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//        factoryBean.setMapperLocations(resolver.getResources("classpath*:mapping/heavycarmapping/**/*.xml"));
//        MybatisConfiguration config = new MybatisConfiguration();
//        config.setMapUnderscoreToCamelCase(true);
//        config.setMultipleResultSetsEnabled(true);
//        config.setMapUnderscoreToCamelCase(true);
//        GlobalConfig globalConfig = new GlobalConfig();
//        globalConfig.setBanner(false);
//        //globalConfig.setMetaObjectHandler(metaObjectHandler);
//        GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
//        dbConfig.setIdType(IdType.ASSIGN_ID).setTableUnderline(true).setLogicDeleteField("delete_flag").setLogicDeleteValue("1").setLogicNotDeleteValue("0");
//        globalConfig.setDbConfig(dbConfig);
//
//        GlobalConfigUtils.setGlobalConfig(config,globalConfig);
//        factoryBean.setConfiguration(config);
//
//        factoryBean.setPlugins(mybatisPlusInterceptor);
//
//        return factoryBean.getObject();
//    }
//
//    @Bean(name = "sqlTemplate2")
//    public SqlSessionTemplate sqlSessionTemplate(@Qualifier("sqlFactory2") SqlSessionFactory sqlSessionFactory) {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
//}
