박정하 박정하 03-31
250331 박정하 이슈 내역 수정
@79b93b9dfafc0370d75167798669c97ece5e49f1
src/main/resources/spring/mapper/host/host-SQL.xml
--- src/main/resources/spring/mapper/host/host-SQL.xml
+++ src/main/resources/spring/mapper/host/host-SQL.xml
@@ -1,6 +1,33 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.takensoft.taken_bi_manager.host.dao.HostDAO">
+    <sql id="searchSQL">
+        <foreach item="item" index="index" collection="searchObjectList">
+            <choose>
+                <when test="item.key == 'currentCode' and item.value != null and item.value != ''">
+                    AND (
+                        dh.dept_code IS NULL
+                        OR dh.dept_code != #{item.value}
+                    )
+                </when>
+                <when test="item.type != null and item.type !='' and  item.type == 'dates'">
+                    AND #{item.value}::timestamp <![CDATA[<=]]> ${item.key}::timestamp
+                    AND ${item.key}::timestamp <![CDATA[<]]> #{item.value2}::timestamp + INTERVAL '1' DAY
+                </when>
+                <when test="item.key != null and item.key !='' and item.value != null and item.value != ''">
+                    AND ${item.key} LIKE CONCAT('%', #{item.value}, '%')
+                </when>
+                <when test="item.key == null and item.value != null and item.value !=''">
+                    AND (
+                        hi.host_nm LIKE CONCAT('%', #{item.value}, '%')
+                        OR hi.host_ip LIKE CONCAT('%', #{item.value}, '%')
+                        OR ui.user_nm LIKE CONCAT('%', #{item.value}, '%')
+                    )
+                </when>
+            </choose>
+        </foreach>
+    </sql>
+
     <!-- 부서 목록 조회 -->
     <select id="selectHostList" parameterType="SearchVO" resultType="HostVO">
         SELECT hi.host_code,
@@ -15,28 +42,11 @@
           FROM host_info AS hi
      LEFT JOIN dept_host AS dh
             ON hi.host_code = dh.host_code
+     LEFT JOIN user_info AS ui
+            ON hi.rgtr_id = ui.user_id
          WHERE hi.use_yn = 'Y'
         <!-- 검색영역 -->
-        <foreach item="item" index="index" collection="searchObjectList">
-            <choose>
-                <when test="item.key == 'currentCode' and item.value != null and item.value != ''">
-                    AND (
-                        dh.dept_code IS NULL
-                        OR dh.dept_code != #{item.value}
-                    )
-                </when>
-                <when test="item.type != null and item.type !='' and  item.type == 'dates'">
-                    AND #{item.value}::timestamp <![CDATA[<=]]> ${item.key}::timestamp
-                    AND ${item.key}::timestamp <![CDATA[<]]> #{item.value2}::timestamp + INTERVAL '1' DAY
-                </when>
-                <when test="item.type != null and item.type !='' and  item.value != null and item.value !='' and item.type == 'eq'">
-                    AND ${item.key} = #{item.value}
-                </when>
-                <when test="item.type != null and item.type !='' and  item.value != null and item.value !=''">
-                    AND ${item.key} LIKE CONCAT('%', #{item.value}, '%')
-                </when>
-            </choose>
-        </foreach>
+        <include refid="searchSQL" />
         <!-- 검색영역 끝 -->
         GROUP BY hi.host_code
         ORDER BY hi.reg_dt DESC
@@ -48,29 +58,11 @@
         FROM host_info AS hi
         LEFT JOIN dept_host AS dh
         ON hi.host_code = dh.host_code
+        LEFT JOIN user_info AS ui
+        ON hi.rgtr_id = ui.user_id
         WHERE hi.use_yn = 'Y'
         <!-- 검색영역 -->
-        <foreach item="item" index="index" collection="searchObjectList">
-            <choose>
-                <when test="item.key == 'currentCode' and item.value != null and item.value != ''">
-                    AND dh.dept_code != #{item.value}
-                </when>
-                <when test="item.type != null and item.type !='' and  item.type == 'dates'">
-                    AND
-                    #{item.value}::timestamp <![CDATA[<=]]> ${item.key}::timestamp
-                    AND
-                    ${item.key}::timestamp <![CDATA[<]]> #{item.value2}::timestamp + INTERVAL '1' DAY
-                </when>
-                <when test="item.type != null and item.type !='' and  item.value != null and item.value !='' and item.type == 'eq'">
-                    AND
-                    ${item.key} = #{item.value}
-                </when>
-                <when test="item.type != null and item.type !='' and  item.value != null and item.value !=''">
-                    AND
-                    ${item.key} LIKE CONCAT('%', #{item.value}, '%')
-                </when>
-            </choose>
-        </foreach>
+        <include refid="searchSQL" />
         <!-- 검색영역 끝 -->
     </select>
 
src/main/resources/spring/mapper/user/member-SQL.xml
--- src/main/resources/spring/mapper/user/member-SQL.xml
+++ src/main/resources/spring/mapper/user/member-SQL.xml
@@ -159,9 +159,20 @@
 			   ON om.dept_code = oi.dept_code
 			WHERE ui.use_at = true
 		<foreach item="item" index="index" collection="searchObjectList">
-			<if test="item.type != null and item.type !='' and item.key != null and item.key != '' and item.value != null and item.value != ''">
-				AND ${item.key} LIKE CONCAT('%', #{item.value}, '%')
-			</if>
+			<choose>
+				<when test="item.key == 'deptCode' and item.value == null">
+					AND om.dept_code IS NULL
+				</when>
+				<when test="item.type == 'string' and item.key != null and item.key != '' and item.value != null and item.value != ''">
+					AND ${item.key} LIKE CONCAT('%', #{item.value}, '%')
+				</when>
+				<when test="item.key == null and item.value != null and item.value != ''">
+					AND (
+					ui.user_id LIKE CONCAT('%', #{item.value}, '%')
+					OR ui.user_nm LIKE CONCAT('%', #{item.value}, '%')
+					)
+				</when>
+			</choose>
 		</foreach>
 		 ORDER BY ui.creat_dt DESC
 		LIMIT #{perPage} OFFSET ((#{currentPage} - 1) * #{perPage})
@@ -227,9 +238,20 @@
 		ON om.dept_code = oi.dept_code
 		WHERE ui.use_at = true
 		<foreach item="item" index="index" collection="searchObjectList">
-			<if test="item.type != null and item.type !='' and item.key != null and item.key != '' and item.value != null and item.value != ''">
-				AND ${item.key} LIKE CONCAT('%', #{item.value}, '%')
-			</if>
+			<choose>
+				<when test="item.key == 'deptCode' and item.value == null">
+					AND om.dept_code IS NULL
+				</when>
+				<when test="item.type == 'string' and item.key != null and item.key != '' and item.value != null and item.value != ''">
+					AND ${item.key} LIKE CONCAT('%', #{item.value}, '%')
+				</when>
+				<when test="item.key == null and item.value != null and item.value != ''">
+					AND (
+					ui.user_id LIKE CONCAT('%', #{item.value}, '%')
+					OR ui.user_nm LIKE CONCAT('%', #{item.value}, '%')
+					)
+				</when>
+			</choose>
 		</foreach>
 	</select>
 
Add a comment
List