Skip to content
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

edit : OAuth 로그인 프로세스 변경 #169

Merged
merged 15 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.civilwar.boardsignal.user.exception.UserErrorCode.NOT_FOUND_AGE_GROUP;

import com.civilwar.boardsignal.common.exception.NotFoundException;
import java.time.LocalDateTime;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand All @@ -11,21 +12,23 @@
@RequiredArgsConstructor
public enum AgeGroup {

UNDER_CHILDREN("1~9", "1-9", "미취학 아동"),
CHILDREN("10~14", "10-14", "어린이"),
TEENAGER("14~19", "14-19", "청소년"),
TWENTY("20~29", "20-29", "20대"),
THIRTY("30~39", "30-39", "30대"),
FORTY("40~49", "40-49", "40대"),
FIFTY("50~59", "50-59", "50대"),
SIXTY("60~69", "60-69", "60대"),
SEVENTY("70~79", "70-79", "70대"),
EIGHTY("80~89", "80-89", "80대"),
NINETY("90~", "90-", "90이상");
UNKNOWN("0", "0", "알 ㅅ 없음", 0),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오타 있습니다~

UNDER_CHILDREN("1~9", "1-9", "미취학 아동", 9),
CHILDREN("10~14", "10-14", "어린이", 14),
TEENAGER("14~19", "14-19", "청소년", 19),
TWENTY("20~29", "20-29", "20대", 29),
THIRTY("30~39", "30-39", "30대", 39),
FORTY("40~49", "40-49", "40대",49),
FIFTY("50~59", "50-59", "50대", 59),
SIXTY("60~69", "60-69", "60대", 69),
SEVENTY("70~79", "70-79", "70대", 79),
EIGHTY("80~89", "80-89", "80대", 89),
NINETY("90~", "90-", "90이상", 100);

private final String kakaoType;
private final String naverType;
private final String description;
private final int maxAge;

public static AgeGroup of(String input, String provider) {
return Arrays.stream(values())
Expand All @@ -41,4 +44,18 @@ private boolean isEqual(String input, String provider) {
return input.equalsIgnoreCase(this.naverType);
}
}

public static AgeGroup convert(int birthYear, LocalDateTime now) {
AgeGroup userAgeGroup = UNKNOWN;
int age = now.getYear()-birthYear+1;

for (AgeGroup a : values()) {
//현재 연령대의 사용자의 나이가 포함된다면
if (a.getMaxAge()>=age) {
userAgeGroup = a;
}
}
return userAgeGroup;

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return문이 if문 안에 있어야 정상 흐름 아닌가욥??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break 건 다는걸 놓쳤네요..!! 감사합니다~!

}