-
Notifications
You must be signed in to change notification settings - Fork 0
#16 Heart 패키지 리팩토링 #22
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
Conversation
LeeJaeYun7
commented
Aug 29, 2023
- Heart 패키지에 대한 리팩토링을 진행하였습니다
f-lab-moony
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생 많으셨습니다 ~
코멘트를 남겨 뒀는데, 저번 시간에 말씀드린 락 부분도 포함해서 한번 다시 다듬으시면 좋을 것 같아서 리뷰 재요청 드려요 ~
| Objects.requireNonNull(answer, "answer가 null입니다."); | ||
| Objects.requireNonNull(member, "member가 null입니다."); | ||
|
|
||
| this.id = id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시퀀스 값인데 받을 필요가 있을까요 ~?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 확인했습니다
| if (heartRepository.findByAnswerIdAndMemberId(heartDTO.getAnswerId(), memberId).isPresent()) { | ||
| Long answerId = heartRequest.getAnswerId(); | ||
|
|
||
| Answer answer = answerRepository.findById(answerId).orElseThrow(() -> new CommonException(NOT_FOUND_ANSWER)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요런 부분은 Repository를 직접 참조하지 않고, Service를 참조하면 재사용이 가능하지 않을까요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 확인했습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영 완료
| Long answerId = heartRequest.getAnswerId(); | ||
|
|
||
| decreaseHeartFacade(heartDTO.getAnswerId()); | ||
| Heart heart = checkHeartExists(answerId, memberId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check~~ 메서드에서 boolean을 리턴하는게 낫지 않을까요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 확인했습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영 완료
f-lab-moony
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생 많으셨습니다 ~
머지 하도록 할게요 ~
|
|
||
| @Builder | ||
| public Heart(Long id, Answer answer, Member member) { | ||
| public Heart(Answer answer, Member member) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
|
||
| public interface AnswerLockRepository extends JpaRepository<Answer, Long> { | ||
|
|
||
| @Query(value = "select get_lock(:key, 3000)", nativeQuery = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeout도 파라미터로 받는게 어떨까요 ~?
| answerLockRepository.getLock(answerId.toString()); | ||
| increaseAnswerHeartCnt(answerId); | ||
| } finally { | ||
| answerLockRepository.releaseLock(answerId.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에 increaseAnswerHaertCnt 에서 SQL Exception이 발생하면, 이 구문은 실행 될까요 ?
| .modify(!ref.getCreatedDate().equals(ref.getModifiedDate())) | ||
| .myRef(ref.getMember().getId().equals(memberId)) | ||
| .heartCnt(refHeartRepository.countRefHeartByReferenceId(ref.getId())) | ||
| // .heartCnt(heartRepository.countRefHeartByReferenceId(ref.getId())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안쓰는거면 정리 해 주세요 ~