提交 | 用户 | 时间
|
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.rest.mapper.RestMenuMapper"> |
|
4 |
|
|
5 |
<!-- 通用查询映射结果 --> |
|
6 |
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.sys.modular.rest.entity.RestMenu"> |
|
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="oracle"> |
|
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="getMenuIdsByRoleId" resultType="long"> |
|
65 |
select menu_id from |
|
66 |
sys_relation where role_id = #{roleId} ORDER BY menu_id |
|
67 |
</select> |
|
68 |
|
|
69 |
<select id="getMenuNamesByRoleId" resultType="string"> |
|
70 |
SELECT |
|
71 |
b.NAME as name |
|
72 |
FROM |
|
73 |
sys_relation a |
|
74 |
LEFT JOIN sys_menu b ON a.menu_id = b.menu_id |
|
75 |
WHERE |
|
76 |
role_id = #{roleId} |
|
77 |
ORDER BY b.menu_id |
|
78 |
</select> |
|
79 |
|
|
80 |
<select id="menuTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
81 |
SELECT |
|
82 |
m1.menu_id AS id, |
|
83 |
( |
|
84 |
CASE |
|
85 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
86 |
0 |
|
87 |
ELSE |
|
88 |
m2.menu_id |
|
89 |
END |
|
90 |
) AS pId, |
|
91 |
m1.name |
|
92 |
AS name, |
|
93 |
( |
|
94 |
CASE |
|
95 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
96 |
'true' |
|
97 |
ELSE |
|
98 |
'false' |
|
99 |
END |
|
100 |
) as "open" |
|
101 |
FROM |
|
102 |
sys_menu m1 |
|
103 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
104 |
ORDER BY |
|
105 |
m1.menu_id ASC |
|
106 |
</select> |
|
107 |
|
|
108 |
<select id="menuTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
109 |
SELECT |
|
110 |
m1.menu_id AS id, |
|
111 |
( |
|
112 |
CASE |
|
113 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
114 |
0 |
|
115 |
ELSE |
|
116 |
m2.menu_id |
|
117 |
END |
|
118 |
) AS pId, |
|
119 |
m1.name |
|
120 |
AS name, |
|
121 |
( |
|
122 |
CASE |
|
123 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
124 |
'1' |
|
125 |
ELSE |
|
126 |
'0' |
|
127 |
END |
|
128 |
) as "open" |
|
129 |
FROM |
|
130 |
sys_menu m1 |
|
131 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
132 |
ORDER BY |
|
133 |
m1.menu_id ASC |
|
134 |
</select> |
|
135 |
|
|
136 |
<select id="menuTreeListByMenuIds" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
137 |
SELECT |
|
138 |
m1.menu_id AS id, |
|
139 |
( |
|
140 |
CASE |
|
141 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
142 |
0 |
|
143 |
ELSE |
|
144 |
m2.menu_id |
|
145 |
END |
|
146 |
) AS "pId", |
|
147 |
m1.name AS name, |
|
148 |
( |
|
149 |
CASE |
|
150 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS |
|
151 |
NULL) THEN |
|
152 |
'true' |
|
153 |
ELSE |
|
154 |
'false' |
|
155 |
END |
|
156 |
) as "open", |
|
157 |
( |
|
158 |
CASE |
|
159 |
WHEN (m3.menu_id = 0 OR m3.menu_id |
|
160 |
IS NULL) THEN |
|
161 |
'false' |
|
162 |
ELSE |
|
163 |
'true' |
|
164 |
END |
|
165 |
) as "checked" |
|
166 |
FROM |
|
167 |
sys_menu m1 |
|
168 |
LEFT JOIN |
|
169 |
sys_menu m2 |
|
170 |
ON m1.pcode = m2.code |
|
171 |
left join ( |
|
172 |
SELECT |
|
173 |
menu_id |
|
174 |
FROM |
|
175 |
sys_menu |
|
176 |
WHERE |
|
177 |
menu_id IN |
|
178 |
<foreach collection="list" index="index" item="i" open="(" |
|
179 |
separator="," close=")"> |
|
180 |
#{i} |
|
181 |
</foreach> |
|
182 |
) m3 on m1.menu_id = m3.menu_id |
|
183 |
ORDER BY |
|
184 |
m1.menu_id ASC |
|
185 |
</select> |
|
186 |
|
|
187 |
<select id="menuTreeListByMenuIds" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
188 |
SELECT |
|
189 |
m1.menu_id AS id, |
|
190 |
( |
|
191 |
CASE |
|
192 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
193 |
0 |
|
194 |
ELSE |
|
195 |
m2.menu_id |
|
196 |
END |
|
197 |
) AS "pId", |
|
198 |
m1.name AS name, |
|
199 |
( |
|
200 |
CASE |
|
201 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS |
|
202 |
NULL) THEN |
|
203 |
'1' |
|
204 |
ELSE |
|
205 |
'0' |
|
206 |
END |
|
207 |
) as "open", |
|
208 |
( |
|
209 |
CASE |
|
210 |
WHEN (m3.menu_id = 0 OR m3.menu_id |
|
211 |
IS NULL) THEN |
|
212 |
'0' |
|
213 |
ELSE |
|
214 |
'1' |
|
215 |
END |
|
216 |
) as "checked" |
|
217 |
FROM |
|
218 |
sys_menu m1 |
|
219 |
LEFT JOIN |
|
220 |
sys_menu m2 |
|
221 |
ON m1.pcode = m2.code |
|
222 |
left join ( |
|
223 |
SELECT |
|
224 |
menu_id |
|
225 |
FROM |
|
226 |
sys_menu |
|
227 |
WHERE |
|
228 |
menu_id IN |
|
229 |
<foreach collection="list" index="index" item="i" open="(" |
|
230 |
separator="," close=")"> |
|
231 |
#{i} |
|
232 |
</foreach> |
|
233 |
) m3 on m1.menu_id = m3.menu_id |
|
234 |
ORDER BY |
|
235 |
m1.menu_id ASC |
|
236 |
</select> |
|
237 |
|
|
238 |
<delete id="deleteRelationByMenu"> |
|
239 |
delete from sys_relation where menu_id = #{menuId} |
|
240 |
</delete> |
|
241 |
|
|
242 |
<select id="getResUrlsByRoleId" resultType="string"> |
|
243 |
select URL from |
|
244 |
sys_relation rel |
|
245 |
inner join sys_menu m on rel.menu_id = m.menu_id |
|
246 |
where rel.role_id = #{roleId} |
|
247 |
</select> |
|
248 |
|
|
249 |
<select id="getMenusByRoleIds" resultType="cn.stylefeng.guns.base.pojo.node.MenuNode"> |
|
250 |
SELECT |
|
251 |
m1.menu_id AS id, |
|
252 |
m1.icon AS icon, |
|
253 |
( |
|
254 |
CASE |
|
255 |
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN |
|
256 |
0 |
|
257 |
ELSE |
|
258 |
m2.menu_id |
|
259 |
END |
|
260 |
) AS "parentId", |
|
261 |
m1.name as name, |
|
262 |
m1.url as url, |
|
263 |
m1.levels as levels, |
|
264 |
m1.menu_flag as ismenu, |
|
265 |
m1.system_type as systemType, |
|
266 |
m1.sort as num |
|
267 |
FROM |
|
268 |
sys_menu m1 |
|
269 |
LEFT join sys_menu m2 ON m1.pcode = m2.code |
|
270 |
INNER JOIN ( |
|
271 |
SELECT |
|
272 |
menu_id |
|
273 |
FROM |
|
274 |
sys_menu |
|
275 |
WHERE |
|
276 |
menu_id IN ( |
|
277 |
SELECT |
|
278 |
menu_id |
|
279 |
FROM |
|
280 |
sys_relation rela |
|
281 |
WHERE |
|
282 |
rela.role_id IN |
|
283 |
<foreach collection="list" index="index" item="i" open="(" separator="," close=")"> |
|
284 |
#{i} |
|
285 |
</foreach> |
|
286 |
) |
|
287 |
) m3 ON m1.menu_id = m3.menu_id |
|
288 |
where m1.menu_flag = 'Y' |
|
289 |
order by levels,m1.sort asc |
|
290 |
</select> |
|
291 |
|
|
292 |
<select id="selectMenuTree" resultType="java.util.Map"> |
|
293 |
select |
|
294 |
<include refid="Base_Column_List"/> |
|
295 |
from sys_menu |
|
296 |
where status = 'ENABLE' |
|
297 |
<if test="condition != null and condition != ''"> |
|
298 |
and (name like CONCAT('%',#{condition},'%') or code like CONCAT('%',#{condition},'%')) |
|
299 |
</if> |
|
300 |
<if test="level != null and level != ''"> |
|
301 |
and levels = #{level} |
|
302 |
</if> |
|
303 |
</select> |
|
304 |
|
|
305 |
<select id="selectMenuTree" resultType="java.util.Map" databaseId="oracle"> |
|
306 |
select |
|
307 |
<include refid="Base_Column_List"/> |
|
308 |
from sys_menu |
|
309 |
where status = 'ENABLE' |
|
310 |
<if test="condition != null and condition != ''"> |
|
311 |
and (name like '%' || #{condition} || '%' or code like '%' || #{condition} || '%') |
|
312 |
</if> |
|
313 |
<if test="level != null and level != ''"> |
|
314 |
and levels = #{level} |
|
315 |
</if> |
|
316 |
</select> |
|
317 |
|
|
318 |
<select id="getMenusLikePcodes" resultType="cn.stylefeng.guns.sys.modular.rest.entity.RestMenu"> |
|
319 |
select |
|
320 |
<include refid="Base_Column_List"></include> |
|
321 |
from sys_menu where 1 = 1 |
|
322 |
<if test="code != null and code != ''"> |
|
323 |
and pcodes LIKE CONCAT('%$[',#{code},'$]%') escape '$' |
|
324 |
</if> |
|
325 |
</select> |
|
326 |
|
|
327 |
<select id="getMenusLikePcodes" resultType="cn.stylefeng.guns.sys.modular.rest.entity.RestMenu" databaseId="oracle"> |
|
328 |
select |
|
329 |
<include refid="Base_Column_List"></include> |
|
330 |
from sys_menu where 1 = 1 |
|
331 |
<if test="code != null and code != ''"> |
|
332 |
and pcodes LIKE '%[' || #{code} || ']%' |
|
333 |
</if> |
|
334 |
</select> |
|
335 |
|
|
336 |
<select id="getMenusTypesByRoleIds" resultType="java.lang.String"> |
|
337 |
select DISTINCT system_type from |
|
338 |
sys_relation rel |
|
339 |
inner join sys_menu m on rel.menu_id = m.menu_id |
|
340 |
where rel.role_id in |
|
341 |
<foreach collection="list" index="index" item="i" open="(" separator="," close=")"> |
|
342 |
#{i} |
|
343 |
</foreach> |
|
344 |
</select> |
|
345 |
|
|
346 |
</mapper> |