diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java index b5c148db..6c51ac3a 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java @@ -49,6 +49,7 @@ import static com.mybatisflex.core.query.QueryMethods.count; * @author 王帅 * @author yangs * @author lhzsdnu + * @author 王超 */ @SuppressWarnings({"varargs", "unchecked", "unused"}) public interface BaseMapper { @@ -197,10 +198,10 @@ public interface BaseMapper { /** * 根据实体主键来删除数据。 * - * @param entity 实体对象,必须包含有主键 + * @param entity 实体对象,必须包含有主键 * @return 受影响的行数 */ - default int delete( T entity){ + default int delete(T entity) { FlexAssert.notNull(entity, "entity can not be null"); TableInfo tableInfo = TableInfoFactory.ofEntityClass(entity.getClass()); Object[] pkArgs = tableInfo.buildPkSqlArgs(entity); @@ -378,16 +379,15 @@ public interface BaseMapper { int updateByQuery(@Param(FlexConsts.ENTITY) T entity, @Param(FlexConsts.IGNORE_NULLS) boolean ignoreNulls, @Param(FlexConsts.QUERY) QueryWrapper queryWrapper); - // === 查(select) === /** * 根据实体主键查询数据。 * - * @param entity 实体对象,必须包含有主键 + * @param entity 实体对象,必须包含有主键 * @return 实体类数据 */ - default T selectOneByEntity(T entity){ + default T selectOneByEntityId(T entity) { FlexAssert.notNull(entity, "entity can not be null"); TableInfo tableInfo = TableInfoFactory.ofEntityClass(entity.getClass()); Object[] pkArgs = tableInfo.buildPkSqlArgs(entity); 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 4ae5d20e..74a5fb3d 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 @@ -300,8 +300,8 @@ public interface IService { * @param entity 实体对象,必须包含有主键 * @return 查询结果数据 */ - default T getOneByEntity(T entity) { - return getMapper().selectOneByEntity(entity); + default T getOneByEntityId(T entity) { + return getMapper().selectOneByEntityId(entity); } /** @@ -311,8 +311,8 @@ public interface IService { * @return 查询结果数据 * @apiNote 该方法会将查询结果封装为 {@link Optional} 类进行返回,方便链式操作。 */ - default Optional getByEntityOpt(T entity) { - return Optional.ofNullable(getOneByEntity(entity)); + default Optional getByEntityIdOpt(T entity) { + return Optional.ofNullable(getOneByEntityId(entity)); } /** *

根据数据主键查询一条数据。