!184 BaseMapper 添加 selectOneWithRelationsByIdAs 方法

Merge pull request !184 from Jerry_Zheng/main
This commit is contained in:
Michael Yang 2023-07-26 01:41:06 +00:00 committed by Gitee
commit c4872f913a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -500,6 +500,20 @@ public interface BaseMapper<T> {
return MapperUtil.queryRelations(this, selectOneById(id));
}
/**
* 根据主表主键来查询 1 条数据
* @param id 表主键
* @param asType 接收数据类型
* @return 实体类数据
*/
default <R> R selectOneWithRelationsByIdAs(Serializable id, Class<R> asType) {
try {
MappedStatementTypes.setCurrentType(asType);
return (R) selectOneWithRelationsById(id);
} finally {
MappedStatementTypes.clear();
}
}
/**
* 根据查询条件来查询 1 条数据
*