package com.yfd.platform.config;

import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
import com.yfd.platform.utils.MybatisUtil;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;

import java.sql.SQLException;

/******************************
 * 用途说明: mybatis-plus分页查询特殊字符处理
 * 作者姓名: pcj
 * 创建时间: 2022/10/24 10:50
 ******************************/
public class LikeStringEscapeInterceptor implements InnerInterceptor {
 
    @Override
    public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds,
                            ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
        // 为了在分页插件中复用，此处抽取出静态方法
        MybatisUtil.escapeParameterIfContainingLike(ms, boundSql);
        InnerInterceptor.super.beforeQuery(executor, ms, parameter, rowBounds, resultHandler, boundSql);
    }
 
}
