-
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.
Browse files
Browse the repository at this point in the history
* refactor: Member에서 Nickname 값 객체로 분리 * refactor: Member에서 Email 값 객체로 분리 * refactor: Member에서 Password 값 객체로 분리 * refactor: 이미 암호화된 비밀번호는 다시 암호화되지 않도록 방어로직 추가
- Loading branch information
Showing
21 changed files
with
418 additions
and
113 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
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
47 changes: 47 additions & 0 deletions
47
backend/src/main/java/edonymyeon/backend/member/domain/Email.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,47 @@ | ||
package edonymyeon.backend.member.domain; | ||
|
||
import static edonymyeon.backend.global.exception.ExceptionInformation.MEMBER_EMAIL_INVALID; | ||
import static edonymyeon.backend.member.domain.SocialInfo.*; | ||
|
||
import edonymyeon.backend.global.exception.EdonymyeonException; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import java.util.UUID; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.logging.log4j.util.Strings; | ||
|
||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Embeddable | ||
public class Email { | ||
|
||
private static final int MAX_EMAIL_LENGTH = 30; | ||
|
||
@Column(name = "email", nullable = false, unique = true) | ||
private String value; | ||
|
||
private Email(String email) { | ||
this.value = email; | ||
} | ||
|
||
public static Email from(String email) { | ||
validate(email); | ||
return new Email(email); | ||
} | ||
|
||
private static void validate(final String email) { | ||
if (Strings.isBlank(email) || email.length() > MAX_EMAIL_LENGTH) { | ||
throw new EdonymyeonException(MEMBER_EMAIL_INVALID); | ||
} | ||
} | ||
|
||
public static Email from(final SocialType socialType) { | ||
return new Email("#" + socialType.name() + UUID.randomUUID()); | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
backend/src/main/java/edonymyeon/backend/member/domain/Nickname.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,49 @@ | ||
package edonymyeon.backend.member.domain; | ||
|
||
import static edonymyeon.backend.global.exception.ExceptionInformation.MEMBER_NICKNAME_INVALID; | ||
import static edonymyeon.backend.member.domain.SocialInfo.*; | ||
|
||
import edonymyeon.backend.global.exception.EdonymyeonException; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import java.util.UUID; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.logging.log4j.util.Strings; | ||
|
||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Embeddable | ||
public final class Nickname { | ||
|
||
public static final String NONE = "Unknown"; | ||
private static final int MAX_NICKNAME_LENGTH = 20; | ||
|
||
@Column(name = "nickname", nullable = false, unique = true) | ||
private String value; | ||
|
||
private Nickname(final String nickname) { | ||
this.value = nickname; | ||
} | ||
|
||
public static Nickname from(final String nickname) { | ||
validate(nickname); | ||
return new Nickname(nickname); | ||
} | ||
|
||
private static void validate(final String nickname) { | ||
if (Strings.isBlank(nickname) || nickname.length() > MAX_NICKNAME_LENGTH | ||
|| nickname.equalsIgnoreCase(NONE)) { | ||
throw new EdonymyeonException(MEMBER_NICKNAME_INVALID); | ||
} | ||
} | ||
|
||
public static Nickname from(final SocialType socialType) { | ||
return new Nickname("#" + socialType.name() + UUID.randomUUID()); | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} |
Oops, something went wrong.