src/main/java/kr/wisestone/owl/constant/MsgConstants.java
@@ -290,6 +290,7 @@ public static final String EMAIL_NOT_INVALID = "EMAIL_NOT_INVALID"; // 이메일 형식이 맞지 않습니다. public static final String IP_NOT_INVALID = "IP_NOT_INVALID"; // IP주소 형식이 맞지 않습니다. public static final String IP_START_NOT_LARGER_THAN_END = "IP_START_NOT_LARGER_THAN_END"; // 시작 IP가 끝 IP 보다 클 수 없습니다. public static final String COMPANY_EXIST_IP = "COMPANY_EXIST_IP"; // 해당 ip 대역대는 이미 존재합니다. public static final String PROJECT_NOT_INCLUDE_DEPARTMENT = "PROJECT_NOT_INCLUDE_DEPARTMENT"; // 선택한 부서 중 프로젝트에 참여하고 있지 않은 부서가 있습니다. public static final String PROJECT_DEPARTMENT_NOT_EQUAL_WORKFLOW = "PROJECT_DEPARTMENT_NOT_EQUAL_WORKFLOW"; // 해당 프로젝트에 속해있는 워크플로우의 담당부서는 프로젝트의 담당부서에서 제외시킬 수 없습니다. src/main/java/kr/wisestone/owl/mapper/CompanyFieldMapper.java
@@ -24,4 +24,7 @@ List<CompanyField> findByUrlsAndIdNot(CompanyFieldCondition companyFieldCondition); List<CompanyField> findByIps(CompanyFieldCondition companyFieldCondition); List<CompanyField> findByIpsAndIdNot(CompanyFieldCondition companyFieldCondition); } src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java
@@ -86,7 +86,7 @@ if (companyFieldForm.getIpStart() != null && companyFieldForm.getIpEnd() != null) { // 아이피 유효성 체크 this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd()); this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd(), null); } if (companyFieldForm.getUrl() != null) { @@ -119,21 +119,41 @@ * IP 유효성 체크 * @param ip String */ private void verifyIp(String ip, String ip2) { if (ip2 == null) { if (!StringUtils.isEmpty(ip)) { if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip)) { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID)); } private void verifyIp(String ip, String ip2, Long id) { if (!StringUtils.isEmpty(ip)) { if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip)) { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID)); } } else { if (!StringUtils.isEmpty(ip)) { long ipStart = ConvertUtil.ipToLong(ip); long ipEnd = ConvertUtil.ipToLong(ip2); if (ipEnd < ipStart) { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_START_NOT_LARGER_THAN_END)); } } if (!StringUtils.isEmpty(ip2)) { if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip2)) { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID)); } } if (!StringUtils.isEmpty(ip) && !StringUtils.isEmpty(ip2)) { long ipStart = ConvertUtil.ipToLong(ip); long ipEnd = ConvertUtil.ipToLong(ip2); if (ipEnd < ipStart) { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_START_NOT_LARGER_THAN_END)); } List<CompanyField> companyFields = Lists.newArrayList(); CompanyFieldCondition condition = new CompanyFieldCondition(); condition.setIpStart(String.valueOf(ipStart)); condition.setIpEnd(String.valueOf(ipEnd)); if (id != null) { condition.setId(id); companyFields = this.companyFieldMapper.findByIpsAndIdNot(condition); } else { companyFields = this.companyFieldMapper.findByIps(condition); } // IP대역대 중복 체크 if (companyFields != null && companyFields.size() > 0) { throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.COMPANY_EXIST_IP)); } } } @@ -276,6 +296,11 @@ public void modifyCompany(CompanyFieldForm companyFieldForm) { // 업체명 유효성 체크 this.verifyTitle(companyFieldForm.getName(), companyFieldForm.getId()); if (companyFieldForm.getIpStart() != null && companyFieldForm.getIpEnd() != null) { // 아이피 유효성 체크 this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd(), companyFieldForm.getId()); } if (companyFieldForm.getUrl() != null) { // url 유효성 체크 @@ -472,7 +497,7 @@ // 업체로 등록하기 위해 CompanyFieldForm 에 데이터를 셋팅한다. CompanyFieldForm newCompanyFieldForm = this.setCompanyFieldFormToExcelField(row, (rowIndex + 1), ispFieldMaps, hostingFieldMaps, companyTypeMaps, parentSectorMaps, childSectorMaps, regionMaps, statusMaps, headers); // ip 유효성 체크 this.verifyIp(newCompanyFieldForm.getIpStart(), newCompanyFieldForm.getIpEnd()); this.verifyIp(newCompanyFieldForm.getIpStart(), newCompanyFieldForm.getIpEnd(), null); companyFieldForms.add(newCompanyFieldForm); } @@ -651,7 +676,7 @@ if (ipEnd.contains(" ")) { ipEnd = ipEnd.replace(" ", ""); } this.verifyIp(ipEnd, null); //ip 유효성 검사 this.verifyIp(ipEnd, null, null); //ip 유효성 검사 companyFieldForm.setIpEnd(ipEnd); } @@ -662,7 +687,7 @@ if (ipStart.contains(" ")) { ipStart = ipStart.replace(" ", ""); } this.verifyIp(ipStart, null); //ip 유효성 검사 this.verifyIp(ipStart, null, null); //ip 유효성 검사 companyFieldForm.setIpStart(ipStart); } src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -566,7 +566,15 @@ // issueCustomFieldValueCondition.setIssueStatusType("CLOSE"); List<Map<String, Object>> results = Lists.newArrayList(); if (customFieldType.equals(IP_ADDRESS.toString()) && issueForm.getIssueCompanyFields() != null && issueForm.getIssueCompanyFields().size() > 0) { long ipValue = ConvertUtil.ipToLong(concatUseValue); long ipValue = 0; if (concatUseValue.contains(",")) { String[] arr = concatUseValue.split(","); for (String str : arr) { ipValue = ConvertUtil.ipToLong(str); } } else { ipValue = ConvertUtil.ipToLong(concatUseValue); } issueCustomFieldValueCondition.setUseValue(String.valueOf(ipValue)); // 하위이슈조건의 타입이 IP일 경우 같은 업체정보인 이슈 찾기 results = this.issueMapper.findByCustomFieldValueOfIp(issueCustomFieldValueCondition); src/main/java/kr/wisestone/owl/util/ConvertUtil.java
@@ -8,6 +8,7 @@ import kr.wisestone.owl.vo.CompanyFieldVo; import kr.wisestone.owl.vo.IspFieldVo; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -17,6 +18,7 @@ import java.lang.reflect.Method; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Pattern; public class ConvertUtil { static final Logger LOGGER = LoggerFactory.getLogger(ConvertUtil.class); @@ -565,11 +567,18 @@ */ public static long ipToLong(String ipAddress) { long result = 0; String[] ipAddressArr = ipAddress.split("\\."); String reg = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; if (!StringUtils.isEmpty(ipAddress) && !Pattern.matches(reg, ipAddress)) { return result; } else { String[] ipAddressArr = ipAddress.split("\\."); for (int i=0; i<ipAddressArr.length; i++) { result += Integer.parseInt(ipAddressArr[i]) * Math.pow(256, 3-i); for (int i=0; i<ipAddressArr.length; i++) { result += Integer.parseInt(ipAddressArr[i]) * Math.pow(256, 3-i); } } return result; } src/main/resources/mybatis/query-template/companyField-template.xml
@@ -107,4 +107,39 @@ AND cf.id not like CONCAT('%',#{id},'%') </if> </select> <select id="findByIps" resultType="kr.wisestone.owl.domain.CompanyField" parameterType="kr.wisestone.owl.web.condition.CompanyFieldCondition"> SELECT cf.id as id, cf.name as name, cf.email as email, cf.url as url FROM company_field cf WHERE 1=1 <choose> <when test="ipStart != null and ipStart != '' and ipEnd != null and ipEnd != ''"> AND INET_ATON(cf.ip_start) BETWEEN #{ipStart} AND #{ipEnd} OR INET_ATON(cf.ip_end) BETWEEN #{ipStart} AND #{ipEnd} </when> </choose> </select> <select id="findByIpsAndIdNot" resultType="kr.wisestone.owl.domain.CompanyField" parameterType="kr.wisestone.owl.web.condition.CompanyFieldCondition"> SELECT cf.id as id, cf.name as name, cf.email as email, cf.url as url FROM company_field cf WHERE 1=1 <choose> <when test="ipStart != null and ipStart != '' and ipEnd != null and ipEnd != ''"> AND (INET_ATON(cf.ip_start) BETWEEN #{ipStart} AND #{ipEnd} OR INET_ATON(cf.ip_end) BETWEEN #{ipStart} AND #{ipEnd}) </when> </choose> <if test="id != '' and id != null"> AND cf.id not like CONCAT('%',#{id},'%') </if> </select> </mapper> src/main/webapp/WEB-INF/i18n/messages_ko_KR.properties
@@ -272,3 +272,4 @@ EMAIL_NOT_INVALID=\uC774\uBA54\uC77C \uD615\uC2DD\uC774 \uB9DE\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. IP_NOT_INVALID=IP\uC8FC\uC18C \uD615\uC2DD\uC774 \uB9DE\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. IP_START_NOT_LARGER_THAN_END=\uC2DC\uC791 IP\uAC00 \uB05D IP \uBCF4\uB2E4 \uD074 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. COMPANY_EXIST_IP=\uD574\uB2F9 ip \uB300\uC5ED\uB300\uB294 \uC774\uBBF8 \uC874\uC7AC\uD569\uB2C8\uB2E4. src/main/webapp/assets/styles/main.css
@@ -1484,13 +1484,6 @@ max-width: 25%; } .col-lg-3-2 { -webkit-box-flex: 0; -ms-flex: 0 0 25%; flex: 0 0 32.4%; max-width: 32.4%; } .col-lg-4 { -webkit-box-flex: 0; -ms-flex: 0 0 33.3333333333%; @@ -7778,6 +7771,10 @@ .ml-5, .mx-5 { margin-left: 3rem !important; } .ml--4 { margin-left: -4px !important; } .ml--12 { @@ -28596,6 +28593,10 @@ margin-top: -14px; !important; } .mr--4 { margin-right: -4px !important; } .ml-10 { margin-left: 10px !important; } src/main/webapp/views/issue/issueAdd.html
@@ -484,7 +484,7 @@ </div>--> </div> </div> <div class="col-lg-3-2"> <div class="col-lg-4"> <div class="form-group mgb5"> <label for="companyFieldUrlAddForm" class="issue-label"><span translate="companyField.url">url</span></label> <input id="companyFieldUrlAddForm" @@ -510,16 +510,16 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipStart" disabled > <div ng-if="issueAddForm.ipStart.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. </div> </div> </div> <div class="mt-30"> <div class="mt-30 ml--4 mr--4"> <label class="issue-label">~</label> </div> <div class="col-lg-2 mt-1"> @@ -531,9 +531,9 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipEnd" disabled > <div ng-if="issueAddForm.ipEnd.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. src/main/webapp/views/issue/issueAddDown.html
@@ -450,7 +450,7 @@ </div>--> </div> </div> <div class="col-lg-3-2"> <div class="col-lg-4"> <div class="form-group mgb5"> <label for="companyFieldUrlAddForm" class="issue-label"><span translate="companyField.url">url</span></label> <input id="companyFieldUrlAddForm" @@ -476,16 +476,16 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipStart" disabled > <div ng-if="issueAddDownForm.ipStart.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. </div> </div> </div> <div class="mt-30"> <div class="mt-30 ml--4 mr--4"> <label class="issue-label">~</label> </div> <div class="col-lg-2 mt-1"> @@ -497,9 +497,9 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipEnd" disabled > <div ng-if="issueAddDownForm.ipEnd.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. src/main/webapp/views/issue/issueAddRelation.html
@@ -453,7 +453,7 @@ </div>--> </div> </div> <div class="col-lg-3-2"> <div class="col-lg-4"> <div class="form-group mgb5"> <label for="companyFieldUrlAddForm" class="issue-label"><span translate="companyField.url">url</span></label> <input id="companyFieldUrlAddForm" @@ -479,16 +479,16 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipStart" disabled > <div ng-if="issueAddRelationForm.ipStart.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. </div> </div> </div> <div class="mt-30"> <div class="mt-30 ml--4 mr--4"> <label class="issue-label">~</label> </div> <div class="col-lg-2 mt-1"> @@ -500,9 +500,9 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipEnd" disabled > <div ng-if="issueAddRelationForm.ipEnd.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. src/main/webapp/views/issue/issueModify.html
@@ -482,7 +482,7 @@ </div>--> </div> </div> <div class="col-lg-3-2"> <div class="col-lg-4"> <div class="form-group mgb5"> <label for="companyFieldUrlAddForm" class="issue-label"><span translate="companyField.url">url</span></label> <input id="companyFieldUrlAddForm" @@ -508,16 +508,16 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipStart" disabled > <div ng-if="issueModifyForm.ipStart.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다. </div> </div> </div> <div class="mt-30"> <div class="mt-30 ml--4 mr--4"> <label class="issue-label">~</label> </div> <div class="col-lg-2 mt-1"> @@ -529,9 +529,9 @@ class="form-control" kr-input ng-pattern="/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/" placeholder="IP 주소 형식만 입력 가능합니다." autocomplete="off" ng-model="vm.ipEnd" disabled > <div ng-if="issueModifyForm.ipEnd.$error.pattern" class="help-block form-text text-danger" translate="common.invalidipAdressFormat">IP주소 형식이 맞지 않습니다.