-
Notifications
You must be signed in to change notification settings - Fork 2
Prod : 게스트, 일반 사용자 PhoneNUmber 구분할 수 있도록 구성 #313
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
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 |
|---|---|---|
|
|
@@ -15,4 +15,12 @@ public static String formatPhoneNumberWithHyphen(String phoneNumber) { | |
| phoneNumber.substring(3, 7), | ||
| phoneNumber.substring(7)); | ||
| } | ||
|
|
||
| public static String formatGuestPhoneNumber(String phoneNumber) { | ||
| return String.format("G%s", phoneNumber); | ||
| } | ||
|
|
||
| public static String formatPhoneNumber(String phoneNumber) { | ||
| return String.format("U%s", phoneNumber); | ||
| } | ||
|
Comment on lines
+23
to
+25
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. To avoid duplicating the logic for removing the phone number prefix (as seen in This centralizes the logic and makes the code easier to maintain. You can then use public static String formatPhoneNumber(String phoneNumber) {
return String.format("U%s", phoneNumber);
}
public static String stripPrefix(String phoneNumber) {
if (phoneNumber == null || phoneNumber.isEmpty()) {
return phoneNumber;
}
return phoneNumber.substring(1);
} |
||
| } | ||
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.
Overriding a getter for a JPA entity field to return a modified value is an anti-pattern. It can cause unexpected behavior with persistence frameworks and breaks the principle of least astonishment. A getter should return the raw field value. It's recommended to rename this method to something like
getRawPhoneNumber()and restore the default getter forphoneNumber(e.g., by letting Lombok generate it).Additionally, the current implementation
phoneNumber.replaceFirst("^.", "")will throw aNullPointerExceptionifphoneNumberis null, as the field is nullable.Here is a safer implementation with a more appropriate method name: