From f0ea027266f0c8fce28ff5e855a12b204ce8df6d Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sat, 9 Nov 2024 19:13:22 +0900 Subject: [PATCH 1/8] =?UTF-8?q?#69=20Feat:=20=EC=98=88=EC=95=BD=20?= =?UTF-8?q?=EC=9A=B0=EC=84=A0=EA=B6=8C=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReservationController.java | 28 ++++++++++ .../converter/ReservationConverter.java | 12 +++++ .../request/ReservationProceedRequest.java | 13 +++++ .../request/ReservationRequest.java | 16 ++++++ .../response/ReservationResponse.java | 27 ++++++++++ .../repository/ReservationRepository.java | 7 +++ .../service/ReservationService.java | 52 +++++++++++++++++++ 7 files changed, 155 insertions(+) create mode 100644 src/main/java/kahlua/KahluaProject/controller/ReservationController.java create mode 100644 src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java create mode 100644 src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java create mode 100644 src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java create mode 100644 src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java create mode 100644 src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java create mode 100644 src/main/java/kahlua/KahluaProject/service/ReservationService.java diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java new file mode 100644 index 0000000..fa3de4a --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -0,0 +1,28 @@ +package kahlua.KahluaProject.controller; + +import kahlua.KahluaProject.dto.reservation.request.ReservationProceedRequest; +import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; +import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; +import kahlua.KahluaProject.service.ReservationService; +import lombok.RequiredArgsConstructor; +import org.springframework.messaging.handler.annotation.*; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequiredArgsConstructor +public class ReservationController { + + private final ReservationService reservationService; + + // 예약 시간 선택한 사람에게 우선권 부여 + @MessageMapping("/reserve.proceed/{date}") + @SendTo("/topic/public/{date}") + public ReservationResponse proceed(@DestinationVariable String reservationDate, + @Header("simpSessionAttributes") Map simpSessionAttributes, + @Payload ReservationProceedRequest reservationProceedRequest) { + + return reservationService.proceed(reservationProceedRequest, reservationDate, simpSessionAttributes); + } +} diff --git a/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java b/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java new file mode 100644 index 0000000..f2d106a --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java @@ -0,0 +1,12 @@ +package kahlua.KahluaProject.converter; + +import kahlua.KahluaProject.domain.reservation.Reservation; +import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; +import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; + +public class ReservationConverter { + + public static ReservationResponse toReservationResponse(Reservation reservation, String email) { + + } +} diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java new file mode 100644 index 0000000..68d3255 --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java @@ -0,0 +1,13 @@ +package kahlua.KahluaProject.dto.reservation.request; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.time.LocalTime; + +public record ReservationProceedRequest( + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + LocalTime startTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + LocalTime endTime +) { +} diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java new file mode 100644 index 0000000..78e3586 --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java @@ -0,0 +1,16 @@ +package kahlua.KahluaProject.dto.reservation.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import kahlua.KahluaProject.domain.reservation.ReservationType; + +import java.time.LocalTime; + +public record ReservationRequest( + ReservationType type, + String clubroomUsername, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + LocalTime startTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + LocalTime endTime +) { +} diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java b/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java new file mode 100644 index 0000000..fa5ab2f --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java @@ -0,0 +1,27 @@ +package kahlua.KahluaProject.dto.reservation.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import kahlua.KahluaProject.domain.reservation.ReservationStatus; +import kahlua.KahluaProject.domain.reservation.ReservationType; +import lombok.Builder; + +import java.time.LocalDate; +import java.time.LocalTime; + +@Builder +public record ReservationResponse( + Long reservationId, + String email, + ReservationType type, + String clubroomUsername, + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") + LocalDate reservationDate, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + LocalTime startTime, + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + LocalTime endTime, + + ReservationStatus status +) { +} diff --git a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java new file mode 100644 index 0000000..d1c9e8f --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java @@ -0,0 +1,7 @@ +package kahlua.KahluaProject.repository; + +import kahlua.KahluaProject.domain.reservation.Reservation; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReservationRepository extends JpaRepository { +} diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java new file mode 100644 index 0000000..ad31e29 --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -0,0 +1,52 @@ +package kahlua.KahluaProject.service; + +import kahlua.KahluaProject.converter.ReservationConverter; +import kahlua.KahluaProject.domain.reservation.Reservation; +import kahlua.KahluaProject.domain.reservation.ReservationStatus; +import kahlua.KahluaProject.dto.reservation.request.ReservationProceedRequest; +import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; +import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; +import kahlua.KahluaProject.repository.ReservationRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; + +@Service +@RequiredArgsConstructor +public class ReservationService { + + private final ReservationRepository reservationRepository; + + public ReservationResponse proceed(ReservationProceedRequest reservationProceedRequest, String reservationDate, Map header) { + + String email = getValueFromHeader(header, "email"); + + return ReservationResponse.builder() + .email(email) + .reservationDate(toLocalDate(reservationDate)) + .startTime(reservationProceedRequest.startTime()) + .endTime(reservationProceedRequest.endTime()) + .status(ReservationStatus.PROCEEDING) + .build(); + } + + // String to LocalDateTime + private LocalDate toLocalDate(String date) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + return LocalDate.parse(date, formatter); + } + + private ReservationResponse toReservationResponse(Reservation reservation, Map header) { + String email = getValueFromHeader(header, "email"); + + return ReservationConverter.toReservationResponse(reservation, email); + } + + private String getValueFromHeader(Map header, String key) { + return (String)header.get(key); + } + +} From 413cd0962fe8fc2abbde799ac221c71baf5541df Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sat, 9 Nov 2024 19:29:09 +0900 Subject: [PATCH 2/8] =?UTF-8?q?#69=20Feat:=20=EC=98=88=EC=95=BD=20?= =?UTF-8?q?=ED=99=95=EC=A0=95=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReservationController.java | 10 +++++++ .../converter/ReservationConverter.java | 28 +++++++++++++++++++ .../service/ReservationService.java | 23 +++++++++++---- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java index fa3de4a..bbcf037 100644 --- a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -25,4 +25,14 @@ public ReservationResponse proceed(@DestinationVariable String reservationDate, return reservationService.proceed(reservationProceedRequest, reservationDate, simpSessionAttributes); } + + // 예약 확정 후 예약내역 DB에 저장 + @MessageMapping("/reserve.complete/{date}") + @SendTo("/topic/public/{date}") + public ReservationResponse complete(@DestinationVariable String reservationDate, + @Header("simpSessionAttributes") Map simpSessionAttributes, + @Payload ReservationRequest reservationRequest) { + + return reservationService.save(reservationRequest, reservationDate, simpSessionAttributes); + } } diff --git a/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java b/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java index f2d106a..19c9a50 100644 --- a/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java +++ b/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java @@ -1,12 +1,40 @@ package kahlua.KahluaProject.converter; import kahlua.KahluaProject.domain.reservation.Reservation; +import kahlua.KahluaProject.domain.reservation.ReservationStatus; +import kahlua.KahluaProject.domain.user.User; import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; +import java.time.LocalDate; + public class ReservationConverter { + + public static Reservation toReservation(ReservationRequest reservationRequest, User user, LocalDate reservationDate, ReservationStatus status) { + + return Reservation.builder() + .user(user) + .type(reservationRequest.type()) + .clubRoomUsername(reservationRequest.clubroomUsername()) + .reservationDate(reservationDate) + .startTime(reservationRequest.startTime()) + .endTime(reservationRequest.endTime()) + .status(status) + .build(); + } public static ReservationResponse toReservationResponse(Reservation reservation, String email) { + return ReservationResponse.builder() + .reservationId(reservation.getId()) + .email(email) + .type(reservation.getType()) + .reservationDate(reservation.getReservationDate()) + .startTime(reservation.getStartTime()) + .endTime(reservation.getEndTime()) + .status(reservation.getStatus()) + .build(); + + } } diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java index ad31e29..0f5de0f 100644 --- a/src/main/java/kahlua/KahluaProject/service/ReservationService.java +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -1,8 +1,10 @@ package kahlua.KahluaProject.service; +import jakarta.transaction.Transactional; import kahlua.KahluaProject.converter.ReservationConverter; import kahlua.KahluaProject.domain.reservation.Reservation; import kahlua.KahluaProject.domain.reservation.ReservationStatus; +import kahlua.KahluaProject.domain.user.User; import kahlua.KahluaProject.dto.reservation.request.ReservationProceedRequest; import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; @@ -14,11 +16,14 @@ import java.time.format.DateTimeFormatter; import java.util.Map; +import static kahlua.KahluaProject.converter.ReservationConverter.*; + @Service @RequiredArgsConstructor public class ReservationService { private final ReservationRepository reservationRepository; + private final UserService userService; public ReservationResponse proceed(ReservationProceedRequest reservationProceedRequest, String reservationDate, Map header) { @@ -33,18 +38,24 @@ public ReservationResponse proceed(ReservationProceedRequest reservationProceedR .build(); } + @Transactional + public ReservationResponse save(ReservationRequest reservationRequest, String reservationDate, Map header) { + + String email = getValueFromHeader(header, "email"); + User user = userService.getUserByEmail(email); + + Reservation reservation = toReservation(reservationRequest, user, toLocalDate(reservationDate), ReservationStatus.RESERVED); + Reservation savedReservation = reservationRepository.save(reservation); + + return toReservationResponse(savedReservation, email); + } + // String to LocalDateTime private LocalDate toLocalDate(String date) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); return LocalDate.parse(date, formatter); } - private ReservationResponse toReservationResponse(Reservation reservation, Map header) { - String email = getValueFromHeader(header, "email"); - - return ReservationConverter.toReservationResponse(reservation, email); - } - private String getValueFromHeader(Map header, String key) { return (String)header.get(key); } From 7feca51b7e0b9985ba43acea671728b0f1e15d81 Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sun, 10 Nov 2024 02:37:03 +0900 Subject: [PATCH 3/8] =?UTF-8?q?#69=20Feat:=20=EB=82=A0=EC=A7=9C=EB=B3=84?= =?UTF-8?q?=20=EC=98=88=EC=95=BD=EB=82=B4=EC=97=AD=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReservationController.java | 17 +++++++++++++++++ .../converter/ReservationConverter.java | 1 + .../request/ReservationProceedRequest.java | 4 ++-- .../reservation/request/ReservationRequest.java | 4 ++-- .../response/ReservationListResponse.java | 11 +++++++++++ .../response/ReservationResponse.java | 11 ++++++++++- .../repository/ReservationRepository.java | 5 +++++ .../service/ReservationService.java | 16 ++++++++++++++++ 8 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationListResponse.java diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java index bbcf037..d0a1f2d 100644 --- a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -1,15 +1,24 @@ package kahlua.KahluaProject.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import kahlua.KahluaProject.apipayload.ApiResponse; import kahlua.KahluaProject.dto.reservation.request.ReservationProceedRequest; import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; +import kahlua.KahluaProject.dto.reservation.response.ReservationListResponse; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; import kahlua.KahluaProject.service.ReservationService; import lombok.RequiredArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.messaging.handler.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDate; import java.util.Map; +@Tag(name = "동방 예약", description = "동방 예약 기능 관련 API") @RestController @RequiredArgsConstructor public class ReservationController { @@ -35,4 +44,12 @@ public ReservationResponse complete(@DestinationVariable String reservationDate, return reservationService.save(reservationRequest, reservationDate, simpSessionAttributes); } + + @GetMapping("/v1/reservation") + @Operation(summary = "날짜별 예약내역 목록 조회", description = "지정한 날짜에 해당하는 예약내역 목록을 조회합니다." + + "
쿼리 파라미터 날짜 형식은 yyyy-MM-dd 입니다") + public ApiResponse getReservationListByDate(@RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { + + return ApiResponse.onSuccess(reservationService.getByDate(date)); + } } diff --git a/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java b/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java index 19c9a50..71d4f97 100644 --- a/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java +++ b/src/main/java/kahlua/KahluaProject/converter/ReservationConverter.java @@ -29,6 +29,7 @@ public static ReservationResponse toReservationResponse(Reservation reservation, .reservationId(reservation.getId()) .email(email) .type(reservation.getType()) + .clubroomUsername(reservation.getClubRoomUsername()) .reservationDate(reservation.getReservationDate()) .startTime(reservation.getStartTime()) .endTime(reservation.getEndTime()) diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java index 68d3255..7cbb4a2 100644 --- a/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationProceedRequest.java @@ -5,9 +5,9 @@ import java.time.LocalTime; public record ReservationProceedRequest( - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "Asia/Seoul") LocalTime startTime, - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "Asia/Seoul") LocalTime endTime ) { } diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java index 78e3586..0b996ec 100644 --- a/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/request/ReservationRequest.java @@ -8,9 +8,9 @@ public record ReservationRequest( ReservationType type, String clubroomUsername, - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "Asia/Seoul") LocalTime startTime, - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "Asia/Seoul") LocalTime endTime ) { } diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationListResponse.java b/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationListResponse.java new file mode 100644 index 0000000..82df59c --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationListResponse.java @@ -0,0 +1,11 @@ +package kahlua.KahluaProject.dto.reservation.response; + +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.List; + +public record ReservationListResponse( + @Schema(description = "예약내역 목록") + List reservationResponseList +) { +} diff --git a/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java b/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java index fa5ab2f..f65013b 100644 --- a/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java +++ b/src/main/java/kahlua/KahluaProject/dto/reservation/response/ReservationResponse.java @@ -1,6 +1,7 @@ package kahlua.KahluaProject.dto.reservation.response; import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; import kahlua.KahluaProject.domain.reservation.ReservationStatus; import kahlua.KahluaProject.domain.reservation.ReservationType; import lombok.Builder; @@ -10,18 +11,26 @@ @Builder public record ReservationResponse( + @Schema(description = "예약 id", example = "1") Long reservationId, + @Schema(description = "예약자 이메일", example = "kahlua@kahlua.com") String email, + @Schema(description = "예약 유형", example = "TEAM") ReservationType type, + @Schema(description = "예약자명", example = "깔루아팀") String clubroomUsername, + @Schema(description = "예약 날짜", example = "2024-01-01") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") LocalDate reservationDate, + @Schema(description = "사용 시작 시간", example = "10:00:00") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") LocalTime startTime, - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul") + @Schema(description = "사용 종료 시간", example = "11:00:00") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm:ss", timezone = "Asia/Seoul") LocalTime endTime, + @Schema(description = "예약 상태", example = "RESERVED") ReservationStatus status ) { } diff --git a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java index d1c9e8f..fdc61d9 100644 --- a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java +++ b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java @@ -3,5 +3,10 @@ import kahlua.KahluaProject.domain.reservation.Reservation; import org.springframework.data.jpa.repository.JpaRepository; +import java.time.LocalDate; +import java.util.List; + public interface ReservationRepository extends JpaRepository { + + List findAllByReservationDate(LocalDate date); } diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java index 0f5de0f..1014d44 100644 --- a/src/main/java/kahlua/KahluaProject/service/ReservationService.java +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -7,6 +7,7 @@ import kahlua.KahluaProject.domain.user.User; import kahlua.KahluaProject.dto.reservation.request.ReservationProceedRequest; import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; +import kahlua.KahluaProject.dto.reservation.response.ReservationListResponse; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; import kahlua.KahluaProject.repository.ReservationRepository; import lombok.RequiredArgsConstructor; @@ -14,7 +15,10 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static kahlua.KahluaProject.converter.ReservationConverter.*; @@ -50,6 +54,18 @@ public ReservationResponse save(ReservationRequest reservationRequest, String re return toReservationResponse(savedReservation, email); } + @Transactional + public ReservationListResponse getByDate(LocalDate date) { + + List reservationList = reservationRepository.findAllByReservationDate(date); + + List reservationResponseList = reservationList.stream() + .map(reservation -> toReservationResponse(reservation, reservation.getUser().getEmail())) + .collect(Collectors.toList()); + + return new ReservationListResponse(reservationResponseList); + } + // String to LocalDateTime private LocalDate toLocalDate(String date) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); From be440ed7f68bad948d2eb9742b3621150a6c9214 Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sun, 10 Nov 2024 03:08:32 +0900 Subject: [PATCH 4/8] =?UTF-8?q?#69=20Feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=98=88=EC=95=BD=EB=82=B4=EC=97=AD=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kahlua/KahluaProject/config/SecurityConfig.java | 1 + .../controller/ReservationController.java | 8 ++++++++ .../repository/ReservationRepository.java | 1 + .../KahluaProject/service/ReservationService.java | 13 +++++++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/kahlua/KahluaProject/config/SecurityConfig.java b/src/main/java/kahlua/KahluaProject/config/SecurityConfig.java index 37b6c0f..a055155 100644 --- a/src/main/java/kahlua/KahluaProject/config/SecurityConfig.java +++ b/src/main/java/kahlua/KahluaProject/config/SecurityConfig.java @@ -51,6 +51,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.authorizeHttpRequests((authorize) -> authorize .requestMatchers( "/api-docs/**", "/swagger-ui/**", "/swagger-ui.html/**", "/v3/api-docs/**", "/swagger-ui/index.html#/**").permitAll() .requestMatchers("/v1/auth/sign-out/**", "v1/auth/recreate/**","/v1/user/**", "/v1/admin/**").authenticated() + .requestMatchers("v1/reservation/**").hasAnyAuthority("KAHLUA", "ADMIN") .anyRequest().permitAll()) .addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class) .addFilterBefore(exceptionFilter, JwtFilter.class); diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java index d0a1f2d..fbee8fc 100644 --- a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -7,10 +7,12 @@ import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; import kahlua.KahluaProject.dto.reservation.response.ReservationListResponse; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; +import kahlua.KahluaProject.security.AuthDetails; import kahlua.KahluaProject.service.ReservationService; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.messaging.handler.annotation.*; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -52,4 +54,10 @@ public ApiResponse getReservationListByDate(@RequestPar return ApiResponse.onSuccess(reservationService.getByDate(date)); } + + @GetMapping("/v1/reservation/check") + public ApiResponse getReservationList(@AuthenticationPrincipal AuthDetails authDetails) { + + return ApiResponse.onSuccess(reservationService.getByUser(authDetails.user())); + } } diff --git a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java index fdc61d9..3f03930 100644 --- a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java +++ b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java @@ -9,4 +9,5 @@ public interface ReservationRepository extends JpaRepository { List findAllByReservationDate(LocalDate date); + List findAllByUser_Id(Long userId); } diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java index 1014d44..298e389 100644 --- a/src/main/java/kahlua/KahluaProject/service/ReservationService.java +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -1,7 +1,6 @@ package kahlua.KahluaProject.service; import jakarta.transaction.Transactional; -import kahlua.KahluaProject.converter.ReservationConverter; import kahlua.KahluaProject.domain.reservation.Reservation; import kahlua.KahluaProject.domain.reservation.ReservationStatus; import kahlua.KahluaProject.domain.user.User; @@ -15,7 +14,6 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -66,6 +64,17 @@ public ReservationListResponse getByDate(LocalDate date) { return new ReservationListResponse(reservationResponseList); } + public ReservationListResponse getByUser(User user) { + + List reservationList = reservationRepository.findAllByUser_Id(user.getId()); + + List reservationResponseList = reservationList.stream() + .map(reservation -> toReservationResponse(reservation, user.getEmail())) + .collect(Collectors.toList()); + + return new ReservationListResponse(reservationResponseList); + } + // String to LocalDateTime private LocalDate toLocalDate(String date) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); From 30952b2bda5813f41e210401410bcb9fff3d013c Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sun, 10 Nov 2024 03:14:59 +0900 Subject: [PATCH 5/8] =?UTF-8?q?#69=20Feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=98=88=EC=95=BD=EB=82=B4=EC=97=AD=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apipayload/code/status/ErrorStatus.java | 5 ++++- .../controller/ReservationController.java | 11 ++++++++--- .../KahluaProject/service/ReservationService.java | 10 ++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/kahlua/KahluaProject/apipayload/code/status/ErrorStatus.java b/src/main/java/kahlua/KahluaProject/apipayload/code/status/ErrorStatus.java index 3259845..fd99574 100644 --- a/src/main/java/kahlua/KahluaProject/apipayload/code/status/ErrorStatus.java +++ b/src/main/java/kahlua/KahluaProject/apipayload/code/status/ErrorStatus.java @@ -44,7 +44,10 @@ public enum ErrorStatus implements BaseCode { WEBSOCKET_SESSION_UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "WEBSOCKET SESSION UNAUTHORIZED", "웹소켓 연결에 실패했습니다."), //게시판 에러 - IMAGE_NOT_UPLOAD(HttpStatus.BAD_REQUEST, "IMAGE_NOT_UPLOAD", "이미지 업로드 개수를 초과하였습니다."); + IMAGE_NOT_UPLOAD(HttpStatus.BAD_REQUEST, "IMAGE_NOT_UPLOAD", "이미지 업로드 개수를 초과하였습니다."), + + // 예약 에러 + RESERVATION_NOT_FOUND(HttpStatus.NOT_FOUND, "RESERVATION NOT FOUND", "예약내역을 찾을 수 없습니다."); private final HttpStatus httpStatus; private final String code; diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java index fbee8fc..e16b591 100644 --- a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -13,9 +13,7 @@ import org.springframework.format.annotation.DateTimeFormat; import org.springframework.messaging.handler.annotation.*; import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.time.LocalDate; import java.util.Map; @@ -60,4 +58,11 @@ public ApiResponse getReservationList(@AuthenticationPr return ApiResponse.onSuccess(reservationService.getByUser(authDetails.user())); } + + @DeleteMapping("/v1/reservation/check/{reservationId}") + public ApiResponse delete(@PathVariable Long reservationId) { + + reservationService.delete(reservationId); + return ApiResponse.onSuccess("예약내역 삭제 성공"); + } } diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java index 298e389..9ff8a55 100644 --- a/src/main/java/kahlua/KahluaProject/service/ReservationService.java +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -1,6 +1,7 @@ package kahlua.KahluaProject.service; import jakarta.transaction.Transactional; +import kahlua.KahluaProject.apipayload.code.status.ErrorStatus; import kahlua.KahluaProject.domain.reservation.Reservation; import kahlua.KahluaProject.domain.reservation.ReservationStatus; import kahlua.KahluaProject.domain.user.User; @@ -8,6 +9,7 @@ import kahlua.KahluaProject.dto.reservation.request.ReservationRequest; import kahlua.KahluaProject.dto.reservation.response.ReservationListResponse; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; +import kahlua.KahluaProject.exception.GeneralException; import kahlua.KahluaProject.repository.ReservationRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -75,6 +77,14 @@ public ReservationListResponse getByUser(User user) { return new ReservationListResponse(reservationResponseList); } + @Transactional + public void delete(Long reservationId) { + Reservation reservation = reservationRepository.findById(reservationId) + .orElseThrow(() -> new GeneralException(ErrorStatus.RESERVATION_NOT_FOUND)); + + reservationRepository.deleteById(reservationId); + } + // String to LocalDateTime private LocalDate toLocalDate(String date) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); From 2d4182462019a475075b21c335cb2384c2f55a5b Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sun, 10 Nov 2024 03:16:40 +0900 Subject: [PATCH 6/8] =?UTF-8?q?#69=20Refactor:=20=EC=8A=A4=EC=9B=A8?= =?UTF-8?q?=EA=B1=B0=20=EC=84=A4=EB=AA=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kahlua/KahluaProject/controller/ReservationController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java index e16b591..70d176f 100644 --- a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -54,12 +54,14 @@ public ApiResponse getReservationListByDate(@RequestPar } @GetMapping("/v1/reservation/check") + @Operation(summary = "사용자 예약내역 조회", description = "사용자의 전체 예약내역을 조회합니다.") public ApiResponse getReservationList(@AuthenticationPrincipal AuthDetails authDetails) { return ApiResponse.onSuccess(reservationService.getByUser(authDetails.user())); } @DeleteMapping("/v1/reservation/check/{reservationId}") + @Operation(summary = "예약내역 삭제", description = "지정한 예약내역을 삭제합니다.") public ApiResponse delete(@PathVariable Long reservationId) { reservationService.delete(reservationId); From 09341b1218e2748796cd12a329afddffa6b2724c Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sun, 10 Nov 2024 03:41:48 +0900 Subject: [PATCH 7/8] =?UTF-8?q?#69=20Refactor:=20=EC=98=88=EC=95=BD?= =?UTF-8?q?=EB=82=B4=EC=97=AD=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?QueryDSL=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReservationController.java | 5 ++- .../repository/ReservationRepository.java | 13 ------- .../ReservationCustomRepository.java | 13 +++++++ .../ReservationCustomRepositoryImpl.java | 39 +++++++++++++++++++ .../reservation/ReservationRepository.java | 7 ++++ .../service/ReservationService.java | 6 +-- 6 files changed, 65 insertions(+), 18 deletions(-) delete mode 100644 src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java create mode 100644 src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepository.java create mode 100644 src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepositoryImpl.java create mode 100644 src/main/java/kahlua/KahluaProject/repository/reservation/ReservationRepository.java diff --git a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java index 70d176f..c69d642 100644 --- a/src/main/java/kahlua/KahluaProject/controller/ReservationController.java +++ b/src/main/java/kahlua/KahluaProject/controller/ReservationController.java @@ -46,7 +46,7 @@ public ReservationResponse complete(@DestinationVariable String reservationDate, } @GetMapping("/v1/reservation") - @Operation(summary = "날짜별 예약내역 목록 조회", description = "지정한 날짜에 해당하는 예약내역 목록을 조회합니다." + + @Operation(summary = "날짜별 예약내역 목록 조회", description = "지정한 날짜에 해당하는 예약내역 목록을 사용 시작 시간 오름차순으로 조회합니다." + "
쿼리 파라미터 날짜 형식은 yyyy-MM-dd 입니다") public ApiResponse getReservationListByDate(@RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { @@ -54,7 +54,8 @@ public ApiResponse getReservationListByDate(@RequestPar } @GetMapping("/v1/reservation/check") - @Operation(summary = "사용자 예약내역 조회", description = "사용자의 전체 예약내역을 조회합니다.") + @Operation(summary = "사용자 예약내역 조회", description = "사용자의 전체 예약내역을 예약 날짜 오름차순으로 조회합니다." + + "
같은 날짜에 대해서는 시작 시간 오름차순으로 정렬합니다.") public ApiResponse getReservationList(@AuthenticationPrincipal AuthDetails authDetails) { return ApiResponse.onSuccess(reservationService.getByUser(authDetails.user())); diff --git a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java b/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java deleted file mode 100644 index 3f03930..0000000 --- a/src/main/java/kahlua/KahluaProject/repository/ReservationRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package kahlua.KahluaProject.repository; - -import kahlua.KahluaProject.domain.reservation.Reservation; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.time.LocalDate; -import java.util.List; - -public interface ReservationRepository extends JpaRepository { - - List findAllByReservationDate(LocalDate date); - List findAllByUser_Id(Long userId); -} diff --git a/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepository.java b/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepository.java new file mode 100644 index 0000000..bbe91de --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepository.java @@ -0,0 +1,13 @@ +package kahlua.KahluaProject.repository.reservation; + +import kahlua.KahluaProject.domain.reservation.Reservation; +import kahlua.KahluaProject.domain.user.User; + +import java.time.LocalDate; +import java.util.List; + +public interface ReservationCustomRepository { + + List findByDate(LocalDate date); + List findByUser(User user); +} diff --git a/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepositoryImpl.java b/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepositoryImpl.java new file mode 100644 index 0000000..98db251 --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationCustomRepositoryImpl.java @@ -0,0 +1,39 @@ +package kahlua.KahluaProject.repository.reservation; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import kahlua.KahluaProject.domain.reservation.Reservation; +import kahlua.KahluaProject.domain.user.User; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +import java.time.LocalDate; +import java.util.List; + +import static kahlua.KahluaProject.domain.reservation.QReservation.reservation; + +@Repository +@RequiredArgsConstructor +public class ReservationCustomRepositoryImpl implements ReservationCustomRepository{ + + private final JPAQueryFactory jpaQueryFactory; + + @Override + public List findByDate(LocalDate date) { + + return jpaQueryFactory + .selectFrom(reservation) + .where(reservation.reservationDate.eq(date)) + .orderBy(reservation.startTime.asc()) + .fetch(); + } + + @Override + public List findByUser(User user) { + + return jpaQueryFactory + .selectFrom(reservation) + .where(reservation.user.eq(user)) + .orderBy(reservation.reservationDate.asc(), reservation.startTime.asc()) + .fetch(); + } +} diff --git a/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationRepository.java b/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationRepository.java new file mode 100644 index 0000000..a519879 --- /dev/null +++ b/src/main/java/kahlua/KahluaProject/repository/reservation/ReservationRepository.java @@ -0,0 +1,7 @@ +package kahlua.KahluaProject.repository.reservation; + +import kahlua.KahluaProject.domain.reservation.Reservation; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReservationRepository extends JpaRepository, ReservationCustomRepository { +} diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java index 9ff8a55..377f120 100644 --- a/src/main/java/kahlua/KahluaProject/service/ReservationService.java +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -10,7 +10,7 @@ import kahlua.KahluaProject.dto.reservation.response.ReservationListResponse; import kahlua.KahluaProject.dto.reservation.response.ReservationResponse; import kahlua.KahluaProject.exception.GeneralException; -import kahlua.KahluaProject.repository.ReservationRepository; +import kahlua.KahluaProject.repository.reservation.ReservationRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -57,7 +57,7 @@ public ReservationResponse save(ReservationRequest reservationRequest, String re @Transactional public ReservationListResponse getByDate(LocalDate date) { - List reservationList = reservationRepository.findAllByReservationDate(date); + List reservationList = reservationRepository.findByDate(date); List reservationResponseList = reservationList.stream() .map(reservation -> toReservationResponse(reservation, reservation.getUser().getEmail())) @@ -68,7 +68,7 @@ public ReservationListResponse getByDate(LocalDate date) { public ReservationListResponse getByUser(User user) { - List reservationList = reservationRepository.findAllByUser_Id(user.getId()); + List reservationList = reservationRepository.findByUser(user); List reservationResponseList = reservationList.stream() .map(reservation -> toReservationResponse(reservation, user.getEmail())) From a9aa2f1430e2867987249d273f3f52a3d7f8274c Mon Sep 17 00:00:00 2001 From: woogieon8on Date: Sat, 16 Nov 2024 11:04:41 +0900 Subject: [PATCH 8/8] =?UTF-8?q?#89=20Feat:=20CANCELED=20status=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KahluaProject/domain/reservation/ReservationStatus.java | 2 +- .../java/kahlua/KahluaProject/service/ReservationService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/kahlua/KahluaProject/domain/reservation/ReservationStatus.java b/src/main/java/kahlua/KahluaProject/domain/reservation/ReservationStatus.java index ece18fc..4666c5c 100644 --- a/src/main/java/kahlua/KahluaProject/domain/reservation/ReservationStatus.java +++ b/src/main/java/kahlua/KahluaProject/domain/reservation/ReservationStatus.java @@ -2,5 +2,5 @@ public enum ReservationStatus { - PROCEEDING, RESERVED, CANCELLED + PROCEEDING, RESERVED } diff --git a/src/main/java/kahlua/KahluaProject/service/ReservationService.java b/src/main/java/kahlua/KahluaProject/service/ReservationService.java index 377f120..40900b8 100644 --- a/src/main/java/kahlua/KahluaProject/service/ReservationService.java +++ b/src/main/java/kahlua/KahluaProject/service/ReservationService.java @@ -82,7 +82,7 @@ public void delete(Long reservationId) { Reservation reservation = reservationRepository.findById(reservationId) .orElseThrow(() -> new GeneralException(ErrorStatus.RESERVATION_NOT_FOUND)); - reservationRepository.deleteById(reservationId); + reservationRepository.delete(reservation); } // String to LocalDateTime