optimize IService.java

This commit is contained in:
开源海哥 2023-06-01 18:29:23 +08:00
parent 768f2be3ae
commit 2ac702a140

View File

@ -155,6 +155,39 @@ public interface IService<T> {
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>根据查询条件更新数据
*
@ -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));
}
// ===== 查询操作 =====