-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-144 feat: Login 후 profile 등록 여부 판단 #146
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
Changes from all commits
00a1dd4
54dd3ca
40d2efd
769e697
3cd2c20
d9e9c5e
7358961
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||
| package life.mosu.mosuserver.application.application.vaildator; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import java.time.LocalDate; | ||||||||||||||||||||||||||||||||||||||
| import java.util.HashSet; | ||||||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||||||
| import java.util.Set; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -66,4 +67,14 @@ public void NoDuplicateApplication(Long userId, List<Long> examIds) { | |||||||||||||||||||||||||||||||||||||
| throw new CustomRuntimeException(ErrorCode.APPLICATION_SCHOOL_DUPLICATED); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| public void ExamDateNotPassed(List<Long> examIds) { | ||||||||||||||||||||||||||||||||||||||
| List<ExamJpaEntity> exams = examJpaRepository.findAllById(examIds); | ||||||||||||||||||||||||||||||||||||||
| boolean hasPassedExam = exams.stream() | ||||||||||||||||||||||||||||||||||||||
| .anyMatch(exam -> exam.getExamDate().isBefore(LocalDate.now())); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if (hasPassedExam) { | ||||||||||||||||||||||||||||||||||||||
| throw new CustomRuntimeException(ErrorCode.EXAM_DATE_PASSED); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to Java naming conventions, method names should start with a lowercase letter and be in
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,15 @@ | ||
| package life.mosu.mosuserver.presentation.auth.dto; | ||
|
|
||
| import life.mosu.mosuserver.domain.user.UserJpaEntity; | ||
|
|
||
| public record LoginCommandResponse( | ||
| Token token, | ||
| Boolean isProfileRegistered | ||
| Boolean isProfileRegistered, | ||
| UserJpaEntity user | ||
| ) { | ||
|
|
||
| public static LoginCommandResponse of(final Token token, final Boolean isProfileRegistered) { | ||
| return new LoginCommandResponse(token, isProfileRegistered); | ||
| public static LoginCommandResponse of(final Token token, final Boolean isProfileRegistered, | ||
| final UserJpaEntity user) { | ||
| return new LoginCommandResponse(token, isProfileRegistered, user); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,23 @@ | ||
| package life.mosu.mosuserver.presentation.auth.dto; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
| import life.mosu.mosuserver.application.oauth.OAuthUser; | ||
| import life.mosu.mosuserver.domain.user.UserJpaEntity; | ||
|
|
||
| public record LoginResponse( | ||
| Boolean isProfileRegistered | ||
| Boolean isProfileRegistered, | ||
| @JsonInclude(Include.NON_NULL) LoginUserResponse oauthUser | ||
| ) { | ||
|
|
||
| public static LoginResponse from(final Boolean isProfileRegistered) { | ||
| return new LoginResponse(isProfileRegistered); | ||
| public static LoginResponse from(final OAuthUser user) { | ||
| return from(user.getIsProfileRegistered(), user.getUser()); | ||
| } | ||
|
|
||
| public static LoginResponse from(Boolean isProfileRegistered, final UserJpaEntity user) { | ||
| if (Boolean.TRUE.equals(isProfileRegistered)) { | ||
| return new LoginResponse(true, null); | ||
| } | ||
| return new LoginResponse(false, LoginUserResponse.from(user)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package life.mosu.mosuserver.presentation.auth.dto; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.Optional; | ||
| import life.mosu.mosuserver.domain.user.UserJpaEntity; | ||
|
|
||
| public record LoginUserResponse( | ||
| String gender, | ||
| String name, | ||
| LocalDate birth, | ||
| String phoneNumber | ||
| ) { | ||
|
|
||
| public static LoginUserResponse from(UserJpaEntity user) { | ||
| return Optional.ofNullable(user) | ||
| .map(userEntity -> { | ||
| String gender = Optional.ofNullable(userEntity.getGender()) | ||
| .map(Enum::name) | ||
| .orElse(null); | ||
|
|
||
| return new LoginUserResponse( | ||
| gender, | ||
| userEntity.getName(), | ||
| userEntity.getBirth(), | ||
| userEntity.getPhoneNumber() | ||
| ); | ||
| }) | ||
| .orElse(null); | ||
| } | ||
|
Comment on lines
+14
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of nested public static LoginUserResponse from(UserJpaEntity user) {
if (user == null) {
return null;
}
String gender = (user.getGender() != null) ? user.getGender().name() : null;
return new LoginUserResponse(
gender,
user.getName(),
user.getBirth(),
user.getPhoneNumber()
);
} |
||
| } | ||
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.
Consider calling the validator method with a lowercase starting letter to adhere to Java naming conventions.