Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created January 17, 2020 07:42
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/f3e0bbd21acb332a787f9fcb7033649f to your computer and use it in GitHub Desktop.
Save ereshzealous/f3e0bbd21acb332a787f9fcb7033649f to your computer and use it in GitHub Desktop.
public Mono<Author> saveAuthor(Author author) {
if (StringUtils.isNotBlank(author.getId())) {
return authorRepository.findByIdAndDeleteIsFalse(author.getId())
.switchIfEmpty(Mono.error(new Exception("No Author found with Id: " + author.getId())))
.doOnSuccess(author1 -> {
author1 = updateAuthor(author, author1);
authorRepository.save(author1)
.subscribe();
});
}
return authorRepository.save(author);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment