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 : 웨이팅 생성 로직 구현 #26

Merged
merged 13 commits into from
Dec 31, 2023
Merged

feat : 웨이팅 생성 로직 구현 #26

merged 13 commits into from
Dec 31, 2023

Conversation

hyun2371
Copy link
Member

@hyun2371 hyun2371 commented Dec 28, 2023

⛏ 작업 상세 내용

  • 웨이팅 고유 번호, 웨이팅 순서 필드 추가

    • 서비스 로직 내에서 두 필드 값 대입

    • 필드 추가에 따른 API 응답 수정

      {
          "shopName" : "shop1",
          "waitingNumber" : 133,
          "waitingOrder" : 23
          "memberName" : "member1",
          "date" : "2023-12-31 19:12",
          "peopleCount" : 4
      }
  • 가게 영업 시간 필드 추가

    • 영업 시간 검증 코드 및 테스트 코드 추가
  • 서비스, 레포지토리 테스트 코드 작성

  • restDocs 생성을 위한 컨트롤러 단위 테스트 작성

  • baseEntity 필드명 수정

📝 작업 요약

  • 웨이팅 생성 API 구현 (동시성 제어는 추후 구현 예정)

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

  • 비즈니스 로직
  • 테스트 로직

@hyun2371 hyun2371 self-assigned this Dec 28, 2023
Copy link

github-actions bot commented Dec 28, 2023

Test Results

 7 files  +4   7 suites  +4   3s ⏱️ +2s
10 tests +5  10 ✅ +5  0 💤 ±0  0 ❌ ±0 
11 runs  +6  11 ✅ +6  0 💤 ±0  0 ❌ ±0 

Results for commit 7df18a6. ± Comparison against base commit 492d637.

♻️ This comment has been updated with latest results.

@hyun2371 hyun2371 changed the title feat : 대기 생성 로직 구현 feat : 웨이팅 생성 로직 구현 Dec 28, 2023
@hyun2371 hyun2371 requested review from kkangh00n and dlswns2480 and removed request for kkangh00n December 28, 2023 08:52
Copy link
Member

@dlswns2480 dlswns2480 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~
리뷰 보고 답글 남겨주세요😃

ALREADY_CANCELED_WAITING("이미 웨이팅을 취소하였습니다."),
EXISTING_MEMBER_WAITING("이미 회원이 웨이팅 중인 가게가 존재합니다."),
SHOP_NOT_RUNNING("가게가 영업시간이 아닙니다."),
INTERNAL_SERVER_ERROR("내부 서버 오류입니다.");
Copy link
Member

Choose a reason for hiding this comment

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

이 서버에러 메세지는 어떤 경우에 쓰일까요??

Copy link
Member Author

Choose a reason for hiding this comment

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

ExceptionHandler 구현 시 기타 Exception을 handling할 때 사용하려고 했습니다!

Comment on lines +11 to +12
int waitingNumber,
int waitingOrder
Copy link
Member

Choose a reason for hiding this comment

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

api 스펙 바뀐것은 pr 내용에도 넣어주시면 감사하겠습니다!
근데 이 둘이 각각 정확히 어떤 걸 의미하는건가요??

Copy link
Member Author

Choose a reason for hiding this comment

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

PR 수정했습니다~
waitingNumber는 웨이팅 고유 번호(불변)이고, waitingOrder는 웨이팅 순서(멤버 입장에 따라 1씩 차감)입니다!

Comment on lines 20 to 30
public Member getMemberEntity(Long memberId){
return memberRepository.findById(memberId).orElseThrow(
()-> new NotFoundCustomException(NOT_EXIST_MEMBER)
);
}

public Shop getShopEntity(Long shopId){
return shopRepository.findById(shopId).orElseThrow(
() -> new NotFoundCustomException(NOT_EXIST_SHOP)
);
}
Copy link
Member

Choose a reason for hiding this comment

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

퍼사드 클래스인데 각 메소드에서 존재여부만 파악해서 여러 로직을 조립하는 과정이 없는데 퍼사드인 이유가 있을까요?? 즉, 퍼사드를 사용하는 측에서 shop의 존재여부를 알고 싶어 호출을 하면 여기선 하위 시스템들을 호출, 조립하여 응답을 하는게 아니라 여기서도 존재여부 결과만 리턴해주는 것 같습니다!
그리고 회원이 로그인을 통해 들어오는데 회원의 존재여부를 파악할 필요가 있을까요??

Comment on lines 30 to 31
Member member = waitingFacade.getMemberEntity(1L);
Shop shop = waitingFacade.getShopEntity(shopId);
Copy link
Member

Choose a reason for hiding this comment

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

이 부분에서 퍼사드를 사용하는 부분이 같은 클래스내에서 로직을 메소드로 따로 빼는거랑 어떤 차이가 있는건지 잘 모르겠습니다!

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.

고생하셨습니다!! 퍼사드 패턴에 대해 비슷한 견해가 나온만큼 더 나은 코드가 무엇인지 주고 받는 함께 토론해보면 좋을 것 같아요 :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

단순 변수명 변경이기에, 커밋 유형이 style이면 어떨까 싶습니다~

Comment on lines 30 to 49
Member member = waitingFacade.getMemberEntity(1L); //member, shop 아이디 임시 1L
Shop shop = waitingFacade.getShopEntity(shopId);

// shop 영업 중인지 검증
shop.validateIfShopOpened(LocalTime.now());

// 기존 waiting이 있는지 검증
validateIfMemberWaitingExists(member);

// 대기 번호 생성
int waitingNumber = (waitingRepository.countByShopAndStatusAndCreatedAtBetween(shop,
PROGRESS, START_DATE_TIME, END_DATE_TIME)).intValue()+1;

// 대기 순서 생성
int waitingOrder = (waitingRepository.countByShopAndCreatedAtBetween(shop,
START_DATE_TIME, END_DATE_TIME)).intValue()+1;

// waiting 저장
Waiting waiting = WaitingMapper.toWaiting(request, waitingNumber, waitingOrder, member, shop);
Waiting savedWaiting = waitingRepository.save(waiting);
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에 있는 이 로직들이 Facade에 들어가야 된다고 생각합니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

넵! 퍼사드 패턴에 대해 더 공부한 다음 수정해보겠습니다!

@hyun2371 hyun2371 merged commit 2083838 into dev Dec 31, 2023
3 checks passed
@hyun2371 hyun2371 linked an issue Jan 17, 2024 that may be closed by this pull request
2 tasks
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