feat(可回溯): 可回溯
修改分页查询
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ public class OrderController {
|
|||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public Mono<ResObj> list(@RequestBody Order order) {
|
public Mono<ResObj> list(@RequestBody Order order) {
|
||||||
OrderList resList = new OrderList();
|
OrderList resList = new OrderList();
|
||||||
|
List<Order> list = new ArrayList<>();
|
||||||
PageRequest pageRequest = PageRequest.of(order.getPage(), order.getPageSize());
|
PageRequest pageRequest = PageRequest.of(order.getPage(), order.getPageSize());
|
||||||
ExampleMatcher matcher = ExampleMatcher.matching()
|
ExampleMatcher matcher = ExampleMatcher.matching()
|
||||||
.withIgnoreNullValues().withIgnorePaths("createAt", "last");
|
.withIgnoreNullValues().withIgnorePaths("createAt", "last");
|
||||||
@@ -42,11 +44,16 @@ public class OrderController {
|
|||||||
|
|
||||||
Flux<Order> flux = orderRepository.findAll(ep, s);
|
Flux<Order> flux = orderRepository.findAll(ep, s);
|
||||||
flux.count().subscribe(c -> resList.setTotal(c));
|
flux.count().subscribe(c -> resList.setTotal(c));
|
||||||
Mono<List<Order>> listMono = flux.skip(pageRequest.getOffset()).limitRequest(pageRequest.getPageSize()).collectList();
|
flux.skip(pageRequest.getOffset()).limitRequest(pageRequest.getPageSize()).subscribe(f -> {
|
||||||
return listMono.flatMap(list -> {
|
list.add(f);
|
||||||
resList.setList(list);
|
|
||||||
return Mono.just(ResObj.ok(resList));
|
|
||||||
});
|
});
|
||||||
|
resList.setList(list);
|
||||||
|
// Mono<List<Order>> listMono = flux.skip(pageRequest.getOffset()).limitRequest(pageRequest.getPageSize()).collectList();
|
||||||
|
// return listMono.flatMap(list -> {
|
||||||
|
// resList.setList(list);
|
||||||
|
// return Mono.just(ResObj.ok(resList));
|
||||||
|
// });
|
||||||
|
return Mono.just(ResObj.ok(resList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/info/{orderId}")
|
@PostMapping("/info/{orderId}")
|
||||||
|
|||||||
Reference in New Issue
Block a user