From e1c148e48266a92a985fd16ecedd7bfbf323112a Mon Sep 17 00:00:00 2001 From: yubin-im Date: Wed, 3 Jul 2024 09:56:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=B6=9C=EB=A0=A5=20userId->=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=20=EB=B0=9B=EC=95=84=EC=98=A4=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reservation/controller/ReservationController.java | 5 +++-- .../hanafun/reservation/service/ReservationService.java | 2 +- .../reservation/service/impl/ReservationServiceImpl.java | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) 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(); // 오늘이후 날짜의 예약만 출력