提交 | 用户 | 时间
|
1ac2bc
|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
懒 |
2 |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|
3 |
<mapper namespace="cn.stylefeng.guns.sys.modular.system.mapper.MenuMapper"> |
|
4 |
|
|
5 |
<!-- 通用查询映射结果 --> |
|
6 |
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.sys.modular.system.entity.Menu"> |
|
7 |
<id column="menu_id" property="menuId"/> |
|
8 |
<result column="code" property="code"/> |
|
9 |
<result column="pcode" property="pcode"/> |
|
10 |
<result column="pcodes" property="pcodes"/> |
|
11 |
<result column="name" property="name"/> |
|
12 |
<result column="icon" property="icon"/> |
|
13 |
<result column="url" property="url"/> |
|
14 |
<result column="sort" property="sort"/> |
|
15 |
<result column="levels" property="levels"/> |
|
16 |
<result column="menu_flag" property="menuFlag"/> |
|
17 |
<result column="description" property="description"/> |
|
18 |
<result column="status" property="status"/> |
|
19 |
<result column="new_page_flag" property="newPageFlag"/> |
|
20 |
<result column="open_flag" property="openFlag"/> |
|
21 |
<result column="create_time" property="createTime"/> |
|
22 |
<result column="update_time" property="updateTime"/> |
|
23 |
<result column="create_user" property="createUser"/> |
|
24 |
<result column="update_user" property="updateUser"/> |
|
25 |
</resultMap> |
|
26 |
|
|
27 |
<!-- 通用查询结果列 --> |
|
28 |
<sql id="Base_Column_List"> |
|
29 |
menu_id AS "menuId", code AS "code", pcode AS "pcode", pcodes AS "pcodes", name AS "name", icon AS "icon", url AS "url", sort AS "sort", levels AS "levels", menu_flag AS "menuFlag", description AS "description", status AS "status", new_page_flag AS "newPageFlag", open_flag AS "openFlag", create_time AS "createTime", update_time AS "updateTime", create_user AS "createUser", update_user AS "updateUser" |
|
30 |
</sql> |
|
31 |
|
|
32 |
<select id="selectMenus" resultType="map"> |
|
33 |
select |
|
34 |
<include refid="Base_Column_List"/> |
|
35 |
from sys_menu |
|
36 |
where status = 'ENABLE' |
|
37 |
<if test="condition != null and condition != ''"> |
|
38 |
and (name like CONCAT('%',#{condition},'%') or code like CONCAT('%',#{condition},'%')) |
|
39 |
</if> |
|
40 |
<if test="level != null and level != ''"> |
|
41 |
and levels = #{level} |
|
42 |
</if> |
|
43 |
<if test="menuId != null and menuId != 0"> |
|
44 |
and (menu_id = #{menuId} or menu_id in ( select menu_id from sys_menu where pcodes like CONCAT('%$[', #{code}, '$]%') escape '$' )) |
|
45 |
</if> |
|
46 |
</select> |
|
47 |
|
|
48 |
<select id="selectMenus" resultType="map" databaseId="pgsql"> |
|
49 |
select |
|
50 |
<include refid="Base_Column_List"/> |
|
51 |
from sys_menu |
|
52 |
where status = 'ENABLE' |
|
53 |
<if test="condition != null and condition != ''"> |
|
54 |
and (name like '%' || #{condition} || '%' or code like '%' || #{condition} || '%') |
|
55 |
</if> |
|
56 |
<if test="level != null and level != ''"> |
|
57 |
and levels = #{level} |
|
58 |
</if> |
|
59 |
<if test="menuId != null and menuId != 0"> |
|
60 |
and (menu_id = #{menuId} or menu_id in ( select menu_id from sys_menu where pcodes like '%[' || #{code} ']%' )) |
|
61 |
</if> |
|
62 |
</select> |
|
63 |
|
|
64 |
<select id="selectMenus" resultType="map" databaseId="oracle"> |
|
65 |
select |
|
66 |
<include refid="Base_Column_List"/> |
|
67 |
from sys_menu |
|
68 |
where status = 'ENABLE' |
|
69 |
<if test="condition != null and condition != ''"> |
|
70 |
and (name like '%' || #{condition} || '%' or code like '%' || #{condition} || '%') |
|
71 |
</if> |
|
72 |
<if test="level != null and level != ''"> |
|
73 |
and levels = #{level} |
|
74 |
</if> |
|
75 |
<if test="menuId != null and menuId != 0"> |
|
76 |
and (menu_id = #{menuId} or menu_id in ( select menu_id from sys_menu where pcodes like '%[' || #{code} ']%' )) |
|
77 |
</if> |
|
78 |
</select> |
|
79 |
|
|
80 |
<select id="getMenuIdsByRoleId" resultType="long"> |
|
81 |
select menu_id from |
|
82 |
sys_relation where role_id = #{roleId} |
|
83 |
</select> |
|
84 |
|
|
85 |
<select id="menuTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
86 |
SELECT |
|
87 |
m1.menu_id AS id, |
|
88 |
( |
|
89 |
CASE |
|
90 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
91 |
0 |
|
92 |
ELSE |
|
93 |
m2.menu_id |
|
94 |
END |
|
95 |
) AS pId, |
|
96 |
m1.name |
|
97 |
AS name, |
|
98 |
( |
|
99 |
CASE |
|
100 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
101 |
'true' |
|
102 |
ELSE |
|
103 |
'false' |
|
104 |
END |
|
105 |
) as "open" |
|
106 |
FROM |
|
107 |
sys_menu m1 |
|
108 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
109 |
ORDER BY |
|
110 |
m1.menu_id ASC |
|
111 |
</select> |
|
112 |
|
|
113 |
<select id="menuTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="pgsql"> |
|
114 |
SELECT |
|
115 |
m1.menu_id AS id, |
|
116 |
( |
|
117 |
CASE |
|
118 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
119 |
0 |
|
120 |
ELSE |
|
121 |
m2.menu_id |
|
122 |
END |
|
123 |
) AS pId, |
|
124 |
m1.name |
|
125 |
AS name, |
|
126 |
( |
|
127 |
CASE |
|
128 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
129 |
'1' |
|
130 |
ELSE |
|
131 |
'0' |
|
132 |
END |
|
133 |
) as "open" |
|
134 |
FROM |
|
135 |
sys_menu m1 |
|
136 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
137 |
ORDER BY |
|
138 |
m1.menu_id ASC |
|
139 |
</select> |
|
140 |
|
|
141 |
<select id="menuTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
142 |
SELECT |
|
143 |
m1.menu_id AS id, |
|
144 |
( |
|
145 |
CASE |
|
146 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
147 |
0 |
|
148 |
ELSE |
|
149 |
m2.menu_id |
|
150 |
END |
|
151 |
) AS pId, |
|
152 |
m1.name |
|
153 |
AS name, |
|
154 |
( |
|
155 |
CASE |
|
156 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
157 |
'1' |
|
158 |
ELSE |
|
159 |
'0' |
|
160 |
END |
|
161 |
) as "open" |
|
162 |
FROM |
|
163 |
sys_menu m1 |
|
164 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
165 |
ORDER BY |
|
166 |
m1.menu_id ASC |
|
167 |
</select> |
|
168 |
|
|
169 |
<select id="menuTreeListByMenuIds" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
170 |
SELECT |
|
171 |
m1.menu_id AS id, |
|
172 |
( |
|
173 |
CASE |
|
174 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
175 |
0 |
|
176 |
ELSE |
|
177 |
m2.menu_id |
|
178 |
END |
|
179 |
) AS "pId", |
|
180 |
m1.name AS name, |
|
181 |
( |
|
182 |
CASE |
|
183 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS |
|
184 |
NULL) THEN |
|
185 |
'true' |
|
186 |
ELSE |
|
187 |
'false' |
|
188 |
END |
|
189 |
) as "open", |
|
190 |
( |
|
191 |
CASE |
|
192 |
WHEN (m3.menu_id = 0 OR m3.menu_id |
|
193 |
IS NULL) THEN |
|
194 |
'false' |
|
195 |
ELSE |
|
196 |
'true' |
|
197 |
END |
|
198 |
) as "checked" |
|
199 |
FROM |
|
200 |
sys_menu m1 |
|
201 |
LEFT JOIN |
|
202 |
sys_menu m2 |
|
203 |
ON m1.pcode = m2.code |
|
204 |
left join ( |
|
205 |
SELECT |
|
206 |
menu_id |
|
207 |
FROM |
|
208 |
sys_menu |
|
209 |
WHERE |
|
210 |
menu_id IN |
|
211 |
<foreach collection="list" index="index" item="i" open="(" |
|
212 |
separator="," close=")"> |
|
213 |
#{i} |
|
214 |
</foreach> |
|
215 |
) m3 on m1.menu_id = m3.menu_id |
|
216 |
ORDER BY |
|
217 |
m1.menu_id ASC |
|
218 |
</select> |
|
219 |
|
|
220 |
<select id="menuTreeListByMenuIds" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="pgsql"> |
|
221 |
SELECT |
|
222 |
m1.menu_id AS id, |
|
223 |
( |
|
224 |
CASE |
|
225 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
226 |
0 |
|
227 |
ELSE |
|
228 |
m2.menu_id |
|
229 |
END |
|
230 |
) AS "pId", |
|
231 |
m1.name AS name, |
|
232 |
( |
|
233 |
CASE |
|
234 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS |
|
235 |
NULL) THEN |
|
236 |
'1' |
|
237 |
ELSE |
|
238 |
'0' |
|
239 |
END |
|
240 |
) as "open", |
|
241 |
( |
|
242 |
CASE |
|
243 |
WHEN (m3.menu_id = 0 OR m3.menu_id |
|
244 |
IS NULL) THEN |
|
245 |
'0' |
|
246 |
ELSE |
|
247 |
'1' |
|
248 |
END |
|
249 |
) as "checked" |
|
250 |
FROM |
|
251 |
sys_menu m1 |
|
252 |
LEFT JOIN |
|
253 |
sys_menu m2 |
|
254 |
ON m1.pcode = m2.code |
|
255 |
left join ( |
|
256 |
SELECT |
|
257 |
menu_id |
|
258 |
FROM |
|
259 |
sys_menu |
|
260 |
WHERE |
|
261 |
menu_id IN |
|
262 |
<foreach collection="list" index="index" item="i" open="(" |
|
263 |
separator="," close=")"> |
|
264 |
#{i} |
|
265 |
</foreach> |
|
266 |
) m3 on m1.menu_id = m3.menu_id |
|
267 |
ORDER BY |
|
268 |
m1.menu_id ASC |
|
269 |
</select> |
|
270 |
|
|
271 |
<select id="menuTreeListByMenuIds" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
272 |
SELECT |
|
273 |
m1.menu_id AS id, |
|
274 |
( |
|
275 |
CASE |
|
276 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
277 |
0 |
|
278 |
ELSE |
|
279 |
m2.menu_id |
|
280 |
END |
|
281 |
) AS "pId", |
|
282 |
m1.name AS name, |
|
283 |
( |
|
284 |
CASE |
|
285 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS |
|
286 |
NULL) THEN |
|
287 |
'1' |
|
288 |
ELSE |
|
289 |
'0' |
|
290 |
END |
|
291 |
) as "open", |
|
292 |
( |
|
293 |
CASE |
|
294 |
WHEN (m3.menu_id = 0 OR m3.menu_id |
|
295 |
IS NULL) THEN |
|
296 |
'0' |
|
297 |
ELSE |
|
298 |
'1' |
|
299 |
END |
|
300 |
) as "checked" |
|
301 |
FROM |
|
302 |
sys_menu m1 |
|
303 |
LEFT JOIN |
|
304 |
sys_menu m2 |
|
305 |
ON m1.pcode = m2.code |
|
306 |
left join ( |
|
307 |
SELECT |
|
308 |
menu_id |
|
309 |
FROM |
|
310 |
sys_menu |
|
311 |
WHERE |
|
312 |
menu_id IN |
|
313 |
<foreach collection="list" index="index" item="i" open="(" |
|
314 |
separator="," close=")"> |
|
315 |
#{i} |
|
316 |
</foreach> |
|
317 |
) m3 on m1.menu_id = m3.menu_id |
|
318 |
ORDER BY |
|
319 |
m1.menu_id ASC |
|
320 |
</select> |
|
321 |
|
|
322 |
<delete id="deleteRelationByMenu"> |
|
323 |
delete from sys_relation where menu_id = #{menuId} |
|
324 |
</delete> |
|
325 |
|
|
326 |
<select id="getResUrlsByRoleId" resultType="string"> |
|
327 |
select URL from |
|
328 |
sys_relation rel |
|
329 |
inner join sys_menu m on rel.menu_id = m.menu_id |
|
330 |
where rel.role_id = #{roleId} |
|
331 |
</select> |
|
332 |
|
|
333 |
<select id="getMenusByRoleIds" resultType="cn.stylefeng.guns.base.pojo.node.MenuNode"> |
|
334 |
SELECT |
|
335 |
m1.menu_id AS id, |
|
336 |
m1.code AS code, |
|
337 |
m1.icon AS icon, |
|
338 |
( |
|
339 |
CASE |
|
340 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
341 |
0 |
|
342 |
ELSE |
|
343 |
m2.menu_id |
|
344 |
END |
|
345 |
) AS "parentId", |
|
346 |
m1.name as name, |
|
347 |
m1.url as url, |
|
348 |
m1.levels as levels, |
|
349 |
m1.menu_flag as ismenu, |
|
350 |
m1.system_type as systemType, |
|
351 |
m1.sort as num |
|
352 |
FROM |
|
353 |
sys_menu m1 |
|
354 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
355 |
INNER JOIN ( |
|
356 |
SELECT |
|
357 |
menu_id |
|
358 |
FROM |
|
359 |
sys_menu |
|
360 |
WHERE |
|
361 |
menu_id IN ( |
|
362 |
SELECT |
|
363 |
menu_id |
|
364 |
FROM |
|
365 |
sys_relation rela |
|
366 |
WHERE |
|
367 |
rela.role_id IN |
|
368 |
<foreach collection="list" index="index" item="i" open="(" separator="," close=")"> |
|
369 |
#{i} |
|
370 |
</foreach> |
|
371 |
) |
|
372 |
) m3 ON m1.menu_id = m3.menu_id |
|
373 |
where m1.menu_flag = 'Y' |
|
374 |
order by levels,m1.sort asc |
|
375 |
</select> |
|
376 |
|
|
377 |
<select id="selectMenuTree" resultType="java.util.Map"> |
|
378 |
select |
|
379 |
<include refid="Base_Column_List"/> |
|
380 |
from sys_menu |
|
381 |
where status = 'ENABLE' |
|
382 |
<if test="condition != null and condition != ''"> |
|
383 |
and (name like CONCAT('%',#{condition},'%') or code like CONCAT('%',#{condition},'%')) |
|
384 |
</if> |
|
385 |
<if test="level != null and level != ''"> |
|
386 |
and levels = #{level} |
|
387 |
</if> |
|
388 |
</select> |
|
389 |
|
|
390 |
<select id="selectMenuTree" resultType="java.util.Map" databaseId="pgsql"> |
|
391 |
select |
|
392 |
<include refid="Base_Column_List"/> |
|
393 |
from sys_menu |
|
394 |
where status = 'ENABLE' |
|
395 |
<if test="condition != null and condition != ''"> |
|
396 |
and (name like '%' || #{condition} || '%' or code like '%' || #{condition} || '%') |
|
397 |
</if> |
|
398 |
<if test="level != null and level != ''"> |
|
399 |
and levels = cast(#{level} as int4) |
|
400 |
</if> |
|
401 |
</select> |
|
402 |
|
|
403 |
<select id="selectMenuTree" resultType="java.util.Map" databaseId="oracle"> |
|
404 |
select |
|
405 |
<include refid="Base_Column_List"/> |
|
406 |
from sys_menu |
|
407 |
where status = 'ENABLE' |
|
408 |
<if test="condition != null and condition != ''"> |
|
409 |
and (name like '%' || #{condition} || '%' or code like '%' || #{condition} || '%') |
|
410 |
</if> |
|
411 |
<if test="level != null and level != ''"> |
|
412 |
and levels = #{level} |
|
413 |
</if> |
|
414 |
</select> |
|
415 |
|
|
416 |
<select id="getMenusLikePcodes" resultType="cn.stylefeng.guns.sys.modular.system.entity.Menu"> |
|
417 |
select |
|
418 |
<include refid="Base_Column_List"></include> |
|
419 |
from sys_menu where 1 = 1 |
|
420 |
<if test="code != null and code != ''"> |
|
421 |
and pcodes LIKE CONCAT('%$[',#{code},'$]%') escape '$' |
|
422 |
</if> |
|
423 |
</select> |
|
424 |
|
|
425 |
<select id="getMenusLikePcodes" resultType="cn.stylefeng.guns.sys.modular.system.entity.Menu" databaseId="pgsql"> |
|
426 |
select |
|
427 |
<include refid="Base_Column_List"></include> |
|
428 |
from sys_menu where 1 = 1 |
|
429 |
<if test="code != null and code != ''"> |
|
430 |
and pcodes LIKE '%[' || #{code} || ']%' |
|
431 |
</if> |
|
432 |
</select> |
|
433 |
|
|
434 |
<select id="getMenusLikePcodes" resultType="cn.stylefeng.guns.sys.modular.system.entity.Menu" databaseId="oracle"> |
|
435 |
select |
|
436 |
<include refid="Base_Column_List"></include> |
|
437 |
from sys_menu where 1 = 1 |
|
438 |
<if test="code != null and code != ''"> |
|
439 |
and pcodes LIKE '%[' || #{code} || ']%' |
|
440 |
</if> |
|
441 |
</select> |
|
442 |
|
|
443 |
<select id="getMenusTypesByRoleIds" resultType="java.lang.String"> |
|
444 |
select DISTINCT system_type from |
|
445 |
sys_relation rel |
|
446 |
inner join sys_menu m on rel.menu_id = m.menu_id |
|
447 |
where rel.role_id in |
|
448 |
<foreach collection="list" index="index" item="i" open="(" separator="," close=")"> |
|
449 |
#{i} |
|
450 |
</foreach> |
|
451 |
</select> |
|
452 |
|
|
453 |
</mapper> |