Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -1,5 +1,6 @@
package life.mosu.mosuserver.application.profile;

import life.mosu.mosuserver.domain.profile.entity.Gender;
import life.mosu.mosuserver.domain.profile.entity.ProfileJpaEntity;
import life.mosu.mosuserver.domain.profile.repository.ProfileJpaRepository;
import life.mosu.mosuserver.domain.user.entity.UserJpaEntity;
Expand Down Expand Up @@ -74,7 +75,7 @@ private void checkIfProfileExistsForUser(UserJpaEntity user) {

private void syncUserInfoFromProfile(UserJpaEntity user, SignUpProfileRequest request) {
if (user.isMosuUser()) {
user.updateUserInfo(request.validatedGender(), request.userName(),
user.updateUserInfo(Gender.fromName(request.gender()), request.userName(),
request.phoneNumber(), request.birth());
Comment on lines +78 to 79

Choose a reason for hiding this comment

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

high

To maintain consistency and proper error handling as suggested for SignUpProfileRequest, this should also use the proposed validatedGender() method. This ensures that invalid gender values are handled gracefully with a proper CustomRuntimeException before this method is called, and avoids duplicating the conversion logic.

Suggested change
user.updateUserInfo(Gender.fromName(request.gender()), request.userName(),
request.phoneNumber(), request.birth());
user.updateUserInfo(request.validatedGender(), request.userName(),
request.phoneNumber(), request.birth);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import life.mosu.mosuserver.domain.profile.entity.Grade;
import life.mosu.mosuserver.domain.profile.entity.ProfileJpaEntity;
import life.mosu.mosuserver.global.annotation.PhoneNumberPattern;
import life.mosu.mosuserver.global.exception.CustomRuntimeException;
import life.mosu.mosuserver.global.exception.ErrorCode;

@Schema(description = "프로필 등록 요청 DTO")
public record SignUpProfileRequest(
Expand Down Expand Up @@ -48,20 +46,12 @@ public record SignUpProfileRequest(

) {

public Gender validatedGender() {
try {
return Gender.valueOf(gender.toUpperCase());
} catch (IllegalArgumentException | NullPointerException e) {
throw new CustomRuntimeException(ErrorCode.INVALID_GENDER);
}
}

public ProfileJpaEntity toEntity(Long userId) {
return ProfileJpaEntity.builder()
.userId(userId)
.userName(userName)
.birth(birth)
.gender(validatedGender())
.gender(Gender.fromName(gender))
.phoneNumber(phoneNumber)
.email(email)
.education(education)
Expand Down