mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 09:08:24 +08:00
Merge branch 'main' of https://gitee.com/mybatis-flex/mybatis-flex
This commit is contained in:
commit
cb8ed1735c
@ -4,4 +4,4 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="#(packageConfig.mapperPackage).#(table.buildMapperClassName())">
|
<mapper namespace="#(packageConfig.mapperPackage).#(table.buildMapperClassName())">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -11,4 +11,4 @@ import #(packageConfig.entityPackage).#(table.buildEntityClassName());
|
|||||||
*/
|
*/
|
||||||
public interface #(table.buildServiceClassName()) extends #(serviceConfig.buildSuperClassName())<#(table.buildEntityClassName())> {
|
public interface #(table.buildServiceClassName()) extends #(serviceConfig.buildSuperClassName())<#(table.buildEntityClassName())> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,4 +121,4 @@ public class #(table.buildServiceImplClassName()) extends #(serviceImplConfig.bu
|
|||||||
}
|
}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,10 @@ import com.mybatisflex.core.util.CollectionUtil;
|
|||||||
import com.mybatisflex.core.util.SqlUtil;
|
import com.mybatisflex.core.util.SqlUtil;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,8 +86,6 @@ public interface IService<T> {
|
|||||||
return saveBatch(entities, DEFAULT_BATCH_SIZE);
|
return saveBatch(entities, DEFAULT_BATCH_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 删除(删)操作 =====
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>批量保存实体类对象数据。
|
* <p>批量保存实体类对象数据。
|
||||||
*
|
*
|
||||||
@ -93,10 +94,16 @@ public interface IService<T> {
|
|||||||
* @return {@code true} 保存成功,{@code false} 保存失败。
|
* @return {@code true} 保存成功,{@code false} 保存失败。
|
||||||
*/
|
*/
|
||||||
default boolean saveBatch(Collection<T> entities, int batchSize) {
|
default boolean saveBatch(Collection<T> entities, int batchSize) {
|
||||||
return SqlUtil.toBool(getMapper().insertBatch(CollectionUtil.toList(entities), batchSize));
|
List<T> entityList = CollectionUtil.toList(entities);
|
||||||
|
Class<BaseMapper<T>> usefulClass = (Class<BaseMapper<T>>) ClassUtil.getUsefulClass(getMapper().getClass());
|
||||||
|
return SqlUtil.toBool(
|
||||||
|
Db.executeBatch(entities.size()
|
||||||
|
, batchSize
|
||||||
|
, usefulClass
|
||||||
|
, (mapper, integer) -> mapper.insert(entityList.get(integer)))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>批量保存实体类对象数据。
|
* <p>批量保存实体类对象数据。
|
||||||
*
|
*
|
||||||
@ -107,8 +114,6 @@ public interface IService<T> {
|
|||||||
return saveBatchSelective(entities, DEFAULT_BATCH_SIZE);
|
return saveBatchSelective(entities, DEFAULT_BATCH_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 删除(删)操作 =====
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>批量保存实体类对象数据。
|
* <p>批量保存实体类对象数据。
|
||||||
*
|
*
|
||||||
@ -120,10 +125,14 @@ public interface IService<T> {
|
|||||||
List<T> entityList = CollectionUtil.toList(entities);
|
List<T> entityList = CollectionUtil.toList(entities);
|
||||||
Class<BaseMapper<T>> usefulClass = (Class<BaseMapper<T>>) ClassUtil.getUsefulClass(getMapper().getClass());
|
Class<BaseMapper<T>> usefulClass = (Class<BaseMapper<T>>) ClassUtil.getUsefulClass(getMapper().getClass());
|
||||||
return SqlUtil.toBool(
|
return SqlUtil.toBool(
|
||||||
Db.executeBatch(entities.size(), batchSize, usefulClass, (mapper, integer) -> mapper.insertSelective(entityList.get(integer)))
|
Db.executeBatch(entities.size()
|
||||||
|
, batchSize
|
||||||
|
, usefulClass
|
||||||
|
, (mapper, integer) -> mapper.insertSelective(entityList.get(integer)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 删除(删)操作 =====
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>根据查询条件删除数据。
|
* <p>根据查询条件删除数据。
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user