mybatisPlus底层的新增方法是一条一条的新增的,今天自定义批量新增方法。
创建自定义数据方法注入类
public class EasySqlInjector extends DefaultSqlInjector {
@Override
public List getMethodList(Class> mapperClass) {
//防止父类方法不可用
List methods= super.getMethodList(mapperClass);
methods.add(new InsertBatchSomeColumn());
return methods;
}
}
在mybatisplus配置文件MybatisPlusConfig加入自定义
@Bean
public EasySqlInjector easySqlInjector() {
return new EasySqlInjector();
}
创建EasybaseMapper 扩展通用 Mapper
package com.cgmcomm.mallplus.basic.mapper; import com.baomidou.mybatisplus.core.mapper.baseMapper; import java.util.Collection; public interface EasybaseMapperextends baseMapper { Integer insertBatchSomeColumn(Collection entityList); }
** * 定义业务mapper接口,继承刚刚扩展的EasybaseMapper * * @author 天开易想 */ @Mapper public interface TestMapper extends EasybaseMapper{ } @Service public class TestServiceImpl extends ServiceImpl implements TestService { @Override public Integer testBatch(Collection testList) { return baseMapper.insertBatchSomeColumn(testList); }
到此这篇关于mybatisPlus自定义批量新增的实现代码的文章就介绍到这了,更多相关mybatisPlus自定义批量新增内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!



