-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : 예약 최종 등록 로직 구현 #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제일 어려운 예약 로직을 모두 구성하시느라 고생하셨습니다!
밑에 리뷰 남겨드린 대로 함께 얘기 나눠보고, 더 나은 코드를 위해 함께 얘기 나눠봐요 ㅎㅎ
|
||
@Transactional | ||
public Reservation validateReservationAndSaveIsEmpty(CreateReservationRequest request) { | ||
ReservationTime reservationTime = reservationTimeRepository.findByIdWithShop( | ||
request.reservationTimeId()). | ||
orElseThrow(() -> new NotFoundCustomException(NOT_EXIST_TIME)); | ||
|
||
if (reservationTime.isOccupied()) { | ||
throw new BadRequestCustomException(ALREADY_OCCUPIED_RESERVATION_TIME); | ||
} | ||
|
||
reservationTime.reverseOccupied(); | ||
|
||
Reservation reservation = Reservation.builder() | ||
.status(COMPLETED) | ||
.peopleCount(request.peopleCount()) | ||
.shop(reservationTime.getShop()) | ||
.reservationTime(reservationTime) | ||
.build(); | ||
return reservationRepository.save(reservation); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최종 예약 요구사항의 흐름대로, 전체적인 로직의 흐름은 잘 구성된 것 같습니다!!
public CreateReservationResponse registerReservation(CreateReservationRequest request) { | ||
Reservation reservation = reservationService.validateReservationAndSaveIsEmpty(request); | ||
return toCreateReservationResponse(reservation); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다만 저는 이 로직을 보면 facade와 service에 역할이 바뀐 것 같다는 느낌이 듭니다!!
더 나은 로직과 구조에 대해서 얘기를 나누어보면 좋을 것 같습니다!
close #32
⛏ 작업 상세 내용
📝 작업 요약
☑️ 중점적으로 리뷰 할 부분