
--- src/main/resources/spring/mapper/host/host-SQL.xml
+++ src/main/resources/spring/mapper/host/host-SQL.xml
... | ... | @@ -1,6 +1,33 @@ |
1 | 1 |
<?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 |
<mapper namespace="com.takensoft.taken_bi_manager.host.dao.HostDAO"> |
4 |
+ <sql id="searchSQL"> |
|
5 |
+ <foreach item="item" index="index" collection="searchObjectList"> |
|
6 |
+ <choose> |
|
7 |
+ <when test="item.key == 'currentCode' and item.value != null and item.value != ''"> |
|
8 |
+ AND ( |
|
9 |
+ dh.dept_code IS NULL |
|
10 |
+ OR dh.dept_code != #{item.value} |
|
11 |
+ ) |
|
12 |
+ </when> |
|
13 |
+ <when test="item.type != null and item.type !='' and item.type == 'dates'"> |
|
14 |
+ AND #{item.value}::timestamp <![CDATA[<=]]> ${item.key}::timestamp |
|
15 |
+ AND ${item.key}::timestamp <![CDATA[<]]> #{item.value2}::timestamp + INTERVAL '1' DAY |
|
16 |
+ </when> |
|
17 |
+ <when test="item.key != null and item.key !='' and item.value != null and item.value != ''"> |
|
18 |
+ AND ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
19 |
+ </when> |
|
20 |
+ <when test="item.key == null and item.value != null and item.value !=''"> |
|
21 |
+ AND ( |
|
22 |
+ hi.host_nm LIKE CONCAT('%', #{item.value}, '%') |
|
23 |
+ OR hi.host_ip LIKE CONCAT('%', #{item.value}, '%') |
|
24 |
+ OR ui.user_nm LIKE CONCAT('%', #{item.value}, '%') |
|
25 |
+ ) |
|
26 |
+ </when> |
|
27 |
+ </choose> |
|
28 |
+ </foreach> |
|
29 |
+ </sql> |
|
30 |
+ |
|
4 | 31 |
<!-- 부서 목록 조회 --> |
5 | 32 |
<select id="selectHostList" parameterType="SearchVO" resultType="HostVO"> |
6 | 33 |
SELECT hi.host_code, |
... | ... | @@ -15,28 +42,11 @@ |
15 | 42 |
FROM host_info AS hi |
16 | 43 |
LEFT JOIN dept_host AS dh |
17 | 44 |
ON hi.host_code = dh.host_code |
45 |
+ LEFT JOIN user_info AS ui |
|
46 |
+ ON hi.rgtr_id = ui.user_id |
|
18 | 47 |
WHERE hi.use_yn = 'Y' |
19 | 48 |
<!-- 검색영역 --> |
20 |
- <foreach item="item" index="index" collection="searchObjectList"> |
|
21 |
- <choose> |
|
22 |
- <when test="item.key == 'currentCode' and item.value != null and item.value != ''"> |
|
23 |
- AND ( |
|
24 |
- dh.dept_code IS NULL |
|
25 |
- OR dh.dept_code != #{item.value} |
|
26 |
- ) |
|
27 |
- </when> |
|
28 |
- <when test="item.type != null and item.type !='' and item.type == 'dates'"> |
|
29 |
- AND #{item.value}::timestamp <![CDATA[<=]]> ${item.key}::timestamp |
|
30 |
- AND ${item.key}::timestamp <![CDATA[<]]> #{item.value2}::timestamp + INTERVAL '1' DAY |
|
31 |
- </when> |
|
32 |
- <when test="item.type != null and item.type !='' and item.value != null and item.value !='' and item.type == 'eq'"> |
|
33 |
- AND ${item.key} = #{item.value} |
|
34 |
- </when> |
|
35 |
- <when test="item.type != null and item.type !='' and item.value != null and item.value !=''"> |
|
36 |
- AND ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
37 |
- </when> |
|
38 |
- </choose> |
|
39 |
- </foreach> |
|
49 |
+ <include refid="searchSQL" /> |
|
40 | 50 |
<!-- 검색영역 끝 --> |
41 | 51 |
GROUP BY hi.host_code |
42 | 52 |
ORDER BY hi.reg_dt DESC |
... | ... | @@ -48,29 +58,11 @@ |
48 | 58 |
FROM host_info AS hi |
49 | 59 |
LEFT JOIN dept_host AS dh |
50 | 60 |
ON hi.host_code = dh.host_code |
61 |
+ LEFT JOIN user_info AS ui |
|
62 |
+ ON hi.rgtr_id = ui.user_id |
|
51 | 63 |
WHERE hi.use_yn = 'Y' |
52 | 64 |
<!-- 검색영역 --> |
53 |
- <foreach item="item" index="index" collection="searchObjectList"> |
|
54 |
- <choose> |
|
55 |
- <when test="item.key == 'currentCode' and item.value != null and item.value != ''"> |
|
56 |
- AND dh.dept_code != #{item.value} |
|
57 |
- </when> |
|
58 |
- <when test="item.type != null and item.type !='' and item.type == 'dates'"> |
|
59 |
- AND |
|
60 |
- #{item.value}::timestamp <![CDATA[<=]]> ${item.key}::timestamp |
|
61 |
- AND |
|
62 |
- ${item.key}::timestamp <![CDATA[<]]> #{item.value2}::timestamp + INTERVAL '1' DAY |
|
63 |
- </when> |
|
64 |
- <when test="item.type != null and item.type !='' and item.value != null and item.value !='' and item.type == 'eq'"> |
|
65 |
- AND |
|
66 |
- ${item.key} = #{item.value} |
|
67 |
- </when> |
|
68 |
- <when test="item.type != null and item.type !='' and item.value != null and item.value !=''"> |
|
69 |
- AND |
|
70 |
- ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
71 |
- </when> |
|
72 |
- </choose> |
|
73 |
- </foreach> |
|
65 |
+ <include refid="searchSQL" /> |
|
74 | 66 |
<!-- 검색영역 끝 --> |
75 | 67 |
</select> |
76 | 68 |
|
--- src/main/resources/spring/mapper/user/member-SQL.xml
+++ src/main/resources/spring/mapper/user/member-SQL.xml
... | ... | @@ -159,9 +159,20 @@ |
159 | 159 |
ON om.dept_code = oi.dept_code |
160 | 160 |
WHERE ui.use_at = true |
161 | 161 |
<foreach item="item" index="index" collection="searchObjectList"> |
162 |
- <if test="item.type != null and item.type !='' and item.key != null and item.key != '' and item.value != null and item.value != ''"> |
|
163 |
- AND ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
164 |
- </if> |
|
162 |
+ <choose> |
|
163 |
+ <when test="item.key == 'deptCode' and item.value == null"> |
|
164 |
+ AND om.dept_code IS NULL |
|
165 |
+ </when> |
|
166 |
+ <when test="item.type == 'string' and item.key != null and item.key != '' and item.value != null and item.value != ''"> |
|
167 |
+ AND ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
168 |
+ </when> |
|
169 |
+ <when test="item.key == null and item.value != null and item.value != ''"> |
|
170 |
+ AND ( |
|
171 |
+ ui.user_id LIKE CONCAT('%', #{item.value}, '%') |
|
172 |
+ OR ui.user_nm LIKE CONCAT('%', #{item.value}, '%') |
|
173 |
+ ) |
|
174 |
+ </when> |
|
175 |
+ </choose> |
|
165 | 176 |
</foreach> |
166 | 177 |
ORDER BY ui.creat_dt DESC |
167 | 178 |
LIMIT #{perPage} OFFSET ((#{currentPage} - 1) * #{perPage}) |
... | ... | @@ -227,9 +238,20 @@ |
227 | 238 |
ON om.dept_code = oi.dept_code |
228 | 239 |
WHERE ui.use_at = true |
229 | 240 |
<foreach item="item" index="index" collection="searchObjectList"> |
230 |
- <if test="item.type != null and item.type !='' and item.key != null and item.key != '' and item.value != null and item.value != ''"> |
|
231 |
- AND ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
232 |
- </if> |
|
241 |
+ <choose> |
|
242 |
+ <when test="item.key == 'deptCode' and item.value == null"> |
|
243 |
+ AND om.dept_code IS NULL |
|
244 |
+ </when> |
|
245 |
+ <when test="item.type == 'string' and item.key != null and item.key != '' and item.value != null and item.value != ''"> |
|
246 |
+ AND ${item.key} LIKE CONCAT('%', #{item.value}, '%') |
|
247 |
+ </when> |
|
248 |
+ <when test="item.key == null and item.value != null and item.value != ''"> |
|
249 |
+ AND ( |
|
250 |
+ ui.user_id LIKE CONCAT('%', #{item.value}, '%') |
|
251 |
+ OR ui.user_nm LIKE CONCAT('%', #{item.value}, '%') |
|
252 |
+ ) |
|
253 |
+ </when> |
|
254 |
+ </choose> |
|
233 | 255 |
</foreach> |
234 | 256 |
</select> |
235 | 257 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?