Skip to content
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

Merged
merged 12 commits into from
Jan 2, 2024

Conversation

dlswns2480
Copy link
Member

close #32

⛏ 작업 상세 내용

  • 예약 최종 등록 로직 구현
  • 예약 등록 로직 테스트
    • 정상 등록 테스트
    • 예외 발생 테스트

📝 작업 요약

  • 예약 등록 로직 구현
  • 코드 포맷팅

☑️ 중점적으로 리뷰 할 부분

  • 예약 최종 등록이 선점권을 가진 상태에서 등록 하기 때문에 그 흐름으로 구현하였습니다.
  • 추후에 선점권 api에서 동시성 이슈 제어를 할 예정이라 최종 등록에는 동시성 관련 로직이 없습니다.
  • 이 부분들 고려해서 로직 봐주십쇼~

@dlswns2480 dlswns2480 self-assigned this Jan 1, 2024
@dlswns2480 dlswns2480 changed the title feat feat : 예약 최종 등록 로직 구현 Jan 1, 2024
Copy link

github-actions bot commented Jan 1, 2024

Test Results

 8 files  +1   8 suites  +1   2s ⏱️ -1s
13 tests +3  13 ✅ +3  0 💤 ±0  0 ❌ ±0 
14 runs  +3  14 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit ebf5bee. ± Comparison against base commit ca219e9.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@kkangh00n kkangh00n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제일 어려운 예약 로직을 모두 구성하시느라 고생하셨습니다!

밑에 리뷰 남겨드린 대로 함께 얘기 나눠보고, 더 나은 코드를 위해 함께 얘기 나눠봐요 ㅎㅎ

Comment on lines +38 to +58

@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);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최종 예약 요구사항의 흐름대로, 전체적인 로직의 흐름은 잘 구성된 것 같습니다!!

Comment on lines +38 to +42
public CreateReservationResponse registerReservation(CreateReservationRequest request) {
Reservation reservation = reservationService.validateReservationAndSaveIsEmpty(request);
return toCreateReservationResponse(reservation);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다만 저는 이 로직을 보면 facade와 service에 역할이 바뀐 것 같다는 느낌이 듭니다!!
더 나은 로직과 구조에 대해서 얘기를 나누어보면 좋을 것 같습니다!

@dlswns2480 dlswns2480 merged commit fdc9744 into dev Jan 2, 2024
3 checks passed
@dlswns2480 dlswns2480 linked an issue Jan 2, 2024 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

feature : 예약 최종 등록 로직 설계
3 participants