mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
optimize IService.java
This commit is contained in:
parent
768f2be3ae
commit
2ac702a140
@ -155,6 +155,39 @@ public interface IService<T> {
|
|||||||
return remove(query().where(query));
|
return remove(query().where(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>根据数据主键更新数据。
|
||||||
|
*
|
||||||
|
* @param entity 实体类对象
|
||||||
|
* @return {@code true} 更新成功,{@code false} 更新失败。
|
||||||
|
*/
|
||||||
|
default boolean updateById(T entity) {
|
||||||
|
return SqlUtil.toBool(getMapper().update(entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据主键更新数据
|
||||||
|
*
|
||||||
|
* @param entity 实体对象
|
||||||
|
* @param ignoreNulls 是否忽略 null 值
|
||||||
|
* @return {@code true} 更新成功,{@code false} 更新失败。
|
||||||
|
*/
|
||||||
|
default boolean updateById(T entity, boolean ignoreNulls) {
|
||||||
|
return SqlUtil.toBool(getMapper().update(entity, ignoreNulls));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>根据 {@link Map} 构建查询条件更新数据。
|
||||||
|
*
|
||||||
|
* @param entity 实体类对象
|
||||||
|
* @param query 查询条件
|
||||||
|
* @return {@code true} 更新成功,{@code false} 更新失败。
|
||||||
|
*/
|
||||||
|
default boolean update(T entity, Map<String, Object> query) {
|
||||||
|
return update(entity, query().where(query));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>根据查询条件更新数据。
|
* <p>根据查询条件更新数据。
|
||||||
*
|
*
|
||||||
@ -204,26 +237,6 @@ public interface IService<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>根据数据主键更新数据。
|
|
||||||
*
|
|
||||||
* @param entity 实体类对象
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败。
|
|
||||||
*/
|
|
||||||
default boolean updateById(T entity) {
|
|
||||||
return SqlUtil.toBool(getMapper().update(entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>根据 {@link Map} 构建查询条件更新数据。
|
|
||||||
*
|
|
||||||
* @param entity 实体类对象
|
|
||||||
* @param query 查询条件
|
|
||||||
* @return {@code true} 更新成功,{@code false} 更新失败。
|
|
||||||
*/
|
|
||||||
default boolean updateByMap(T entity, Map<String, Object> query) {
|
|
||||||
return update(entity, query().where(query));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===== 查询(查)操作 =====
|
// ===== 查询(查)操作 =====
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user