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

[BE] issue344: 리뷰 리팩토링 #348

Merged
merged 15 commits into from
Oct 5, 2022

Conversation

sc0116
Copy link
Collaborator

@sc0116 sc0116 commented Sep 14, 2022

요약

리뷰 리팩토링

세부사항

리뷰 관련 파일 스터디룸 패키지 내부로 이동 및 리팩토링

close #344

@sc0116 sc0116 added 🖥 backend New backend feature 🛠 refactoring Refactor code labels Sep 14, 2022
@sc0116 sc0116 added this to the Milestone 5 milestone Sep 14, 2022
@sc0116 sc0116 self-assigned this Sep 14, 2022
@sc0116 sc0116 linked an issue Sep 14, 2022 that may be closed by this pull request
@2022-moamoa

This comment has been minimized.

@tco0427 tco0427 removed this from the Milestone 5 milestone Sep 14, 2022
@2022-moamoa

This comment has been minimized.

Copy link
Collaborator

@tco0427 tco0427 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다..!!
패키지 이동하면서 StudyRoom 의 메소드를 활용한 부분이 인상깊네요!

@2022-moamoa

This comment has been minimized.

Copy link
Collaborator

@jaejae-yoo jaejae-yoo left a comment

Choose a reason for hiding this comment

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

짱구 고생하셨습니다! 👍
ReviewControllerTestSearchingReviewControllerTest 테스트가 깨지는 데 확인부탁드려요 ~

@2022-moamoa

This comment has been minimized.

@2022-moamoa

This comment has been minimized.

@@ -48,6 +51,13 @@ public Article write(final Accessor accessor, final String title, final String c
throw new NotParticipatedMemberException();
}

public Review writeReview(final Accessor accessor, final String content) {
if (!isPermittedAccessor(accessor)) {
throw new NotParticipatedMemberException();
Copy link
Collaborator

Choose a reason for hiding this comment

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

아마 StudyRoom에 UneditableArticleException이 있을 건데 이거와 합치는게 좋을 듯 합니다. 당연히 이름도 Article을 빼서 적절한 이름으로 변경해야겠죠 ㅎㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

앗 합치는건 좋은데 리뷰 작성시 예외 발생하는 경우에 "수정할 수 없는 아티클 예외"를 사용하는게 맞나용?

Comment on lines 48 to 55
public void updateContent(final AssociatedStudy associatedStudy, final Reviewer reviewer, final String content) {
validateReview(associatedStudy, reviewer);
this.content = content;
}

public void updateContent(final Reviewer reviewer, final String content) {
validateReviewer(reviewer);
this.content = content;
public void delete(final AssociatedStudy associatedStudy, final Reviewer reviewer) {
validateReview(associatedStudy, reviewer);
deleted = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Article처럼 Accessor를 도입해보는 것도 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

기존 메서드 유지하면서 Accessor 사용한 메서드 추가하고 테스트 통과한거 확인한 뒤 지우는 절차를 밟았는데 재밌네요!

Comment on lines 30 to 31
memberRepository.findById(memberId)
.orElseThrow(MemberNotFoundException::new);
Copy link
Collaborator

Choose a reason for hiding this comment

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

StudyRoom에서 작성 가능한 사용자를 체크하는데 member가 DB에 존재하는지 확인할 필요가 없을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

StudyRoom에서는 스터디에 참여한 회원인가를 확인하고, 저 부분은 해당 id의 멤버가 존재하냐를 확인하는거라 다르긴 하지만 지금 생각해보면 굳이 회원이 존재하는지 확인안해도 될 것 같네요! 저 로직을 타려면 굳이굳이 힘들게 포스트맨으로 보내야만 탈 것 같네용...

private final MemberRepository memberRepository;
private final StudyRoomRepository studyRoomRepository;

public Long writeReview(final Long memberId, final Long studyId, final WriteReviewRequest writeReviewRequest) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

WriteReviewRequest와 EditingReviewRequest가 동일하기 때문에 하나로 합치는게 일단은 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😊

final Review review = reviewRepository.findById(reviewId)
.orElseThrow(ReviewNotFoundException::new);

review.updateContent(new AssociatedStudy(studyId), new Reviewer(memberId), editingReviewRequest.getContent());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Article과 비슷한 구조로 만들 수 있을 것 같습니다. Review가 Accessor를 사용해 수정하게 되면, StudyRoom, Member를 DB에 조회할 필요가 없을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Accessor를 사용하도록 수정했는데요! 그래도 해당 스터디나 회원이 있는지 여부는 확인해야 하는거 아닌가요??

assertDoesNotThrow(() -> sut.writeReview(accessor, "content"));
}

@DisplayName("스터디에 참여하지 않은 사용자는 리뷰를 작성할 수 없다.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

작성자 ID는 맞으나 스터디 ID가 다른 케이스도 다뤄야할 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

작성에 있어서는 두 가지가 같은 의미 아닌가요?? 만약 수정, 삭제에서 작성자는 맞지만 스터디가 다른 경우를 말씀하시는거면 ReviewTest에 작성되어있습니다!(삭제만 있고 수정은 없어서 추가했습니다)

@2022-moamoa

This comment has been minimized.

@sc0116 sc0116 force-pushed the refactor/344-review-move-the-package branch from 8720320 to a4bf8e4 Compare October 5, 2022 06:41
@2022-moamoa
Copy link

2022-moamoa bot commented Oct 5, 2022

Passed

Analysis Details

7 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 7 Code Smells

Coverage and Duplications

  • Coverage No coverage information (69.50% Estimated after merge)
  • Duplications No duplication information (0.40% Estimated after merge)

Project ID: woowacourse-teams_2022-moamoa_AYKvd_z4VbW_bWBvgn13

View in SonarQube

Copy link
Collaborator

@tco0427 tco0427 left a comment

Choose a reason for hiding this comment

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

충돌 해결하느라 고생하셨습니다..!!

@verus-j verus-j merged commit 4cb0804 into develop Oct 5, 2022
@tco0427 tco0427 deleted the refactor/344-review-move-the-package branch October 6, 2022 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖥 backend New backend feature 🛠 refactoring Refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] 리뷰 리팩토링
4 participants