package cn.cslg.pas.common.config;

import cn.cslg.pas.common.config.InnerInterceptor.LizzMybatisIntercepts;
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;

@Configuration
@MapperScan("cn.cslg.pas.mapper")
public class MybatisPlusConfig {
    @Bean//必须加Bean注解，否则无法拦截器里无法实例化serve
    public LizzMybatisIntercepts lizzMybatisIntercepts(){
        return  new LizzMybatisIntercepts();
    } //自定义拦截器
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(lizzMybatisIntercepts());//加入自定义拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
