mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
refactor: optimize IService.java
This commit is contained in:
parent
a9c8638eac
commit
fb7d13f4b9
@ -269,6 +269,7 @@ public interface IService<T> {
|
||||
return updateBatch(entities, DEFAULT_BATCH_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>根据数据主键批量更新数据
|
||||
*
|
||||
@ -279,8 +280,8 @@ public interface IService<T> {
|
||||
* @return boolean {@code true} 更新成功,{@code false} 更新失败。
|
||||
* @apiNote 若 {@code ignoreNulls} 为 {@code true},实体类中为 {@code null} 的属性不会更新到数据库。
|
||||
*/
|
||||
default boolean updateBatchWithIgnoreNulls(Collection<T> entities, boolean ignoreNulls) {
|
||||
return updateBatchWithIgnoreNulls(entities, DEFAULT_BATCH_SIZE, ignoreNulls);
|
||||
default boolean updateBatch(Collection<T> entities, boolean ignoreNulls) {
|
||||
return updateBatch(entities, DEFAULT_BATCH_SIZE, ignoreNulls);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -296,6 +297,7 @@ public interface IService<T> {
|
||||
return SqlUtil.toBool(Db.executeBatch(entities, batchSize, usefulClass, BaseMapper::update));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>根据数据主键批量更新数据
|
||||
*
|
||||
@ -307,7 +309,7 @@ public interface IService<T> {
|
||||
* @return {@code true} 更新成功,{@code false} 更新失败。
|
||||
* @apiNote 若 {@code ignoreNulls} 为 {@code true},实体类中为 {@code null} 的属性不会更新到数据库。
|
||||
*/
|
||||
default boolean updateBatchWithIgnoreNulls(Collection<T> entities, int batchSize, boolean ignoreNulls) {
|
||||
default boolean updateBatch(Collection<T> entities, int batchSize, boolean ignoreNulls) {
|
||||
Class<BaseMapper<T>> usefulClass = (Class<BaseMapper<T>>) ClassUtil.getUsefulClass(getMapper().getClass());
|
||||
return SqlUtil.toBool(Db.executeBatch(entities, batchSize, usefulClass, (mapper, entity) -> mapper.update(entity, ignoreNulls)));
|
||||
}
|
||||
@ -344,6 +346,7 @@ public interface IService<T> {
|
||||
default Optional<T> getByEntityIdOpt(T entity) {
|
||||
return Optional.ofNullable(getOneByEntityId(entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>根据数据主键查询一条数据。
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user