From 3c54a4671cf489fd2c32e24685338bc3590e8d4b Mon Sep 17 00:00:00 2001
From: minhee <alsdldlfrl@gmail.com>
Date: 화, 15 3월 2022 17:34:41 +0900
Subject: [PATCH] - api로 이슈 추가 시 사용자정의필드 타입으로 체크 => 정규식표현검사로 체크로 변경

---
 src/main/resources/mybatis/query-template/companyField-template.xml |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 105 insertions(+), 5 deletions(-)

diff --git a/src/main/resources/mybatis/query-template/companyField-template.xml b/src/main/resources/mybatis/query-template/companyField-template.xml
index 466d7e2..a4a8708 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,
@@ -19,18 +22,33 @@
         cf.child_sector_id as childSectorId,
         cf.region_id as regionId,
         cf.status_id as statusId,
-        cf.status_name as statusName
+        cf.status_name as statusName,
+        sf.name AS ispName,
+        hf.name AS hostingName
         FROM
         company_field cf
+        LEFT OUTER JOIN isp_field sf ON cf.isp_id = sf.id
+        LEFT OUTER JOIN hosting_field hf ON cf.hosting_id = hf.id
         WHERE 1=1
-        <if test="name != '' and name != null">
+        <if test="name != null and name != ''">
             AND cf.name like CONCAT('%',#{name},'%')
         </if>
-        <if test="id != '' and id != null">
+        <if test="id != null and id != ''">
             AND cf.id like CONCAT('%',#{id},'%')
         </if>
-        <if test="url != '' and id != url">
-            AND cf.url like CONCAT('%',#{url},'%')
+        <if test="url != null and url != ''">
+            AND cf.url LIKE CONCAT('%',#{url},'%')
+        </if>
+        <choose>
+            <when test="urls != null and urls.size != 0">
+                AND
+                <foreach collection="urls" item="item" index="index" separator="or" open="(" close=")">
+                    cf.url LIKE CONCAT('%',#{item},'%')
+                </foreach>
+            </when>
+        </choose>
+        <if test="ip != null and ip != ''">
+            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">
@@ -51,4 +69,86 @@
             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
+        <if test="url != null and url != ''">
+            AND cf.url LIKE CONCAT('%',#{url},'%')
+        </if>
+        <choose>
+            <when test="urls != null and urls.size != 0">
+                AND
+                <foreach collection="urls" 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
+        <if test="url != null and url != ''">
+            AND cf.url LIKE CONCAT('%',#{url},'%')
+        </if>
+        <choose>
+            <when test="urls != null and urls.size != 0">
+                AND
+                <foreach collection="urls" 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>
+
+    <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>
\ No newline at end of file

--
Gitblit v1.8.0