Skip to content

Comments

[BE] 리뷰 리팩토링#316

Merged
jihaneol merged 2 commits intodevelopfrom
be/feat/315
Apr 21, 2025
Merged

[BE] 리뷰 리팩토링#316
jihaneol merged 2 commits intodevelopfrom
be/feat/315

Conversation

@jihaneol
Copy link
Contributor

  • 디미터 법칙 적용
  • 묻지 말고 시켜라
  • 중복 리뷰 좋아요 개선
  • 리뷰 좋아요 테스트 코드 작성
  • 리뷰 확인 테스트 코드 작성

🔗 Resolves: #315


🚀 어떤 기능을 구현했나요 ?

  • 디미터 법칙, 묻지말고 시켜라, 테스트 코드 작성

🔥 어떤 문제를 마주했나요 ?

기존 productsummary 생성 부분에서 service에서 option null 인지 판별하는 역할을 넘는 행위를 하고 있었다.
entity와 같은 값은 어쩔 수 없이 값을 알기 위해 get.get.을 해야 하지만 if 문으로 service에서 처리하는 것은
프론트에서 보여줄 값이 늘어나면 불필요한 service에 변경이 가해지므로 책임을 orderDetail과 saleProduct에 전가했다.

✨ 어떻게 해결했나요 ?

📝 어떤 부분에 집중해서 리뷰해야 할까요?

📚 참고 자료 및 회고

- 디미터 법칙 적용
- 묻지 말고 시켜라
- 중복 리뷰 좋아요 개선
- 리뷰 좋아요 테스트 코드 작성
- 리뷰 확인 테스트 코드 작성

🔗 Resolves: #315
REVIEW_DUPLICATE(HttpStatus.CONFLICT, "이미 리뷰를 작성했습니다."),
RATING_OUT_OF_RANGE(HttpStatus.BAD_REQUEST, "별점은 1~5점을 해야한다."),
REVIEW_NOT_FOUND(HttpStatus.BAD_REQUEST, "작성하신 리뷰가 없습니다."),
ALLREADY_LIVIEW_LIKED(HttpStatus.CONFLICT, "이미 리뷰 좋아요를 했습니다."),
Copy link
Contributor

Choose a reason for hiding this comment

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

오타가 있습니다! L이 두번 들어가있어요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

고쳤습니다!

}

public String getProductSummary() {
return saleProduct.getProductSummary(quantity);
Copy link
Contributor

Choose a reason for hiding this comment

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

리뷰 작성을 할때 필요한 상품 정보를 가져오는 메서드인가요? quantity를 보내는 이유가 궁금합니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리뷰 작성할때 상품 요약으로 상품명/수량/옵션을 나타내는 것입니다.
리뷰를 가져올때 불필요한 조인으로 옵션과 수량 상품명을 갖고 오지 않으려고 만들어 놨습니다.

주문에서 quantity를 판매 상품에 보내는 이유는 saleproduct에 있는 데이터와 수량을 갖고 productsummary를 반환해 줍니다.

기존에 이 로직이 리뷰 서비스에서 해주었습니다. 지금 구조로 가져간다면 상품 요약이 변경 되었을때
사이 임팩트로 서비스까지 변경이 될 부분이 사라질 수 있어서 이렇게 만들어 보았습니다.

- 오타 수정

🔗 Resolves: #315
@jihaneol jihaneol merged commit b8ce026 into develop Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants