| | |
| | | import kr.wisestone.owl.common.ExcelConditionCheck; |
| | | import kr.wisestone.owl.constant.Constants; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.domain.CompanyField; |
| | | import kr.wisestone.owl.domain.HostingField; |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.mapper.HostingFieldMapper; |
| | |
| | | import kr.wisestone.owl.web.condition.HostingFieldCondition; |
| | | import kr.wisestone.owl.web.form.HostingFieldForm; |
| | | import kr.wisestone.owl.web.view.ExcelView; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | |
| | | // Hosting 추가 |
| | | @Override |
| | | public HostingField add(HostingFieldForm HostingFieldForm) { |
| | | // url 유효성 체크 |
| | | this.verifyUrl(HostingFieldForm.getUrl(), null); |
| | | |
| | | HostingField HostingField = ConvertUtil.copyProperties(HostingFieldForm, HostingField.class); |
| | | hostingFieldRepository.saveAndFlush(HostingField); |
| | | return HostingField; |
| | | } |
| | | |
| | | // url 유효성 체크 |
| | | private void verifyUrl(String url, Long id) { |
| | | if (StringUtils.isEmpty(url)) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_NOT_URL)); |
| | | } |
| | | HostingField hostingField; |
| | | |
| | | if(id == null){ |
| | | hostingField = this.hostingFieldRepository.findByUrl(url); |
| | | } else { |
| | | hostingField = this.hostingFieldRepository.findByUrlAndIdNot(url,id); |
| | | } |
| | | |
| | | if (hostingField != null) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.COMPANYFIELD_USED_URL)); |
| | | } |
| | | } |
| | | |
| | | // Hosting 목록을 가져온다. |
| | |
| | | // Hosting 정로를 수정한다. |
| | | @Override |
| | | public void modify(HostingFieldForm HostingFieldForm) { |
| | | // url 유효성 체크 |
| | | this.verifyUrl(HostingFieldForm.getUrl(), HostingFieldForm.getId()); |
| | | |
| | | HostingField HostingField = ConvertUtil.copyProperties(HostingFieldForm, HostingField.class); |
| | | hostingFieldRepository.saveAndFlush(HostingField); |
| | | } |