Created
September 25, 2022 08:24
-
-
Save FindZach/8af937d2122d699c2cf1229f4f5b10fc to your computer and use it in GitHub Desktop.
tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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