Skip to content

Instantly share code, notes, and snippets.

@FindZach
Created September 25, 2022 08:24
Show Gist options
  • Save FindZach/8af937d2122d699c2cf1229f4f5b10fc to your computer and use it in GitHub Desktop.
Save FindZach/8af937d2122d699c2cf1229f4f5b10fc to your computer and use it in GitHub Desktop.
tester
@GetMapping("/tutorial/{slug}")
public ResponseEntity<TutorialDTO> getTutorialBySlug(@PathVariable String slug) {
log.info("Slug read: " + slug);
Optional<Tutorial> possibleTutorial = Optional.ofNullable(tutorialService.getTutorialBySlug(slug));
if (possibleTutorial.isPresent()) {
log.info("Found " + possibleTutorial.get().getTitle());
} else {
log.info("Unable to find tutorial by the slug");
}
TutorialDTO newTut = new TutorialDTO();
newTut.setSlug(slug);
newTut.setTitle(possibleTutorial.get().getTitle());
newTut.setDescription(possibleTutorial.get().getDescription());
newTut.setContent(possibleTutorial.get().getContent());
//newTut.setUse(String.valueOf(possibleTutorial.get().getUser().getId()));
newTut.setCreationDate(possibleTutorial.get().getCreationDate());
return ResponseEntity.ok().body(newTut);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment