From 650abd35a305c39a2a8f55755187665d9849725f Mon Sep 17 00:00:00 2001 From: limjihoon99 Date: Wed, 29 Nov 2023 21:52:59 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=A0=84=EC=B2=B4=20=EC=98=88=EC=95=BD?= =?UTF-8?q?=20=EB=82=B4=EC=97=AD=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reservation/controller/ReservationController.java | 7 +++++++ .../backend/reservation/dto/ReservationResponse.java | 2 -- .../backend/reservation/service/ReservationService.java | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/backend/backend/reservation/controller/ReservationController.java b/backend/src/main/java/backend/backend/reservation/controller/ReservationController.java index bca91f51..ce2a31e8 100644 --- a/backend/src/main/java/backend/backend/reservation/controller/ReservationController.java +++ b/backend/src/main/java/backend/backend/reservation/controller/ReservationController.java @@ -36,6 +36,13 @@ public ResponseEntity> getReservationsByUserId() { return ResponseEntity.ok(reservations); } + //전체 예약 내역 조회 + @GetMapping("/all") + public ResponseEntity> getAllReservations() { + List allReservations = reservationService.getAllReservations(); + return ResponseEntity.ok(allReservations); + } + //예약 취소 @DeleteMapping("/{reservationId}") public ResponseEntity cancelReservation(@PathVariable Long reservationId) { diff --git a/backend/src/main/java/backend/backend/reservation/dto/ReservationResponse.java b/backend/src/main/java/backend/backend/reservation/dto/ReservationResponse.java index 4dea7b51..79139bde 100644 --- a/backend/src/main/java/backend/backend/reservation/dto/ReservationResponse.java +++ b/backend/src/main/java/backend/backend/reservation/dto/ReservationResponse.java @@ -4,8 +4,6 @@ import lombok.Getter; import lombok.Setter; -import java.time.LocalDateTime; - @Getter @Setter public class ReservationResponse { diff --git a/backend/src/main/java/backend/backend/reservation/service/ReservationService.java b/backend/src/main/java/backend/backend/reservation/service/ReservationService.java index 7238ee63..fa2a38ab 100644 --- a/backend/src/main/java/backend/backend/reservation/service/ReservationService.java +++ b/backend/src/main/java/backend/backend/reservation/service/ReservationService.java @@ -96,6 +96,13 @@ public List getReservationsByUserId(Long userId) { .collect(Collectors.toList()); } + public List getAllReservations() { + List allReservations = reservationRepository.findAll(); + return allReservations.stream() + .map(this::convertToResponse) + .collect(Collectors.toList()); + } + public boolean cancelReservation(Long reservationId) { Long userId = (long) session.getAttribute("userId"); User user = userService.findById(userId);