| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | @Service |
| | | public class HostingFieldServiceImpl extends AbstractServiceImpl<HostingField, Long, JpaRepository<HostingField, Long>> implements HostingFieldService { |
| | |
| | | |
| | | private void setHostingFormEmail(String email, HostingFieldForm hostingFieldForm, boolean isNull) { |
| | | if (!isNull) { |
| | | if (email.contains(" ")) { |
| | | email = email.replace(" ", ""); |
| | | } |
| | | // 이메일 유효성 검사 |
| | | email = this.verifyEmail(email); |
| | | hostingFieldForm.setEmail(email); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 이메일 유효성 검사 |
| | | * @param email String |
| | | * @return String |
| | | */ |
| | | private String verifyEmail(String email) { |
| | | if (!Pattern.matches("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$", email)) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.EMAIL_NOT_INVALID)); |
| | | } |
| | | |
| | | if (email.contains(" ")) { |
| | | email = email.replace(" ", ""); |
| | | } |
| | | |
| | | return email; |
| | | } |
| | | |
| | | private void setHostingFormTel(String tel, HostingFieldForm hostingFieldForm, boolean isNull) { |
| | | if (!isNull) { |
| | | if (tel.contains("-")) { |
| | | tel = tel.replace("-", ""); |
| | | } |
| | | if (tel.contains(" ")) { |
| | | tel = tel.replace(" ", ""); |
| | | } |
| | | // 연락처 유효성 검사 |
| | | tel = this.verifyTel(tel); |
| | | hostingFieldForm.setTel(tel); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 연락처 유효성 검사 |
| | | * @param tel String |
| | | */ |
| | | private String verifyTel(String tel) { |
| | | if (!Pattern.matches("^[0-9-]{2,20}$", tel)) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.TEL_NOT_INVALID)); |
| | | } |
| | | |
| | | if (tel.contains("-")) { |
| | | tel = tel.replace("-", ""); |
| | | } |
| | | if (tel.contains(" ")) { |
| | | tel = tel.replace(" ", ""); |
| | | } |
| | | |
| | | return tel; |
| | | } |
| | | |
| | | private void setHostingFormManager(String manager, HostingFieldForm hostingFieldForm, boolean isNull) { |
| | |
| | | |
| | | private void setHostingFormCode(String code, HostingFieldForm hostingFieldForm) { |
| | | //코드 유효성 체크 |
| | | this.verifyCode(code); |
| | | hostingFieldForm.setCode(code); |
| | | } |
| | | |
| | | /** |
| | | * 코드 유효성 검사 |
| | | * @param code String |
| | | */ |
| | | private void verifyCode(String code) { |
| | | if (!Pattern.matches("^[a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ\\u318D\\u119E\\u11A2\\u2022\\u2025a\\u00B7\\uFE55]+$", code)) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.CODE_NOT_INVALID)); |
| | | } |
| | | } |
| | | |
| | | private void setHostingFormName(String title, HostingFieldForm hostingFieldForm) { |
| | | // 호스팅명 유효성 체크 |
| | | //this.verifyTitle(title, null); |