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: 팔로우 추가 / 취소 기능 #191

Merged
merged 6 commits into from
Jan 21, 2024
Merged

feat: 팔로우 추가 / 취소 기능 #191

merged 6 commits into from
Jan 21, 2024

Conversation

kdomo
Copy link
Member

@kdomo kdomo commented Jan 21, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 팔로우 추가 / 취소 기능 구현하였습니다.

팔로우 추가할 때 예외상황

  • targetId가 null일 때
  • 로그인 된 회원이 존재하지 않을 때
  • target 회원이 존재하지 않을 때
  • 이미 팔로우 중일 때

팔로우를 취소할 때 예외상황

  • targetId가 null일 때
  • 로그인 된 회원이 존재하지 않을 때
  • target 회원이 존재하지 않을 때
  • 팔로우 중이지 않을 때

@kdomo kdomo added the ✨ feature 새로운 기능 추가 및 수정 label Jan 21, 2024
@kdomo kdomo added this to the 2.5차 스프린트 milestone Jan 21, 2024
@kdomo kdomo requested review from char-yb and uwoobeat January 21, 2024 10:19
@kdomo kdomo self-assigned this Jan 21, 2024

public void createFollow(FollowCreateRequest request) {
final Member currentMember = memberUtil.getCurrentMember();
Member targetMember =
Copy link
Member

Choose a reason for hiding this comment

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

중복 로직 따로 추출해두면 좋을 것 같습니다~

Copy link
Member Author

Choose a reason for hiding this comment

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

중복로직이라면 어떤 부분일까용?

Copy link
Member

Choose a reason for hiding this comment

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

targetMember 쿼리하는 부분이 겹치는 것 같아서요~

Copy link
Member Author

Choose a reason for hiding this comment

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

확인했슴니당

ErrorCode.FOLLOW_TARGET_MEMBER_NOT_FOUND));

memberRelationRepository
.findByFollowerIdAndFollowingId(currentMember.getId(), targetMember.getId())
Copy link
Member

Choose a reason for hiding this comment

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

existBy 쓰는 건 어떨까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

        MemberRelation memberRelation =
                memberRelationRepository
                        .findByFollowerIdAndFollowingId(currentMember.getId(), targetMember.getId())
                        .orElseThrow(() -> new CustomException(ErrorCode.FOLLOW_NOT_EXIST));

        memberRelationRepository.delete(memberRelation);

현재 코드가 MemberRelation이 존재하지 않을 때 예외를 발생시키는데, 존재할때 해당 객체로 바로 삭제를 진행하는데

existBy로 값이 없다면 예외를 터트리고, 있을 때 MemberRelation을 조회하는 쿼리가 한번 더 나가게되는데
요거에 대해서는 어떻게 생각하시나용?

Copy link
Member

Choose a reason for hiding this comment

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

말씀하신대로 delete는 그렇고, save는 exist 써도 문제 없지 않나요?

Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

38 New issues
0 Security Hotspots
53.2% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@kdomo kdomo merged commit 69bb3d6 into develop Jan 21, 2024
2 checks passed
@github-actions github-actions bot added the merged 머지된 PR label Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature 새로운 기능 추가 및 수정 merged 머지된 PR
Projects
Status: 완료
Development

Successfully merging this pull request may close these issues.

✨ 팔로우 추가 / 취소 기능
2 participants