-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor][#53] 정적 팩토리로 객체 생성 하도록 수정
- Loading branch information
Showing
2 changed files
with
23 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 18 additions & 17 deletions
35
src/main/java/kr/startoff/backend/domain/user/dto/response/LoginResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |