KakaoUserResponseDto

sudals·2024년 10월 11일

Pawfit - KakaoLogin

목록 보기
5/5

클래스 선언


@Getter

  • 모든 필드의 getter 메서드를 자동으로 생성

@NoArgsConstructor

  • 기본 생성자를 자동으로 생성

@JsonIgnoreProperties(ignoreUnknown = true)

  • JSON에 정의되지 않은 필드가 있어도 무시

public class KakaoUserResponseDto

  • 카카오 사용자 응답을 처리하는 DTO 클래스

필드 정의

@JsonProperty("kakao_account")

  • JSON의 "kakao_account" 필드를 kakaoAccount 객체로 매핑

private KakaoAccount kakaoAccount

  • KakaoAccount 클래스의 객체로 JSON 데이터를 매핑합니다.

내부 클래스 KakaoAccount

이 클래스는 카카오 계정 정보를 표현
@Getter, @NoArgsConstructor, @JsonIgnoreProperties(ignoreUnknown = true)

  • 앞서 설명한 것과 같이 getter 메서드, 기본 생성자 생성, 정의되지 않은 JSON 필드 무시를 설정

public static class KakaoAccount

  • 외부 클래스 KakaoUserResponseDto에 포함된 정적 내부 클래스로, 카카오 계정 정보를 표현

필드 정의

@JsonProperty("email")

  • JSON의 "email" 필드를 email 필드에 매핑

@JsonProperty("profile")

  • JSON의 "profile" 필드를 Profile 객체로 매핑
    private String email
  • 유저의 이메일 정보를 저장하는 필드
    private Profile profile
  • 유저의 프로필 정보를 저장하는 필드

getNickname() 메서드

@JsonProperty("nickname")

  • 이 메서드는 JSON의 "nickname" 필드를 매핑하기 위해 사용됨
    public String getNickname()
  • nickname 값을 가져오기 위해 profile 객체의 getNickname() 메서드를 호출, 이는 JSON 구조가 계층적이기 때문에 프로필 내부의 닉네임 값을 반환하도록 구성됨

부 클래스 Profile

  • 이 클래스는 프로필 정보를 표현

@Getter, @NoArgsConstructor, @JsonIgnoreProperties(ignoreUnknown = true)

  • getter 메서드, 기본 생성자 생성, 정의되지 않은 JSON 필드 무시를 설정

public static class Profile

  • 외부 클래스 KakaoAccount에 포함된 정적 내부 클래스로, 프로필 정보를 표현

@JsonProperty("nickname")

  • JSON의 "nickname" 필드를 nickname 필드에 매핑

private String nickname

  • 유저의 닉네임을 저장하는 필드
profile
봉천동 불개미

0개의 댓글