Skip to content

Commit

Permalink
Merge pull request #743 from woowacourse-teams/fix/#741
Browse files Browse the repository at this point in the history
회원 객체의 상태를 직접 변경하여 더티체킹 하도록 수정
  • Loading branch information
Mingyum-Kim authored Oct 23, 2024
2 parents 38caff3 + 1130ed8 commit c91dd2d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class KakaoAuthService {
public void convert(Member alternation, KakaoConvertRequest kakaoConvertRequest) {
String identifier = userInfoProvider.getIdentifier(kakaoConvertRequest.code());
Member kakao = memberFinder.findActiveOrDeletedByIdentifier(identifier);
memberWriter.updateLoginDetail(kakao.getId(), alternation.getLoginDetail());
memberWriter.updateLoginDetail(kakao, alternation.getLoginDetail());
kakao.convert();
memberWriter.deprecate(alternation);
}
Expand Down
4 changes: 4 additions & 0 deletions backend/src/main/java/mouda/backend/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public void deprecate() {
this.memberStatus = MemberStatus.DEPRECATED;
}

public void updateLoginDetail(LoginDetail loginDetail) {
this.loginDetail = loginDetail;
}

@Override
public boolean equals(Object o) {
if (this == o)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public Member append(Member member) {
return memberRepository.save(member);
}

public void updateLoginDetail(long memberId, LoginDetail loginDetail) {
memberRepository.updateLoginDetail(memberId, loginDetail.getOauthType(),
loginDetail.getIdentifier());
public void updateLoginDetail(Member member, LoginDetail loginDetail) {
member.updateLoginDetail(loginDetail);
memberRepository.save(member);
}

public void updateName(long memberId, String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ void convert() {

// then
Optional<Member> kakaoMember = memberRepository.findActiveOrDeletedByIdentifier(kakaoIdentifier);
assertThat(kakaoMember.isPresent()).isTrue();
assertThat(kakaoMember.get().getMemberStatus()).isEqualTo(MemberStatus.ACTIVE);
assertThat(kakaoMember.isEmpty()).isTrue();

Optional<Member> convertedMember = memberRepository.findActiveOrDeletedByIdentifier(googleIdentifier);
assertThat(convertedMember.isPresent()).isTrue();
assertThat(convertedMember.get().getMemberStatus()).isEqualTo(MemberStatus.ACTIVE);
assertThat(convertedMember.get().isConverted()).isTrue();

Optional<Member> googleMember = memberRepository.findDeprecatedByIdentifier(googleIdentifier);
assertThat(googleMember.isPresent()).isTrue();
assertThat(googleMember.get().getMemberStatus()).isEqualTo(MemberStatus.DEPRECATED);
Expand Down

0 comments on commit c91dd2d

Please sign in to comment.