From 3ed16046f8119f33e68c61dc9b909e098ff25f32 Mon Sep 17 00:00:00 2001 From: nuyh Date: Thu, 20 Jul 2023 18:02:27 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=96=B4=EB=93=9C=EB=AF=BC=EC=9A=A9=20?= =?UTF-8?q?=ED=82=A4=EC=9B=8C=EB=93=9C=EB=B3=84=20=EC=B6=94=EC=B2=9C=20?= =?UTF-8?q?=ED=8F=AC=EC=8A=A4=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1397 --- .../roadmap/ui/RecommendedController.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 backend/src/main/java/wooteco/prolog/roadmap/ui/RecommendedController.java diff --git a/backend/src/main/java/wooteco/prolog/roadmap/ui/RecommendedController.java b/backend/src/main/java/wooteco/prolog/roadmap/ui/RecommendedController.java new file mode 100644 index 000000000..6838624d3 --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/RecommendedController.java @@ -0,0 +1,43 @@ +package wooteco.prolog.roadmap.ui; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import wooteco.prolog.roadmap.application.RecommendedService; +import wooteco.prolog.roadmap.application.dto.RecommendedRequest; +import wooteco.prolog.roadmap.application.dto.RecommendedUpdateRequest; + +import java.net.URI; + +@RestController +@RequestMapping("/keywords/{keywordId}/recommended-posts") +public class RecommendedController { + + private final RecommendedService recommendedService; + + public RecommendedController(final RecommendedService recommendedService) { + this.recommendedService = recommendedService; + } + + @PostMapping + public ResponseEntity createRecommendedPost(@PathVariable("keywordId") Long keywordId, + @RequestBody RecommendedRequest request) { + final Long id = recommendedService.create(keywordId, request); + return ResponseEntity.created( + URI.create("/keywords/" + keywordId + "/recommended-posts/" + id)).build(); + } + + @PutMapping("/{recommendedId}") + public ResponseEntity updateRecommendedPost(@PathVariable("keywordId") Long keywordId, + @PathVariable("recommendedId") Long recommendedId, + @RequestBody RecommendedUpdateRequest request) { + recommendedService.update(recommendedId, request); + return ResponseEntity.ok().build(); + } + + @DeleteMapping("/{recommendedId}") + public ResponseEntity deleteRecommendedPost(@PathVariable("keywordId") Long keywordId, + @PathVariable("recommendedId") Long recommendedId) { + recommendedService.delete(recommendedId); + return ResponseEntity.noContent().build(); + } +}