diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java index ded14920..5b14a0ee 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java @@ -20,18 +20,17 @@ import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.table.TableInfo; import com.mybatisflex.core.table.TableInfoFactory; -import com.mybatisflex.core.util.SqlUtil; import java.util.List; import java.util.Optional; /** - * {@link QueryWrapper}链式调用。 + * {@link QueryWrapper} 链式调用。 * * @author 王帅 * @since 2023-07-22 */ -public class QueryChain extends QueryWrapperAdapter> { +public class QueryChain extends QueryWrapperAdapter> implements MapperQueryChain { private final BaseMapper baseMapper; @@ -43,98 +42,76 @@ public class QueryChain extends QueryWrapperAdapter> { return new QueryChain<>(baseMapper); } - public long count() { - return baseMapper.selectCountByQuery(this); + @Override + public BaseMapper baseMapper() { + return baseMapper; } - public boolean exists() { - return SqlUtil.toBool(count()); - } - - public T one() { - return baseMapper.selectOneByQuery(this); - } - - public R oneAs(Class asType) { - return baseMapper.selectOneByQueryAs(this, asType); + @Override + public QueryWrapper toQueryWrapper() { + return this; } + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public T oneWithRelations() { return baseMapper.selectOneWithRelationsByQuery(this); } + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public R oneWithRelationsAs(Class asType) { return baseMapper.selectOneWithRelationsByQueryAs(this, asType); } - public Optional oneOpt() { - return Optional.ofNullable(baseMapper.selectOneByQuery(this)); - } - - public Optional oneAsOpt(Class asType) { - return Optional.ofNullable(baseMapper.selectOneByQueryAs(this, asType)); - } - + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public Optional oneWithRelationsOpt() { return Optional.ofNullable(baseMapper.selectOneWithRelationsByQuery(this)); } + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public Optional oneWithRelationsAsOpt(Class asType) { return Optional.ofNullable(baseMapper.selectOneWithRelationsByQueryAs(this, asType)); } - public Object obj() { - return baseMapper.selectObjectByQuery(this); - } - - public R objAs(Class asType) { - return baseMapper.selectObjectByQueryAs(this, asType); - } - - public Optional objOpt() { - return Optional.ofNullable(baseMapper.selectObjectByQuery(this)); - } - - public Optional objAsOpt(Class asType) { - return Optional.ofNullable(baseMapper.selectObjectByQueryAs(this, asType)); - } - - public List objList() { - return baseMapper.selectObjectListByQuery(this); - } - - public List objListAs(Class asType) { - return baseMapper.selectObjectListByQueryAs(this, asType); - } - - public List list() { - return baseMapper.selectListByQuery(this); - } - + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public List listWithRelations() { return baseMapper.selectListWithRelationsByQuery(this); } - public List listAs(Class asType) { - return baseMapper.selectListByQueryAs(this, asType); - } - + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public List listWithRelationsAs(Class asType) { return baseMapper.selectListWithRelationsByQueryAs(this, asType); } - public Page page(Page page) { - return baseMapper.paginate(page, this); - } - + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public Page pageWithRelations(Page page) { return baseMapper.paginateWithRelations(page, this); } - public Page pageAs(Page page, Class asType) { - return baseMapper.paginateAs(page, this, asType); - } - + /** + * @deprecated 该方法将在 1.6.0 版本移除 + */ + @Deprecated public Page pageWithRelationsAs(Page page, Class asType) { return baseMapper.paginateWithRelationsAs(page, this, asType); } @@ -145,4 +122,5 @@ public class QueryChain extends QueryWrapperAdapter> { CPI.setFromIfNecessary(this, tableInfo.getSchema(), tableInfo.getTableName()); return super.toSQL(); } + }