com.jn.sqlhelper.mybatisplus.plugins.pagination.CustomMybatisPlus3_3_0ParameterHandler Maven / Gradle / Ivy
package com.jn.sqlhelper.mybatisplus.plugins.pagination;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
import com.jn.langx.util.Objs;
import com.jn.langx.util.Strings;
import com.jn.langx.util.collection.Collects;
import com.jn.langx.util.function.Consumer;
import com.jn.langx.util.reflect.type.Primitives;
import com.jn.sqlhelper.mybatis.plugins.CustomMybatisParameterHandler;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.reflection.MetaObject;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 适用mybatis plus 版本: [3.3.0, )
*
* code migrate from mybatis-plus 3.4.2 version
*/
public class CustomMybatisPlus3_3_0ParameterHandler extends CustomMybatisParameterHandler {
public CustomMybatisPlus3_3_0ParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
super(mappedStatement, parameterObject, boundSql);
}
@Override
protected Object processParameter(Object parameter) {
/* 只处理插入或更新操作 */
if (parameter != null
&& (SqlCommandType.INSERT == this.sqlCommandType || SqlCommandType.UPDATE == this.sqlCommandType)) {
//检查 parameterObject
if (Primitives.isPrimitiveOrPrimitiveWrapperType(parameter.getClass()) || parameter.getClass() == String.class) {
return parameter;
}
Collection