From f2fcf329cea64d71c671f1ab17f17d1634d1464d Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 월, 07 3월 2022 17:08:23 +0900
Subject: [PATCH] - API로 이슈 추가 시 하위이슈처리기준 항목으로 동일한 업체 정보로 이슈 생성하여 하위이슈로 넣기 - 업체 테이블에 ip_start, ip_end 컬럼 추가

---
 src/main/resources/mybatis/query-template/companyField-template.xml |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/src/main/resources/mybatis/query-template/companyField-template.xml b/src/main/resources/mybatis/query-template/companyField-template.xml
index 61f27e8..4973732 100644
--- a/src/main/resources/mybatis/query-template/companyField-template.xml
+++ b/src/main/resources/mybatis/query-template/companyField-template.xml
@@ -11,6 +11,9 @@
         cf.tel as tel,
         cf.email as email,
         cf.url as url,
+        cf.ip_start as ipStart,
+        cf.ip_end as ipEnd,
+        concat(cf.ip_start, "~", cf.ip_end) AS ipRange,
         cf.memo as memo,
         cf.isp_id as ispId,
         cf.hosting_id as hostingId,
@@ -33,8 +36,16 @@
         <if test="id != '' and id != null">
             AND cf.id like CONCAT('%',#{id},'%')
         </if>
-        <if test="url != '' and id != url">
-            AND cf.url like CONCAT('%',#{url},'%')
+        <choose>
+            <when test="url != null and url.size != 0">
+                AND
+                <foreach collection="url" item="item" index="index" separator="or" open="(" close=")">
+                    cf.url LIKE CONCAT('%',#{item},'%')
+                </foreach>
+            </when>
+        </choose>
+        <if test="ip != '' and ip != null">
+            AND INET_ATON(cf.ip_start) <![CDATA[ <= ]]> #{ip} AND INET_ATON(cf.ip_end) >= #{ip}
         </if>
         ORDER BY cf.register_date DESC
         <if test="pageSize != '' and pageSize != null">
@@ -55,4 +66,45 @@
             AND cf.id like CONCAT('%',#{id},'%')
         </if>
     </select>
+
+    <select id="findByUrls" 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="url != null and url.size != 0">
+                AND
+                <foreach collection="url" item="item" index="index" separator="or" open="(" close=")">
+                    cf.url LIKE CONCAT('%',#{item},'%')
+                </foreach>
+            </when>
+        </choose>
+    </select>
+
+    <select id="findByUrlsAndIdNot" 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="url != null and url.size != 0">
+                AND
+                <foreach collection="url" item="item" index="index" separator="or" open="(" close=")">
+                    cf.url LIKE CONCAT('%',#{item},'%')
+                </foreach>
+            </when>
+        </choose>
+        <if test="id != '' and id != null">
+            AND cf.id not like CONCAT('%',#{id},'%')
+        </if>
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0