1、在自定义注入器MySqlInjector上添加选装件方法
public class MySqlInjector extends DefaultSqlInjector {
@Override
public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
List<AbstractMethod> methodList = super.getMethodList(mapperClass);
methodList.add(new InsertBatchSomeColumn());
methodList.add(new AlwaysUpdateSomeColumnById());
methodList.add(new LogicDeleteByIdWithFill());
return methodList;
}
}
2、创建MP配置文件MybatisPlusConfig,放在config目录下
@Configuration
public class MybatisPlusConfig {
@Bean
public MySqlInjector sqlInjector(){
return new MySqlInjector();
}
}
3、创建MyBaseMapper,继承BaseMapper,添加内置选装件方法
public interface MyBaseMapper<T> extends BaseMapper<T> {
int insertBatchSomeColumn(List<T> entityList);
int alwaysUpdateSomeColumnById(@Param(Constants.ENTITY) T entity);
int deleteByIdWithFill(T entity);
}
最新回复