-
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.
Merge pull request #225 from ku-ring/develop
version 2.10.2
- Loading branch information
Showing
132 changed files
with
7,110 additions
and
14,765 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
68 changes: 68 additions & 0 deletions
68
src/main/java/com/kustacks/kuring/common/utils/converter/EmailSupporter.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,68 @@ | ||
package com.kustacks.kuring.common.utils.converter; | ||
|
||
import java.util.Arrays; | ||
import java.util.regex.Pattern; | ||
|
||
public class EmailSupporter { | ||
private static final Pattern AT_PATTERN = Pattern.compile("\\s+at\\s+"); | ||
private static final Pattern DOT_PATTERN = Pattern.compile("\\s+dot\\s+"); | ||
private static final Pattern EMAIL_PATTERN = Pattern.compile("^[a-zA-Z0-9_!#$%&'\\*+/=?{|}~^.-]+@[a-zA-Z0-9.-]+$"); | ||
|
||
private static final String KONKUK_DOMAIN = "@konkuk.ac.kr"; | ||
private static final String EMPTY_EMAIL = ""; | ||
|
||
public static boolean isNullOrBlank(String email) { | ||
return email == null || email.isBlank(); | ||
} | ||
|
||
public static String convertValidEmail(String email) { | ||
if (isNullOrBlank(email)) { | ||
return EMPTY_EMAIL; | ||
} | ||
|
||
String[] emailGroups = splitEmails(email); | ||
String[] normalizedEmails = normalizeEmails(emailGroups); | ||
|
||
//여러 이메일 중 konkuk을 우선 선택, 없으면 첫번째 내용 | ||
return selectPreferredEmail(normalizedEmails); | ||
} | ||
|
||
private static String[] splitEmails(String email) { | ||
return email.split("[/,]"); | ||
} | ||
|
||
private static String[] normalizeEmails(String[] emailGroups) { | ||
return Arrays.stream(emailGroups) | ||
.map(EmailSupporter::normalizeEmail) | ||
.toArray(String[]::new); | ||
} | ||
|
||
private static String normalizeEmail(String email) { | ||
if (EMAIL_PATTERN.matcher(email).matches()) { | ||
return email; | ||
} | ||
|
||
if (containsSubstitutePatterns(email)) { | ||
return replaceSubstitutePatterns(email); | ||
} | ||
|
||
return EMPTY_EMAIL; | ||
} | ||
|
||
private static String replaceSubstitutePatterns(String email) { | ||
return email.replaceAll(DOT_PATTERN.pattern(), ".") | ||
.replaceAll(AT_PATTERN.pattern(), "@"); | ||
} | ||
|
||
private static boolean containsSubstitutePatterns(String email) { | ||
return DOT_PATTERN.matcher(email).find() && AT_PATTERN.matcher(email).find(); | ||
} | ||
|
||
// Konkuk 도메인 우선 선택 | ||
private static String selectPreferredEmail(String[] emails) { | ||
return Arrays.stream(emails) | ||
.filter(email -> email.endsWith(KONKUK_DOMAIN)) | ||
.findFirst() | ||
.orElseGet(() -> emails.length > 0 ? emails[0] : EMPTY_EMAIL); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/kustacks/kuring/common/utils/converter/PhoneNumberSupporter.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,42 @@ | ||
package com.kustacks.kuring.common.utils.converter; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class PhoneNumberSupporter { | ||
|
||
private static final Pattern LAST_FOUR_NUMBER_PATTERN = Pattern.compile("\\d{4}"); | ||
private static final Pattern FULL_NUMBER_PATTERN = Pattern.compile("02-\\d{3,4}-\\d{4}"); | ||
private static final Pattern FULL_NUMBER_WITH_PARENTHESES_PATTERN = Pattern.compile("02[)]\\d{3,4}-\\d{4}"); | ||
|
||
private static final String EMPTY_PHONE = ""; | ||
|
||
public static boolean isNullOrBlank(String number) { | ||
return number == null || number.isBlank(); | ||
} | ||
|
||
public static String convertFullExtensionNumber(String number) { | ||
if (isNullOrBlank(number)) { | ||
return EMPTY_PHONE; | ||
} | ||
|
||
if (FULL_NUMBER_PATTERN.matcher(number).matches()) { | ||
return number; | ||
} | ||
if (containsLastFourNumber(number)) { | ||
return "02-450-" + number; | ||
} | ||
if (containsParenthesesPattern(number)) { | ||
return number.replace(")", "-"); | ||
} | ||
|
||
return EMPTY_PHONE; | ||
} | ||
|
||
private static boolean containsLastFourNumber(String number) { | ||
return LAST_FOUR_NUMBER_PATTERN.matcher(number).matches(); | ||
} | ||
|
||
private static boolean containsParenthesesPattern(String number) { | ||
return FULL_NUMBER_WITH_PARENTHESES_PATTERN.matcher(number).matches(); | ||
} | ||
} |
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
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
37 changes: 0 additions & 37 deletions
37
.../com/kustacks/kuring/worker/parser/staff/LivingAndCommunicationDesignStaffHtmlParser.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.