From 1130ed8e6b85b252db8f10ced3df79e32df3c567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EA=B2=B8?= Date: Wed, 23 Oct 2024 21:55:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EA=B0=9D=EC=B2=B4?= =?UTF-8?q?=EC=9D=98=20=EC=83=81=ED=83=9C=EB=A5=BC=20=EC=A7=81=EC=A0=91=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=98=EC=97=AC=20=EB=8D=94=ED=8B=B0?= =?UTF-8?q?=EC=B2=B4=ED=82=B9=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mouda/backend/auth/business/KakaoAuthService.java | 2 +- .../main/java/mouda/backend/member/domain/Member.java | 4 ++++ .../mouda/backend/member/implement/MemberWriter.java | 6 +++--- .../backend/auth/business/KakaoAuthServiceTest.java | 9 +++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/mouda/backend/auth/business/KakaoAuthService.java b/backend/src/main/java/mouda/backend/auth/business/KakaoAuthService.java index 5ddc4959..655659fb 100644 --- a/backend/src/main/java/mouda/backend/auth/business/KakaoAuthService.java +++ b/backend/src/main/java/mouda/backend/auth/business/KakaoAuthService.java @@ -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); } diff --git a/backend/src/main/java/mouda/backend/member/domain/Member.java b/backend/src/main/java/mouda/backend/member/domain/Member.java index f31b3ff2..03d950d0 100644 --- a/backend/src/main/java/mouda/backend/member/domain/Member.java +++ b/backend/src/main/java/mouda/backend/member/domain/Member.java @@ -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) diff --git a/backend/src/main/java/mouda/backend/member/implement/MemberWriter.java b/backend/src/main/java/mouda/backend/member/implement/MemberWriter.java index 1d118230..23f79445 100644 --- a/backend/src/main/java/mouda/backend/member/implement/MemberWriter.java +++ b/backend/src/main/java/mouda/backend/member/implement/MemberWriter.java @@ -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) { diff --git a/backend/src/test/java/mouda/backend/auth/business/KakaoAuthServiceTest.java b/backend/src/test/java/mouda/backend/auth/business/KakaoAuthServiceTest.java index 9ad93919..44c90d85 100644 --- a/backend/src/test/java/mouda/backend/auth/business/KakaoAuthServiceTest.java +++ b/backend/src/test/java/mouda/backend/auth/business/KakaoAuthServiceTest.java @@ -49,8 +49,13 @@ void convert() { // then Optional kakaoMember = memberRepository.findActiveOrDeletedByIdentifier(kakaoIdentifier); - assertThat(kakaoMember.isPresent()).isTrue(); - assertThat(kakaoMember.get().getMemberStatus()).isEqualTo(MemberStatus.ACTIVE); + assertThat(kakaoMember.isEmpty()).isTrue(); + + Optional convertedMember = memberRepository.findActiveOrDeletedByIdentifier(googleIdentifier); + assertThat(convertedMember.isPresent()).isTrue(); + assertThat(convertedMember.get().getMemberStatus()).isEqualTo(MemberStatus.ACTIVE); + assertThat(convertedMember.get().isConverted()).isTrue(); + Optional googleMember = memberRepository.findDeprecatedByIdentifier(googleIdentifier); assertThat(googleMember.isPresent()).isTrue(); assertThat(googleMember.get().getMemberStatus()).isEqualTo(MemberStatus.DEPRECATED);