-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b44d3d
commit 2225160
Showing
5 changed files
with
60 additions
and
16 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/main/java/com/wap/cano_be/controller/LikeController.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.wap.cano_be.controller; | ||
|
||
import com.wap.cano_be.domain.PrincipalDetail; | ||
import com.wap.cano_be.service.impl.LikeService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class LikeController { | ||
private final LikeService likeService; | ||
|
||
public LikeController(LikeService likeService) { | ||
this.likeService = likeService; | ||
} | ||
|
||
// 좋아요 등록 | ||
@PostMapping("/{menu_id}/like") | ||
public ResponseEntity<?> like( | ||
@PathVariable("menu_id") long menuId, | ||
@AuthenticationPrincipal PrincipalDetail principalDetail){ | ||
return likeService.insert(principalDetail.getMember().getId(), menuId); | ||
} | ||
|
||
// [TEST] 좋아요 한 메뉴 조회 | ||
@GetMapping("/likes/me") | ||
public ResponseEntity<?> getLikes( | ||
@AuthenticationPrincipal PrincipalDetail principalDetail | ||
) { | ||
return likeService.getLikedMenus(principalDetail.getMember().getId()); | ||
} | ||
|
||
// 좋아요 취소 | ||
@DeleteMapping("/{menu_id}/like") | ||
public ResponseEntity<?> unlike( | ||
@PathVariable("menu_id") long menuId, | ||
@AuthenticationPrincipal PrincipalDetail principalDetail){ | ||
return likeService.delete(principalDetail.getMember().getId(), menuId); | ||
} | ||
} |
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
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
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
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