From ad486a401ad59d44bd4187f6406fe8c11b046a1f Mon Sep 17 00:00:00 2001 From: minhee <alsdldlfrl@gmail.com> Date: 월, 21 2월 2022 16:05:09 +0900 Subject: [PATCH] - 파트너 정보 엑셀 임포트 시 연락처, 코드, 이메일 유효성 검사 - 특정 프로젝트로 설정된 상태에서 타 프로젝트의 이슈 클릭 시 대시보드로 이동되는 문제 해결 --- src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java | 62 ++++++++++++++++++++++++++---- 1 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java index 501e770..23212c1 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IspFieldServiceImpl.java @@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.*; +import java.util.regex.Pattern; @Service public class IspFieldServiceImpl extends AbstractServiceImpl<IspField, Long, JpaRepository<IspField, Long>> implements IspFieldService { @@ -472,23 +473,55 @@ private void setIspFormEmail(String email, IspFieldForm ispFieldForm, boolean isNull) { if (!isNull) { - if (email.contains(" ")) { - email = email.replace(" ", ""); - } + // �씠硫붿씪 �쑀�슚�꽦 寃��궗 + email = this.verifyEmail(email); ispFieldForm.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 setIspFormTel(String tel, IspFieldForm ispFieldForm, int rowIndex, boolean isNull) { if (!isNull) { - if (tel.contains("-")) { - tel = tel.replace("-", ""); - } - if (tel.contains(" ")) { - tel = tel.replace(" ", ""); - } + // �뿰�씫泥� �쑀�슚�꽦 寃��궗 + tel = this.verifyTel(tel); ispFieldForm.setTel(tel); } + } + + /** + * �뿰�씫泥� �쑀�슚�꽦 寃��궗 + * @param tel String + * @return 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 setIspFormManager(String manager, IspFieldForm ispFieldForm, boolean isNull) { @@ -499,9 +532,20 @@ private void setIspFormCode(String code, IspFieldForm ispFieldForm) { //肄붾뱶 �쑀�슚�꽦 泥댄겕 + this.verifyCode(code); ispFieldForm.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 setIspFormName(String title, IspFieldForm ispFieldForm) { // ISP紐� �쑀�슚�꽦 泥댄겕 //this.verifyTitle(title, null); -- Gitblit v1.8.0