Skip to content

Commit

Permalink
Feat: 전체 예약 내역 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
limjihoon99 committed Nov 29, 2023
1 parent 4214177 commit 650abd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public ResponseEntity<List<ReservationResponse>> getReservationsByUserId() {
return ResponseEntity.ok(reservations);
}

//전체 예약 내역 조회
@GetMapping("/all")
public ResponseEntity<List<ReservationResponse>> getAllReservations() {
List<ReservationResponse> allReservations = reservationService.getAllReservations();
return ResponseEntity.ok(allReservations);
}

//예약 취소
@DeleteMapping("/{reservationId}")
public ResponseEntity<String> cancelReservation(@PathVariable Long reservationId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
public class ReservationResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public List<ReservationResponse> getReservationsByUserId(Long userId) {
.collect(Collectors.toList());
}

public List<ReservationResponse> getAllReservations() {
List<Reservation> 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);
Expand Down

0 comments on commit 650abd3

Please sign in to comment.