Browse Source

优化参数clone

zhou-hao 3 years ago
parent
commit
52bfe0288d

+ 1 - 1
hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/QueryParamEntity.java

@@ -128,7 +128,7 @@ public class QueryParamEntity extends QueryParam {
      * <p>
      * 执行后条件: (name=? or type=?) and userId=?
      *
-     * @see this#toNestQuery(Consumer)
+     * @see QueryParamEntity#toNestQuery(Consumer)
      * @since 3.0.4
      */
     public <T> Query<T, QueryParamEntity> toNestQuery() {

+ 2 - 2
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/ReactiveCrudService.java

@@ -207,14 +207,14 @@ public interface ReactiveCrudService<E, K> {
         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) {

+ 1 - 1
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/QueryController.java

@@ -113,7 +113,7 @@ public interface QueryController<E, K> {
                                 .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);
         }

+ 1 - 1
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/ServiceQueryController.java

@@ -111,7 +111,7 @@ public interface ServiceQueryController<E, K> {
                                 .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);
         }

+ 7 - 6
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/reactive/ReactiveQueryController.java

@@ -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)
@@ -109,11 +109,12 @@ public interface ReactiveQueryController<E, K> {
                     .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)
+                );
 
     }