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

del: gender, ageRange field in the member domain #29

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,20 +41,19 @@ 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)
.refreshToken(refreshToken)
.build();
}

private static KakaoInfoDto getKakaoData(String kakaoToken) {
private static String getKakaoData(String kakaoToken) {

try {
HttpHeaders headers = new HttpHeaders();
Expand All @@ -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) {
Expand All @@ -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());
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/fullcar/member/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ public class Member {
private String nickname;

private String email;

private String gender;

private String ageRange;
private String gender;

@Builder.Default
@Column(name = "onboarding_flag")
Expand Down

This file was deleted.

Loading