refactor: rename QueryWrapperChain methods

This commit is contained in:
开源海哥 2023-07-22 19:00:43 +08:00
parent 7a0f1e918e
commit 1ce835a00d
2 changed files with 74 additions and 54 deletions

View File

@ -61,10 +61,73 @@ public class QueryWrapperChain<T> extends QueryWrapperAdapter<QueryWrapperChain<
return SqlUtil.toBool(count());
}
public T one() {
public T getOne() {
return baseMapper.selectOneByQuery(this);
}
public <R> R getOneAs(Class<R> asType) {
return baseMapper.selectOneByQueryAs(this, asType);
}
public T getOneWithRelations() {
return baseMapper.selectOneWithRelationsByQuery(this);
}
public <R> R getOneWithRelationsAs(Class<R> asType) {
return baseMapper.selectOneWithRelationsByQueryAs(this, asType);
}
public Optional<T> getOneOpt() {
return Optional.ofNullable(baseMapper.selectOneByQuery(this));
}
public <R> Optional<R> getOneAsOpt(Class<R> asType) {
return Optional.ofNullable(baseMapper.selectOneByQueryAs(this, asType));
}
public Optional<T> getOneWithRelationsOpt() {
return Optional.ofNullable(baseMapper.selectOneWithRelationsByQuery(this));
}
public <R> Optional<R> getOneWithRelationsAsOpt(Class<R> asType) {
return Optional.ofNullable(baseMapper.selectOneWithRelationsByQueryAs(this, asType));
}
public List<T> getList() {
return baseMapper.selectListByQuery(this);
}
public List<T> getListWithRelations() {
return baseMapper.selectListWithRelationsByQuery(this);
}
public <R> List<R> getListAs(Class<R> asType) {
return baseMapper.selectListByQueryAs(this, asType);
}
public <R> List<R> getListWithRelationsAs(Class<R> asType) {
return baseMapper.selectListWithRelationsByQueryAs(this, asType);
}
public Page<T> getPage(Page<T> page) {
return baseMapper.paginate(page, this);
}
public Page<T> getPageWithRelations(Page<T> page) {
return baseMapper.paginateWithRelations(page, this);
}
public <R> Page<R> getPageAs(Page<R> page, Class<R> asType) {
return baseMapper.paginateAs(page, this, asType);
}
public <R> Page<R> getPageWithRelationsAs(Page<R> page, Class<R> asType) {
return baseMapper.paginateWithRelationsAs(page, this, asType);
}
public Object getObj() {
return baseMapper.selectObjectByQuery(this);
}
@ -81,64 +144,21 @@ public class QueryWrapperChain<T> extends QueryWrapperAdapter<QueryWrapperChain<
return Optional.ofNullable(baseMapper.selectObjectByQueryAs(this, asType));
}
public <R> R oneAs(Class<R> asType) {
return baseMapper.selectOneByQueryAs(this, asType);
public List<Object> getObjList() {
return baseMapper.selectObjectListByQuery(this);
}
public T oneWithRelations() {
return baseMapper.selectOneWithRelationsByQuery(this);
public <R> List<R> getObjListAs(Class<R> asType) {
return baseMapper.selectObjectListByQueryAs(this, asType);
}
public <R> R oneWithRelationsAs(Class<R> asType) {
return baseMapper.selectOneWithRelationsByQueryAs(this, asType);
public Optional<Object> getObjListOpt() {
return Optional.ofNullable(baseMapper.selectObjectListByQuery(this));
}
public Optional<T> oneOpt() {
return Optional.ofNullable(baseMapper.selectOneByQuery(this));
}
public <R> Optional<R> oneAsOpt(Class<R> asType) {
return Optional.ofNullable(baseMapper.selectOneByQueryAs(this, asType));
}
public Optional<T> oneWithRelationsOpt() {
return Optional.ofNullable(baseMapper.selectOneWithRelationsByQuery(this));
}
public <R> Optional<R> oneWithRelationsAsOpt(Class<R> asType) {
return Optional.ofNullable(baseMapper.selectOneWithRelationsByQueryAs(this, asType));
}
public List<T> list() {
return baseMapper.selectListByQuery(this);
}
public List<T> listWithRelations() {
return baseMapper.selectListWithRelationsByQuery(this);
}
public <R> List<R> listAs(Class<R> asType) {
return baseMapper.selectListByQueryAs(this, asType);
}
public <R> List<R> listWithRelationsAs(Class<R> asType) {
return baseMapper.selectListWithRelationsByQueryAs(this, asType);
}
public Page<T> page(Page<T> page) {
return baseMapper.paginate(page, this);
}
public Page<T> pageWithRelations(Page<T> page) {
return baseMapper.paginateWithRelations(page, this);
}
public <R> Page<R> pageAs(Page<R> page, Class<R> asType) {
return baseMapper.paginateAs(page, this, asType);
}
public <R> Page<R> pageWithRelationsAs(Page<R> page, Class<R> asType) {
return baseMapper.paginateWithRelationsAs(page, this, asType);
public <R> Optional<List<R>> getObjListAsOpt(Class<R> asType) {
return Optional.ofNullable(baseMapper.selectObjectListByQueryAs(this, asType));
}
}

View File

@ -38,7 +38,7 @@ class ArticleServiceTest {
.select(ARTICLE.ALL_COLUMNS)
.from(ARTICLE)
.where(ARTICLE.ID.ge(100))
.list()
.getList()
.forEach(System.out::println);
}