Skip to content

Conversation

@LeeJaeYun7
Copy link
Collaborator

  • Heart 패키지에 대한 리팩토링을 진행하였습니다

Copy link
Collaborator

@f-lab-moony f-lab-moony left a 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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

시퀀스 값인데 받을 필요가 있을까요 ~?

Copy link
Collaborator Author

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));
Copy link
Collaborator

Choose a reason for hiding this comment

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

요런 부분은 Repository를 직접 참조하지 않고, Service를 참조하면 재사용이 가능하지 않을까요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 확인했습니다

Copy link
Collaborator Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

check~~ 메서드에서 boolean을 리턴하는게 낫지 않을까요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 확인했습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영 완료

Copy link
Collaborator

@f-lab-moony f-lab-moony left a 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) {
Copy link
Collaborator

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)
Copy link
Collaborator

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());
Copy link
Collaborator

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()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

안쓰는거면 정리 해 주세요 ~

@f-lab-moony f-lab-moony merged commit d72a299 into main Sep 8, 2023
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