From 6e20d7a92d0e86f7648e01c36dfce1413e6a11ed Mon Sep 17 00:00:00 2001 From: Seokyeong Date: Fri, 26 Jan 2024 03:50:09 +0900 Subject: [PATCH 1/2] del: gender, ageRange field --- .../application/auth/KakaoAuthService.java | 21 ++++++------------- .../fullcar/member/domain/member/Member.java | 4 ---- .../presentation/auth/dto/KakaoInfoDto.java | 14 ------------- 3 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java diff --git a/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java b/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java index a654e10..1bbf65d 100644 --- a/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java +++ b/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java @@ -11,7 +11,6 @@ import com.fullcar.member.domain.member.Member; import com.fullcar.member.domain.member.service.MemberIdService; import com.fullcar.member.domain.member.MemberRepository; -import com.fullcar.member.presentation.auth.dto.KakaoInfoDto; import com.fullcar.member.presentation.auth.dto.request.AuthRequestDto; import com.fullcar.member.presentation.auth.dto.response.SocialInfoResponseDto; import lombok.RequiredArgsConstructor; @@ -42,12 +41,11 @@ public class KakaoAuthService implements AuthService { @Transactional public SocialInfoResponseDto getMemberInfo(AuthRequestDto authRequestDto) { String deviceToken = authRequestDto.getDeviceToken(); - KakaoInfoDto kakaoInfoDto = getKakaoData(authRequestDto.getToken()); - SocialId socialId = socialIdService.generateSocialId(kakaoInfoDto.getSocialId()); + SocialId socialId = socialIdService.generateSocialId(getKakaoData(authRequestDto.getToken())); String refreshToken = jwtTokenProvider.generateRefreshToken(); if (memberRepository.existsBySocialId(socialId)) memberRepository.findBySocialIdAndIsDeleted(socialId, false).loginMember(deviceToken, refreshToken); - else createMember(kakaoInfoDto, deviceToken, refreshToken); + else createMember(socialId, deviceToken, refreshToken); return SocialInfoResponseDto.builder() .socialId(socialId) @@ -55,7 +53,7 @@ public SocialInfoResponseDto getMemberInfo(AuthRequestDto authRequestDto) { .build(); } - private static KakaoInfoDto getKakaoData(String kakaoToken) { + private static String getKakaoData(String kakaoToken) { try { HttpHeaders headers = new HttpHeaders(); @@ -77,13 +75,8 @@ private static KakaoInfoDto getKakaoData(String kakaoToken) { ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(responseBody); - JsonNode kakaoAccount = jsonNode.get("kakao_account"); - String socialId = jsonNode.get("id").asText(); - String gender = kakaoAccount.get("gender").asText(); - String ageRange = kakaoAccount.get("age_range").asText(); - - return new KakaoInfoDto(socialId, gender, ageRange); + return jsonNode.get("id").asText(); } catch (HttpClientErrorException e) { throw new NotFoundException(ErrorCode.UNAUTHORIZED_KAKAO_TOKEN); } catch (JsonProcessingException e) { @@ -92,12 +85,10 @@ private static KakaoInfoDto getKakaoData(String kakaoToken) { } // 새로운 멤버 생성 - private void createMember(KakaoInfoDto kakaoInfoDto, String deviceToken, String refreshToken) { + private void createMember(SocialId socialId, String deviceToken, String refreshToken) { memberRepository.save(Member.builder() .id(memberIdService.nextId()) - .socialId(socialIdService.generateSocialId(kakaoInfoDto.getSocialId())) - .gender(kakaoInfoDto.getGender()) - .ageRange(kakaoInfoDto.getAgeRange()) + .socialId(socialId) .deviceToken(deviceToken) .refreshToken(refreshToken) .build()); diff --git a/src/main/java/com/fullcar/member/domain/member/Member.java b/src/main/java/com/fullcar/member/domain/member/Member.java index dca7d02..c9ae38a 100644 --- a/src/main/java/com/fullcar/member/domain/member/Member.java +++ b/src/main/java/com/fullcar/member/domain/member/Member.java @@ -41,10 +41,6 @@ public class Member { private String nickname; private String email; - - private String gender; - - private String ageRange; @Builder.Default @Column(name = "onboarding_flag") diff --git a/src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java b/src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java deleted file mode 100644 index eb84aea..0000000 --- a/src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fullcar.member.presentation.auth.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class KakaoInfoDto { - private String socialId; - - private String gender; - - private String ageRange; -} From a93db9ce12cd1574f99ac5f7798afa7c974f22e9 Mon Sep 17 00:00:00 2001 From: Seokyeong Date: Fri, 26 Jan 2024 16:48:39 +0900 Subject: [PATCH 2/2] add: gender --- src/main/java/com/fullcar/member/domain/member/Member.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/fullcar/member/domain/member/Member.java b/src/main/java/com/fullcar/member/domain/member/Member.java index c9ae38a..7b2781e 100644 --- a/src/main/java/com/fullcar/member/domain/member/Member.java +++ b/src/main/java/com/fullcar/member/domain/member/Member.java @@ -42,6 +42,8 @@ public class Member { private String email; + private String gender; + @Builder.Default @Column(name = "onboarding_flag") private boolean flag = false;