Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created December 27, 2019 11:24
Show Gist options
  • Select an option

  • Save ereshzealous/9f5bfe08d81355826fc70a6305dcc742 to your computer and use it in GitHub Desktop.

Select an option

Save ereshzealous/9f5bfe08d81355826fc70a6305dcc742 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