Skip to content

Commit

Permalink
优化参数clone
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Jul 30, 2021
1 parent ed5e3b0 commit 52bfe02
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public <T> Query<T, QueryParamEntity> toQuery() {
* <p>
* 执行后条件: (name=? or type=?) and userId=?
*
* @see this#toNestQuery(Consumer)
* @see QueryParamEntity#toNestQuery(Consumer)
* @since 3.0.4
*/
public <T> Query<T, QueryParamEntity> toNestQuery() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ default <T> Mono<PagerResult<T>> queryPager(QueryParamEntity query, Function<E,
if (query.isParallelPager()) {
return Mono
.zip(
createQuery().setParam(query).count(),
createQuery().setParam(query.clone()).count(),
createQuery().setParam(query.clone()).fetch().map(mapper).collectList(),
(total, data) -> PagerResult.of(total, data, query)
);
}
return getRepository()
.createQuery()
.setParam(query)
.setParam(query.clone())
.count()
.flatMap(total -> {
if (total == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ default PagerResult<E> queryPager(@Parameter(hidden = true) QueryParamEntity que
.fetch(), query)
;
}
int total = getRepository().createQuery().setParam(query).count();
int total = getRepository().createQuery().setParam(query.clone()).count();
if (total == 0) {
return PagerResult.of(0, Collections.emptyList(), query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ default PagerResult<E> queryPager(@Parameter(hidden = true) QueryParamEntity que
.fetch(), query)
;
}
int total = getService().createQuery().setParam(query).count();
int total = getService().createQuery().setParam(query.clone()).count();
if (total == 0) {
return PagerResult.of(0, Collections.emptyList(), query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public interface ReactiveQueryController<E, K> {
@QueryAction
@QueryOperation(summary = "使用GET方式分页动态查询(不返回总数)",
description = "此操作不返回分页总数,如果需要获取全部数据,请设置参数paging=false")
default Flux<E> query(@Parameter(hidden = true) QueryParamEntity query) {
default Flux<E> query(@Parameter(hidden = true) QueryParamEntity query) {
return getRepository()
.createQuery()
.setParam(query)
Expand Down Expand Up @@ -109,11 +109,12 @@ default Mono<PagerResult<E>> queryPager(@Parameter(hidden = true) QueryParamEnti
.map(list -> PagerResult.of(query.getTotal(), list, query));
}

return Mono.zip(
getRepository().createQuery().setParam(query).count(),
query(query.clone()).collectList(),
(total, data) -> PagerResult.of(total, data, query)
);
return Mono
.zip(
getRepository().createQuery().setParam(query.clone()).count(),
query(query.clone()).collectList(),
(total, data) -> PagerResult.of(total, data, query)
);

}

Expand Down

0 comments on commit 52bfe02

Please sign in to comment.