package com.ycwl.basic.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wenshijia
 * @date 2021年06月04日 9:42
 */
@Configuration
@MapperScan(basePackages = {
        "com.ycwl.basic.mapper",
        "com.ycwl.basic.order.mapper",
        "com.ycwl.basic.pricing.mapper",
        "com.ycwl.basic.product.mapper",
        "com.ycwl.basic.profitsharing.mapper",
        "com.ycwl.basic.puzzle.mapper",
        "com.ycwl.basic.stats.mapper"
})
public class MybatisPlusPageConfig {

    /*	旧版本配置
	@Bean
	public PaginationInterceptor paginationInterceptor(){
		return new PaginationInterceptor();
	}*/

    /**
     * 新的分页插件,一缓和二缓遵循mybatis的规则,
     * 需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
