You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package com.glxp.api.config;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
|
|
|
|
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 自定义sql注入器,增加通用方法
|
|
|
|
|
*/
|
|
|
|
|
public class CustomerSqlInjector extends DefaultSqlInjector {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
|
|
|
|
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
|
|
|
|
|
// 插入数据,如果中已经存在相同的记录,则忽略当前新数据
|
|
|
|
|
methodList.add(new InsertIgnore());
|
|
|
|
|
// 批量插入数据,如果中已经存在相同的记录,则忽略当前新数据
|
|
|
|
|
methodList.add(new InsertIgnoreBatch());
|
|
|
|
|
// 替换数据,如果中已经存在相同的记录,则覆盖旧数据
|
|
|
|
|
methodList.add(new Replace());
|
|
|
|
|
// 批量替换数据,如果中已经存在相同的记录,则覆盖旧数据
|
|
|
|
|
methodList.add(new ReplaceBatch());
|
|
|
|
|
return methodList;
|
|
|
|
|
}
|
|
|
|
|
}
|