Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created January 17, 2020 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ereshzealous/2694e55cb983891c9559ce71283b7327 to your computer and use it in GitHub Desktop.
Save ereshzealous/2694e55cb983891c9559ce71283b7327 to your computer and use it in GitHub Desktop.
public Mono<WSAuthorResponse> findAuthors(Integer offset, Integer limit) {
WSAuthorResponse result = new WSAuthorResponse();
return authorRepository.count()
.map(totalElements -> {
result.setTotalElements(totalElements);
return totalElements;
})
.flatMapMany(el -> authorRepository.retrieveAllAuthors(PageRequest.of(offset, limit)))
.collectList()
.map(data -> {
result.setAuthors(data);
return result;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment