-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: #86 - 유저 로그인 시 응답 포맷 내 닉네임 정보 추가
- Loading branch information
Showing
7 changed files
with
57 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package com.freediving.authservice.adapter.in.web.dto; | ||
|
||
import com.freediving.authservice.domain.OauthType; | ||
import com.freediving.authservice.domain.OauthUser; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
@@ -24,22 +23,26 @@ | |
public class UserLoginResponse { | ||
|
||
@Schema(description = "유저 식별 키", example = "1") | ||
private String userId; | ||
|
||
@Schema(description = "소셜 로그인 타입", example = "KAKAO") | ||
private OauthType oauthType; | ||
private Long userId; | ||
|
||
@Schema(description = "이메일", example = "[email protected]") | ||
private String email; | ||
|
||
@Schema(description = "프로필 이미지 URL", example = "https://aws-s3.com") | ||
private String profileImgUrl; | ||
|
||
@Schema(description = "닉네임", example = "초보다이버_00001") | ||
private String nickname; | ||
|
||
@Schema(description = "소셜 로그인 타입", example = "KAKAO") | ||
private String oauthType; | ||
|
||
@Schema(description = "유저 권한", example = "0") | ||
private Integer roleLevel; | ||
|
||
public static UserLoginResponse from(OauthUser oauthUser) { | ||
return new UserLoginResponse(oauthUser.getUserId(), oauthUser.getOauthType(), oauthUser.getEmail(), | ||
oauthUser.getProfileImgUrl(), oauthUser.getRoleLevel()); | ||
return new UserLoginResponse(Long.valueOf(oauthUser.getUserId()), oauthUser.getEmail(), | ||
oauthUser.getProfileImgUrl(), oauthUser.getNickname(), oauthUser.getOauthType().name(), | ||
oauthUser.getRoleLevel()); | ||
} | ||
} |
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
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
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
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
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
33 changes: 33 additions & 0 deletions
33
...ice/src/main/java/com/freediving/memberservice/application/port/in/NicknameGenerator.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.freediving.memberservice.application.port.in; | ||
|
||
import java.util.Random; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* @Author : sasca37 | ||
* @Date : 2024/02/27 | ||
* @Description : 신규 가입 시 닉네임 생성 기능을 담당하는 클래스 | ||
* =========================================================== | ||
* DATE AUTHOR NOTE | ||
* =========================================================== | ||
* 2024/02/27 sasca37 최초 생성 | ||
*/ | ||
public class NicknameGenerator { | ||
private static final String[] WORDS = { | ||
"빠른", "느린", "높은", "낮은", "멋진", | ||
"작은", "애기", "어른", "예쁜", "얇은", | ||
"행복", "슬픈", "기쁨", "쿨한", "초보", | ||
"고래", "사슴", "토끼", "거북", "상어", | ||
"문어", "해마", "가재", "갈치", "물범", | ||
"펭귄", "참치", "새우", "홍합", "해달" | ||
}; | ||
|
||
private static final Random RANDOM = new Random(); | ||
|
||
public static String generateNickname(Long id) { | ||
String sequence = StringUtils.leftPad(String.valueOf(id), 5, '0'); | ||
String randomAdjective = WORDS[RANDOM.nextInt(WORDS.length)]; | ||
return randomAdjective + "다이버_" + sequence; | ||
} | ||
} |