diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java index 96124ce3..19652951 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java @@ -155,6 +155,39 @@ public interface IService { return remove(query().where(query)); } + /** + *

根据数据主键更新数据。 + * + * @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)); + } + + /** + *

根据 {@link Map} 构建查询条件更新数据。 + * + * @param entity 实体类对象 + * @param query 查询条件 + * @return {@code true} 更新成功,{@code false} 更新失败。 + */ + default boolean update(T entity, Map query) { + return update(entity, query().where(query)); + } + /** *

根据查询条件更新数据。 * @@ -204,26 +237,6 @@ public interface IService { }); } - /** - *

根据数据主键更新数据。 - * - * @param entity 实体类对象 - * @return {@code true} 更新成功,{@code false} 更新失败。 - */ - default boolean updateById(T entity) { - return SqlUtil.toBool(getMapper().update(entity)); - } - - /** - *

根据 {@link Map} 构建查询条件更新数据。 - * - * @param entity 实体类对象 - * @param query 查询条件 - * @return {@code true} 更新成功,{@code false} 更新失败。 - */ - default boolean updateByMap(T entity, Map query) { - return update(entity, query().where(query)); - } // ===== 查询(查)操作 =====