From eab0aa894f84b47489b7b19586fa48b71a93b1b7 Mon Sep 17 00:00:00 2001 From: xooooooooox Date: Thu, 26 Dec 2024 14:27:42 +0800 Subject: [PATCH] feat: Add insertBatch method to BaseMapperX --- CHANGELOG.md | 4 ++++ .../mybatis/spring/boot/mapper/BaseMapperX.java | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86cc817..0d327c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # ChangeLog +## 0.3 + +- + ## 0.2 ### features diff --git a/radp-components/radp-spring-boot-starters/radp-mybatis-spring-boot-starter/src/main/java/space/x9x/radp/mybatis/spring/boot/mapper/BaseMapperX.java b/radp-components/radp-spring-boot-starters/radp-mybatis-spring-boot-starter/src/main/java/space/x9x/radp/mybatis/spring/boot/mapper/BaseMapperX.java index a8ee586..81ab1f8 100644 --- a/radp-components/radp-spring-boot-starters/radp-mybatis-spring-boot-starter/src/main/java/space/x9x/radp/mybatis/spring/boot/mapper/BaseMapperX.java +++ b/radp-components/radp-spring-boot-starters/radp-mybatis-spring-boot-starter/src/main/java/space/x9x/radp/mybatis/spring/boot/mapper/BaseMapperX.java @@ -50,7 +50,7 @@ default PageResult selectPage(PageParam pageParam, List sorting // ================================ Join ============================== // default PageResult selectJoinPage(PageParam pageParam, Class clazz, MPJLambdaWrapper lambdaWrapper) { - if (pageParam.getPageSize().equals(PageParam.PAGE_SIZE_NONE)){ + if (pageParam.getPageSize().equals(PageParam.PAGE_SIZE_NONE)) { List totalList = selectJoinList(clazz, lambdaWrapper); return PageResult.build(totalList, (long) totalList.size()); } @@ -158,4 +158,15 @@ default int delete(String field, String value) { default int delete(SFunction field, Object value) { return delete(new LambdaQueryWrapper().eq(field, value)); } + + /** + * 批量插入 + * + * @param collections 待插入的数据列表 + * @param size 插入数量, {@link Db#saveBatch} 默认为 1000 + * @return 操作成功或失败 + */ + default Boolean insertBatch(Collection collections, int size) { + return Db.saveBatch(collections, size); + } }