|
8 | 8 | import com.ll.commars.global.rsData.RsData; |
9 | 9 | import io.swagger.v3.oas.annotations.Operation; |
10 | 10 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | +import jakarta.servlet.http.HttpServletRequest; |
11 | 12 | import lombok.RequiredArgsConstructor; |
12 | 13 | import org.springframework.http.ResponseEntity; |
13 | 14 | import org.springframework.security.core.annotation.AuthenticationPrincipal; |
@@ -88,15 +89,28 @@ public ResponseEntity<?> createFavoriteList( |
88 | 89 | @Operation(summary = "사용자의 찜 목록에 식당이 존재하는지 확인") |
89 | 90 | public ResponseEntity<Map<String, Boolean>> isFavorite( |
90 | 91 | @RequestParam(name = "restaurantId") Long restaurantId, |
| 92 | +// @RequestParam Long restaurantId, |
91 | 93 | @AuthenticationPrincipal UserDetails userDetails |
92 | 94 | ) { |
93 | 95 | if (userDetails == null) { |
94 | 96 | throw new IllegalArgumentException("UserDetails is null. Authentication failed."); |
95 | 97 | } |
96 | | - |
97 | 98 | User user = userService.findByEmail(userDetails.getUsername()) |
98 | 99 | .orElseThrow(() -> new IllegalArgumentException("User not found")); |
| 100 | + boolean isFavorite = favoriteService.isFavorite(user, 1L); |
| 101 | + Map<String, Boolean> response = new HashMap<>(); |
| 102 | + response.put("isFavorite", isFavorite); |
| 103 | + return ResponseEntity.ok(response); |
| 104 | + } |
99 | 105 |
|
| 106 | + @GetMapping("/check") |
| 107 | + @Operation(summary = "찜 목록에 식당이 존재하는지 확인") |
| 108 | + public ResponseEntity<?> checkFavorite( |
| 109 | + @RequestParam("restaurantId") Long restaurantId, |
| 110 | + @AuthenticationPrincipal UserDetails userDetails |
| 111 | + ) { |
| 112 | + User user = userService.findById(Long.parseLong(userDetails.getUsername())) |
| 113 | + .orElseThrow(() -> new IllegalArgumentException("User not found")); |
100 | 114 | boolean isFavorite = favoriteService.isFavorite(user, restaurantId); |
101 | 115 | Map<String, Boolean> response = new HashMap<>(); |
102 | 116 | response.put("isFavorite", isFavorite); |
|
0 commit comments