diff --git a/src/main/java/com/hanaro/hanafun/reservation/controller/ReservationController.java b/src/main/java/com/hanaro/hanafun/reservation/controller/ReservationController.java index 8fcf120..deaec49 100644 --- a/src/main/java/com/hanaro/hanafun/reservation/controller/ReservationController.java +++ b/src/main/java/com/hanaro/hanafun/reservation/controller/ReservationController.java @@ -6,6 +6,7 @@ import com.hanaro.hanafun.reservation.service.ReservationService; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -18,8 +19,8 @@ public class ReservationController { // 마이페이지 데이터 출력 @GetMapping("/my") - public ResponseEntity myPage(@RequestBody MyPageReqDto myPageReqDto) { - MyPageResDto myPageResDto = reservationService.myPage(myPageReqDto); + public ResponseEntity myPage(@AuthenticationPrincipal Long userId) { + MyPageResDto myPageResDto = reservationService.myPage(userId); return ResponseEntity.ok(new ApiResponse<>(true, "ok", myPageResDto)); } diff --git a/src/main/java/com/hanaro/hanafun/reservation/service/ReservationService.java b/src/main/java/com/hanaro/hanafun/reservation/service/ReservationService.java index 1977b85..bd2f62a 100644 --- a/src/main/java/com/hanaro/hanafun/reservation/service/ReservationService.java +++ b/src/main/java/com/hanaro/hanafun/reservation/service/ReservationService.java @@ -7,7 +7,7 @@ public interface ReservationService { // 마이페이지 데이터 출력 - MyPageResDto myPage(MyPageReqDto myPageReqDto); + MyPageResDto myPage(Long userId); // 나의 신청 클래스 데이터 출력 List myLessons(MyPageReqDto myPageReqDto); diff --git a/src/main/java/com/hanaro/hanafun/reservation/service/impl/ReservationServiceImpl.java b/src/main/java/com/hanaro/hanafun/reservation/service/impl/ReservationServiceImpl.java index ad9dbbd..707a095 100644 --- a/src/main/java/com/hanaro/hanafun/reservation/service/impl/ReservationServiceImpl.java +++ b/src/main/java/com/hanaro/hanafun/reservation/service/impl/ReservationServiceImpl.java @@ -38,8 +38,8 @@ public class ReservationServiceImpl implements ReservationService { // 마이페이지 데이터 출력 @Transactional @Override - public MyPageResDto myPage(MyPageReqDto myPageReqDto) { - UserEntity user = userRepository.findById(myPageReqDto.getUserId()).orElseThrow(() -> new UserNotFoundException()); + public MyPageResDto myPage(Long userId) { + UserEntity user = userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException()); List reservations = reservationRepository.findReservationEntitiesByUserEntity(user); LocalDate today = LocalDate.now(); // 오늘이후 날짜의 예약만 출력