调整分页
This commit is contained in:
parent
ba311be507
commit
3de86dde66
@ -3,6 +3,7 @@ package ink.wgink.gateway.handler.route;
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.handler.BaseHandler;
|
||||
import ink.wgink.gateway.pojo.ListSearch;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResultList;
|
||||
import ink.wgink.gateway.pojo.route.Route;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
@ -11,6 +12,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -112,18 +114,26 @@ public class RouteHandler extends BaseHandler {
|
||||
if (size.isPresent()) {
|
||||
totalSize = Integer.parseInt(size.get());
|
||||
}
|
||||
|
||||
Optional<String> keyword = serverRequest.queryParam("keyword");
|
||||
Route route = new Route();
|
||||
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAny();
|
||||
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAny()
|
||||
.withMatcher("system", ExampleMatcher.GenericPropertyMatcher::contains)
|
||||
.withMatcher("summary", ExampleMatcher.GenericPropertyMatcher::contains)
|
||||
.withIgnoreCase("id");
|
||||
Example example = Example.of(route, exampleMatcher);
|
||||
if (keyword.isPresent()) {
|
||||
route.setSystem(keyword.get());
|
||||
route.setSummary(keyword.get());
|
||||
exampleMatcher
|
||||
.withMatcher("system", ExampleMatcher.GenericPropertyMatcher::contains)
|
||||
.withMatcher("summary", ExampleMatcher.GenericPropertyMatcher::contains);
|
||||
}
|
||||
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(routeDao.findAll().skip((currentPage - 1) * totalSize).take(totalSize), Route.class);
|
||||
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(listPage(example, currentPage - 1, totalSize), Route.class);
|
||||
//return routeDao.findAll(example).skip((currentPage - 1) * totalSize).take(totalSize);
|
||||
}
|
||||
|
||||
public Mono<SuccessResultList> listPage(Example example, int skip, long totalSize) {
|
||||
Flux<Route> routeFlux = routeDao.findAll(example).skip(skip * totalSize).take(totalSize);
|
||||
Mono<Long> mono = routeDao.count(example);
|
||||
return Mono.just(new SuccessResultList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user