Skip to content

Commit

Permalink
[refactor][#53] 정적 팩토리로 객체 생성 하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ProtoSeo committed Jul 25, 2022
1 parent b70a36c commit 554c8d1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ public class AccessTokenResponse {
private Long userId;
private String accessToken;

public AccessTokenResponse(Long userId, String accessToken) {
private AccessTokenResponse(Long userId, String accessToken) {
this.userId = userId;
this.accessToken = accessToken;
}

public static AccessTokenResponse of(Long userId, String accessToken) {
return new AccessTokenResponse(userId, accessToken);
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package kr.startoff.backend.domain.user.dto.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

import lombok.Builder;
import kr.startoff.backend.domain.user.domain.security.UserPrincipal;
import lombok.Getter;

@Getter
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class LoginResponse {
@JsonProperty("token_type")
private final String TOKEN_TYPE = "Bearer";
private String accessToken;
private String uuid;
private Long userId;
private String email;
private String nickname;
private final Long userId;
private final String email;
private final String nickname;
private final String accessToken;
private final String uuid;

@Builder
public LoginResponse(String accessToken, String uuid, Long userId, String email, String nickname) {
this.accessToken = accessToken;
this.uuid = uuid;
private LoginResponse(Long userId, String email, String nickname, String accessToken, String uuid) {
this.userId = userId;
this.email = email;
this.nickname = nickname;
this.accessToken = accessToken;
this.uuid = uuid;
}

public static LoginResponse of(UserPrincipal userPrincipal, String accessToken, String uuid) {
return new LoginResponse(
userPrincipal.getId(),
userPrincipal.getEmail(),
userPrincipal.getNickname(),
accessToken,
uuid);
}
}

0 comments on commit 554c8d1

Please sign in to comment.