diff --git a/src/main/java/ink/wgink/gateway/handler/route/RouteHandler.java b/src/main/java/ink/wgink/gateway/handler/route/RouteHandler.java index eecee27..ded75fe 100644 --- a/src/main/java/ink/wgink/gateway/handler/route/RouteHandler.java +++ b/src/main/java/ink/wgink/gateway/handler/route/RouteHandler.java @@ -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 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 listPage(Example example, int skip, long totalSize) { + Flux routeFlux = routeDao.findAll(example).skip(skip * totalSize).take(totalSize); + Mono mono = routeDao.count(example); + return Mono.just(new SuccessResultList()); } /**