Browse Source

优化API

zhou-hao 5 năm trước cách đây
mục cha
commit
1408df0524

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

@@ -35,9 +35,9 @@ public interface ReactiveCrudService<E, K> {
     }
 
     @Transactional(readOnly = true)
-    default Mono<E> findById(K publisher) {
+    default Mono<E> findById(K id) {
         return getRepository()
-                .findById(publisher);
+                .findById(id);
     }
 
     @Transactional(readOnly = true)

+ 4 - 3
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/reactive/ReactiveQueryController.java

@@ -9,6 +9,7 @@ import org.hswebframework.web.exception.NotFoundException;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
@@ -71,7 +72,7 @@ public interface ReactiveQueryController<E, K> {
      */
     @PostMapping("/_query/no-paging")
     @QueryAction
-    default Flux<E> query(Mono<QueryParamEntity> query) {
+    default Flux<E> query(@RequestBody Mono<QueryParamEntity> query) {
         return query.flatMapMany(this::query);
     }
 
@@ -134,13 +135,13 @@ public interface ReactiveQueryController<E, K> {
     @PostMapping("/_query")
     @QueryAction
     @SuppressWarnings("all")
-    default Mono<PagerResult<E>> queryPager(Mono<QueryParamEntity> query) {
+    default Mono<PagerResult<E>> queryPager(@RequestBody Mono<QueryParamEntity> query) {
         return query.flatMap(q -> queryPager(q));
     }
 
     @PostMapping("/_count")
     @QueryAction
-    default Mono<Integer> count(Mono<QueryParamEntity> query) {
+    default Mono<Integer> count(@RequestBody Mono<QueryParamEntity> query) {
         return query.flatMap(this::count);
     }
 

+ 4 - 3
hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/reactive/ReactiveServiceQueryController.java

@@ -9,6 +9,7 @@ import org.hswebframework.web.exception.NotFoundException;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
@@ -29,7 +30,7 @@ public interface ReactiveServiceQueryController<E, K> {
 
     @PostMapping("/_query/no-paging")
     @QueryAction
-    default Flux<E> query(Mono<QueryParamEntity> query) {
+    default Flux<E> query(@RequestBody Mono<QueryParamEntity> query) {
         return query.flatMapMany(this::query);
     }
 
@@ -51,13 +52,13 @@ public interface ReactiveServiceQueryController<E, K> {
     @PostMapping("/_query")
     @QueryAction
     @SuppressWarnings("all")
-    default Mono<PagerResult<E>> queryPager(Mono<QueryParamEntity> query) {
+    default Mono<PagerResult<E>> queryPager(@RequestBody Mono<QueryParamEntity> query) {
         return getService().queryPager(query);
     }
 
     @PostMapping("/_count")
     @QueryAction
-    default Mono<Integer> count(Mono<QueryParamEntity> query) {
+    default Mono<Integer> count(@RequestBody Mono<QueryParamEntity> query) {
         return query.flatMap(this::count);
     }