-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/177 : 애플로그인 사용자명 랜덤 세팅 #198
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7938ff2
:sparkles: Feat: NickName Feign Client 세팅
swa07016 20d4dea
:sparkles: Feat: 애플로그인 랜덤 닉네임 세팅
swa07016 ad4bad9
:sparkles: Feat: 닉네임 생성 관련 상수 분리
swa07016 db5fdf6
:recycle: Refactor: 클라이언트 코드가 랜덤 닉네임 생성에 관여하지 않도록 Adapter 제공
swa07016 3d625cb
:white_check_mark: Test: NickNameGenerator 테스트 코드 작성
swa07016 5ed6b66
:sparkles: Feat: 기본 닉네임 세팅 & 응답 words 기본 빈 리스트 할당
swa07016 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
51 changes: 51 additions & 0 deletions
51
...main/java/com/example/briefinginfra/feign/nickname/hwanmoo/adapter/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,51 @@ | ||
package com.example.briefinginfra.feign.nickname.hwanmoo.adapter; | ||
|
||
import com.example.briefinginfra.feign.nickname.hwanmoo.client.NickNameClient; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
import static com.example.briefingcommon.common.constant.BriefingStatic.*; | ||
import static com.example.briefingcommon.common.constant.BriefingStatic.NICK_NAME_FORMAT; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NickNameGenerator { | ||
private final NickNameClient nickNameClient; | ||
|
||
/** | ||
* 기본 최대 길이를 사용하여 랜덤 닉네임을 생성하고 반환합니다. | ||
* 이 메소드는 내부적으로 {@code getOneRandomNickNameWithDetails}를 호출합니다. | ||
* | ||
* @return 생성된 닉네임. 닉네임 생성에 실패한 경우 빈 문자열을 반환합니다. | ||
*/ | ||
public String getOneRandomNickName() { | ||
return getOneRandomNickNameWithDetails(NICK_NAME_MAX_LENGTH); | ||
} | ||
|
||
/** | ||
* 사용자가 지정한 최대 길이를 사용하여 랜덤 닉네임을 생성하고 반환합니다. | ||
* 이 메소드는 내부적으로 {@code getOneRandomNickNameWithDetails}를 호출합니다. | ||
* | ||
* @param maxLength 생성할 닉네임의 최대 길이 | ||
* @return 생성된 닉네임. 닉네임 생성에 실패한 경우 빈 문자열을 반환합니다. | ||
*/ | ||
public String getOneRandomNickName(int maxLength) { | ||
return getOneRandomNickNameWithDetails(maxLength); | ||
} | ||
|
||
/** | ||
* 지정된 최대 길이를 사용하여 랜덤 닉네임을 생성하고, 생성된 목록에서 첫 번째 닉네임을 반환합니다. | ||
* 이 메소드는 내부적으로 {@code NickNameClient}를 사용하여 닉네임을 요청합니다. | ||
* | ||
* @param maxLength 생성할 닉네임의 최대 길이 | ||
* @return 생성된 닉네임 중 첫 번째 닉네임. 닉네임 생성에 실패한 경우 빈 문자열을 반환합니다. | ||
*/ | ||
private String getOneRandomNickNameWithDetails(int maxLength) { | ||
List<String> nickNameWords = nickNameClient.getNickName(NICK_NAME_FORMAT, NICK_NAME_COUNT, maxLength).getWords(); | ||
if (!nickNameWords.isEmpty()) return nickNameWords.get(0); | ||
return ""; | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앞선 리뷰와 동일한데, nickNameWords.stream().findFirst();를 사용하는 방식에 대해서는 어떻게 생각하시나요?
빈 리스트의 경우 ""를 반환할지 아니면 기본 닉네임을 반환할지도 고민이 되네요