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 : Review Service 빌더패턴 적용 마이페이지 분리 #61

Merged

Conversation

peacefullyquietly
Copy link
Contributor

  • reviewService에서 이전에 추가한 빌더 패턴을 활용하게끔 수정하였습니다.
  • 이전에는 review로 GET 요청 시, 마이페이지 여부를 searchByUser 필드로 구분하였으나, 가독성이 떨어지고 토큰이 불필요하게 남용된다고 판단됐습니다. 따라서 기존 '/api/reviews'를 전체 리뷰 조회와 마이페이지 조회('/api/reviews/my')로 분리하여, 마이페이지에서만 토큰 활용이 필수일 수 있게 수정하였습니다.
  • 프론트와 상의 결과 마이페이지에서 리뷰 조회 시, 해당 상품의 이미지가 필요하다고 판단되었습니다. 따라서 해당 필드를 optional로 추가하여 선택적으로 포함할 수 있게끔 수정하였습니다.
  • reviewService에 중복되는 메서드를 제거하고, 리뷰 삭제 시 productId가 아닌 reviewId를 활용하게끔 수정하였습니다.
  • 위 항목을 위해 product에 review와 연관관계를 매핑하여, 상품 삭제 시 리뷰가 함께 삭제되게끔 수정했습니다.
  • userEntity에 kakaoId 필드를 추가하였습니다. 해당 필드는 추후에 삭제 예정이나, 현재는 findBykakaoId 메서드에 대한 쿼리 생성이 필요하여 임시로 만들어 놓았습니다.
  • 위 항목들에 따라 필요한 부분들의 testcode를 수정하였습니다. �부족한 test code는 상품 api를 작성하며 추가하도록 하겠습니다.

=> 현재는 jwt 토큰에서 파싱된 String 타입의 kakaoId를 사용하고 있으나, 추후에 이를 기반으로 userId를 반환하게 수정할 예정입니다. 수정이 완료되면 kakaoId를 사용하는 부분도 그에 맞게 수정 할 예정입니다. 해당 내용은 userId가 필요한 메서드에 @todo 로 적어놓았습니다.

Comment on lines +139 to +140
Long userId = userRepository.findByKakaoId(kakaoId)
.orElseThrow(() -> new IllegalArgumentException("사용자를 찾을 수 없습니다."));
Copy link
Contributor

Choose a reason for hiding this comment

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

IllegalArgumentException보다는 만들어둔 UserNotFoundException은 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

해당 부분 코드는 jwt 토큰이 userId를 반환하게 수정되면 사라질 부분이어서 토큰 부분 수정 후에도 필요하다면 수정해보도록 하겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

확인했습니다

@jjh4450 jjh4450 merged commit 2a42f00 into kakao-tech-campus-2nd-step3:weekly/9 Oct 29, 2024
1 check passed
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.

3 participants