package cn.axzo.msg.center.message.service.todo.mybatis;

import cn.axzo.msg.center.inside.notices.config.DiagnosisProps;
import cn.axzo.msg.center.inside.notices.config.PendingMessageBizConfig;
import cn.axzo.msg.center.message.service.todo.mybatis.rowcountwarn.RowCountInterceptor;
import cn.axzo.msg.center.util.DeleteAwareInterceptor;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 由于依赖顺序的问题, 这里需要重新定义一个
 *
 * @author yanglin
 */
@Configuration
public class SqlInterceptorConfig {

    @Bean
    ReplaceInterceptor replaceTableInterceptor() {
        return new ReplaceInterceptor();
    }

    @Bean
    RowCountInterceptor rowCountInterceptor(DiagnosisProps props,
                                            ListableBeanFactory beanFactory) {
        return new RowCountInterceptor(props, beanFactory);
    }

    @Bean
    CollectSQLInterceptor sqlCollectInterceptor() {
        return new CollectSQLInterceptor();
    }

    @Bean
    DeleteAwareInterceptor deleteAwareInterceptor() {
        return new DeleteAwareInterceptor();
    }

    @Bean
    public BeautifulPaginationInterceptor paginationInterceptor2() {
        return new BeautifulPaginationInterceptor();
    }

    @Bean
    LogExecSQLInterceptor logExecSQLInterceptor(PendingMessageBizConfig cfg) {
        return new LogExecSQLInterceptor(cfg);
    }
}
