From 6670ab7fb7eece5482fff9ba679bb7bdd71005ba Mon Sep 17 00:00:00 2001 From: Zoonmy Date: Fri, 25 Oct 2024 17:43:08 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20like=20delete=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/hyundai/blog/like/controller/LikeController.java | 6 ++++-- .../main/java/hyundai/blog/like/service/LikeService.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BE/Blog/src/main/java/hyundai/blog/like/controller/LikeController.java b/BE/Blog/src/main/java/hyundai/blog/like/controller/LikeController.java index 698981e..9bba9af 100644 --- a/BE/Blog/src/main/java/hyundai/blog/like/controller/LikeController.java +++ b/BE/Blog/src/main/java/hyundai/blog/like/controller/LikeController.java @@ -9,8 +9,10 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -29,9 +31,9 @@ public ResponseEntity saveLike( @DeleteMapping("/like") public ResponseEntity deleteLike( - @RequestBody LikeCreateRequest request + @PathVariable Long tilId ) { - LikeDeleteResponse likeDeleteResponse = likeService.delete(request); + LikeDeleteResponse likeDeleteResponse = likeService.delete(tilId); return ResponseEntity.ok(likeDeleteResponse); } diff --git a/BE/Blog/src/main/java/hyundai/blog/like/service/LikeService.java b/BE/Blog/src/main/java/hyundai/blog/like/service/LikeService.java index 70f4b25..159d6fa 100644 --- a/BE/Blog/src/main/java/hyundai/blog/like/service/LikeService.java +++ b/BE/Blog/src/main/java/hyundai/blog/like/service/LikeService.java @@ -60,12 +60,12 @@ public LikeCreateResponse save(LikeCreateRequest request) { } @Transactional - public LikeDeleteResponse delete(LikeCreateRequest request) { + public LikeDeleteResponse delete(Long tilId) { // 1) 현재 로그인 된 멤버의 ID를 가져온다. Member loggedInMember = memberResolver.getCurrentMember(); // 2) tilRepo에서 requestTilId에 해당하는 til 조회 - Til til = tilRepository.findById(request.getTilId()) + Til til = tilRepository.findById(tilId) .orElseThrow(TilIdNotFoundException::new);