From ec9c7e5582d4c20c35e7c3016d64a2213e9f6a50 Mon Sep 17 00:00:00 2001 From: minhee <alsdldlfrl@gmail.com> Date: 화, 15 3월 2022 12:12:17 +0900 Subject: [PATCH] - 파트너 엑셀 임포트 시 이메일 정규식표현 검사하는 코드 제거 - 이슈 상세페이지 setHideCompleteIssue null 체크 - api로 이슈 추가 시 이슈유형에 업체가 설정되어있지 않는경우 메시지 추가 --- src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java | 91 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 79 insertions(+), 12 deletions(-) diff --git a/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java index 38ad53c..245534d 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/HostingFieldServiceImpl.java @@ -31,6 +31,7 @@ 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 { @@ -81,11 +82,17 @@ } HostingField hostingField = ConvertUtil.copyProperties(HostingFieldForm, HostingField.class); + if (hostingField.getCode() != null && !hostingField.getCode().equals("")) { - hostingFieldRepository.saveAndFlush(hostingField); + try { + hostingFieldRepository.saveAndFlush(hostingField); + } catch (Exception e) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.HOSTING_CODE_USED_EXIST_VALUE)); + } } else { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.HOSTING_CODE_NOT_ENTER)); } + return hostingField; } @@ -139,7 +146,17 @@ HostingFieldForm.setEmail(emails.trim()); } HostingField HostingField = ConvertUtil.copyProperties(HostingFieldForm, HostingField.class); - hostingFieldRepository.saveAndFlush(HostingField); + + if (HostingField.getCode() != null && !HostingField.getCode().equals("")) { + try { + hostingFieldRepository.saveAndFlush(HostingField); + } catch (Exception e) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.HOSTING_CODE_USED_EXIST_VALUE)); + } + } else { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.HOSTING_CODE_NOT_ENTER)); + } + } // Hosting瑜� �궘�젣�븳�떎. @@ -304,7 +321,15 @@ HostingField hostingField = new HostingField(); ConvertUtil.copyProperties(saveHostingFieldForm, hostingField); - hostingField = this.hostingFieldRepository.saveAndFlush(hostingField); + if (hostingField.getCode() != null && !hostingField.getCode().equals("")) { + try { + hostingField = hostingFieldRepository.saveAndFlush(hostingField); + } catch (Exception e) { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.HOSTING_CODE_USED_EXIST_VALUE)); + } + } else { + throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.HOSTING_CODE_NOT_ENTER)); + } saveHostingFieldForm.setId(hostingField.getId()); } @@ -442,23 +467,54 @@ 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) { @@ -469,9 +525,20 @@ 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); -- Gitblit v1.8.0