MenuMapper.xml
9.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?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="cn.runsa.portal.base.dao.MenuMapper" >
<cache eviction="LRU" flushInterval="60000" size="512" readOnly="true"/>
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Menu">
<id column="meId" property="id" />
<result column="pltId" property="pltId" />
<result column="meSys" property="sys" />
<result column="meName" property="name" />
<result column="meCode" property="code" />
<result column="meAsCode" property="asCode" />
<result column="meAsName" property="asname" />
<result column="meLevel" property="level" />
<result column="meParent" property="parent" />
<result column="meType" property="type" />
<result column="meUrl" property="url" />
<result column="meIcon" property="icon" />
<result column="meUptime" property="uptime" />
<result column="ptUpdater" property="updater" />
<result column="meInclude" property="include" />
<collection property="actions" javaType="ArrayList" ofType="cn.runsa.portal.base.entity.MenuAction">
<id column="meaId" property="id" />
<result column="meaName" property="name" />
<result column="meaCode" property="code" />
<result column="meaSort" property="sort" />
<result column="meaSelect" property="select"/>
</collection>
</resultMap>
<select id="selectList" parameterType="cn.runsa.portal.base.entity.Menu" resultType="cn.runsa.portal.base.entity.Menu" useCache="false">
select * from smMenu where meDisable=0
<if test="id!=null">
and t1.meId=#{id}
</if>
<if test="pltId!=null">
and t1.pltId=#{pltId}
</if>
<if test="name!=null and name!=''">
and t1.meName=#{name}
</if>
<if test="code!=null and code!='' ">
and t1.meCode=#{code}
</if>
<if test="asname!=null and asname!=''">
and t1.meAsName=#{asname}
</if>
<if test="level!=null">
and t1.meLevel=#{level}
</if>
<if test="parent!=null">
and t1.meParent=#{parent}
</if>
<if test="type!=null">
and t1.meType=#{type}
</if>
<if test="url!=null and url!=''">
and t1.meUrl=#{url}
</if>
<if test="updater!=null and updater!=''">
and t1.ptUpdater=#{updater}
</if>
order by t1.meId desc
</select>
<!-- 按用户查询菜单/菜单动作(权限/shiro) -->
<select id="selectByUserIds" resultMap="BaseResultMap" useCache="true">
select t1.*,
(select count(*) from smMenu where meParent=t1.meId) meInclude,
t2.*
from smMenu t1
left join smMenuAction t2 on t1.meId=t2.meId and t2.meaId in(
select meaId from vUsersMenuAction where usId in
<foreach collection="array" item="usId" open="(" close=")" separator=",">
#{usId}
</foreach>
)
where t1.meId in (
select distinct t3.meParent
from vUsersMenuAction t1
inner join smMenuAction t2 on t1.meaId=t2.meaId
inner join smMenuInfo t3 on t3.meId=t2.meId
where t1.usId in
<foreach collection="array" item="usId" open="(" close=")" separator=",">
#{usId}
</foreach>
)
<if test="null!=limitParentId">
and t1.meId in (
select meId from smMenuInfo where meParent=#{limitParentId}
)
</if>
and t1.meType in(4,5) and t1.meDisable=0
order by t1.meParent,t1.meSort asc,t2.meaSort asc
</select>
<!-- 按用户查询菜单(首页菜单) -->
<select id="selectAllByUserIds" resultMap="BaseResultMap" useCache="true">
select *,
(select count(*) from smMenu where meParent=t1.meId) meInclude
from smMenu t1
<!-- left join smMenuAction t2 on t1.meId=t2.meId and t2.meaId in(
select meaId from vUsersMenuAction where usId in
<foreach collection="array" item="usId" open="(" close=")" separator=",">
#{usId}
</foreach>
) -->
where t1.meId in (
select distinct t3.meParent
from vUsersMenuAction t1
inner join smMenuAction t2 on t1.meaId=t2.meaId
inner join smMenuInfo t3 on t3.meId=t2.meId
where t1.usId in
<foreach collection="array" item="usId" open="(" close=")" separator=",">
#{usId}
</foreach>
) and t1.meDisable=0
order by t1.meParent,t1.meSort asc<!-- ,t2.meaSort asc -->
</select>
<select id="selectAllByParent" resultMap="BaseResultMap" useCache="true">
select *,
(select count(*) from smMenu where meParent=t1.meId) meInclude
from smMenu t1
<!-- left join smMenuAction t2 on t1.meId=t2.meId and t2.meaId in(
select meaId from vUsersMenuAction where usId in
<foreach collection="array" item="usId" open="(" close=")" separator=",">
#{usId}
</foreach>
) -->
where t1.meId in (
select distinct t3.meParent
from vUsersMenuAction t1
inner join smMenuAction t2 on t1.meaId=t2.meaId
inner join smMenuInfo t4 on t4.meId=t2.meId and t4.meParent=#{parent}
inner join smMenuInfo t3 on t3.meId=t2.meId
where t1.usId in
<foreach collection="userIds" item="usId" open="(" close=")" separator=",">
#{usId}
</foreach>
) and t1.meDisable=0
order by t1.meParent,t1.meSort asc<!-- ,t2.meaSort asc -->
</select>
<select id="selectByType" resultMap="BaseResultMap" useCache="true">
select *,
(select count(*) from smMenu where meParent=t1.meId) meInclude
from smMenu t1
where t1.meId in (
select distinct t3.meParent
from vUsersMenuAction t1
inner join smMenuAction t2 on t1.meaId=t2.meaId
inner join smMenuInfo t3 on t3.meId=t2.meId
where t1.usId = #{userId}
) and t1.meType=${type} and t1.meDisable=0 /*and t1.meParent is null*/
order by t1.meSort asc
</select>
<!-- 按平台类型,平台编号,和角色编号查询(当前角色动作是否选择) -->
<select id="selectByPlatAndRole" resultMap="BaseResultMap" useCache="false">
select t1.*,t2.*
<if test="roleId !=null and roleId > 0">
,t3.meaId meaSelect
</if>
from smMenu t1
left join (
select t1.*
from smMenuAction t1
inner join (
select meaId from smMenuActionPlatType where pltId=#{platType} and meaId not in(
select meaId from smPlatformMenuAction where plId=#{platId} and plmLimit=1
)
union
select meaId from smPlatformMenuAction where plId=#{platId} and plmAppend=1
) t2 on t1.meaId=t2.meaId
) t2 on t1.meId=t2.meId
<if test="roleId !=null and roleId > 0">
left join smRoleMenuAction t3 on t3.roId=#{roleId} and t3.meaId=t2.meaId
</if>
where t1.meId in (
select distinct t1.meParent
from smMenuInfo t1
inner join smMenuAction t2 on t1.meId=t2.meId
inner join (
select meaId from smMenuActionPlatType where pltId=#{platType} and meaId not in(
select meaId from smPlatformMenuAction where plId=#{platId} and plmLimit=1
)
union
select meaId from smPlatformMenuAction where plId=#{platId} and plmAppend=1
) t3 on t2.meaId=t3.meaId
) and t1.meDisable=0
order by t1.meParent asc,t1.meSort asc,t2.meaSort asc
</select>
<select id="selectByRoleIds" parameterType="list" resultMap="BaseResultMap">
select t3.* ,t2.*
from smRoleMenuAction t1
join smMenuAction t2 on t1.meaId=t2.meaId
join smMenu t3 on t2.meId=t3.meId and t3.meDisable=0
where t1.roId in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")" >
#{item}
</foreach>
</select>
<select id="selectAllChild" parameterType="cn.runsa.portal.base.entity.Menu" resultType="cn.runsa.portal.base.entity.Menu" useCache="false">
select distinct t2.*
from smMenuInfo t1
inner join smMenu t2 on t1.meId = t2.meId and t2.meDisable=0
where t1.meParent = #{id}
</select>
<select id="selectAllParent" parameterType="cn.runsa.portal.base.entity.Menu" resultType="cn.runsa.portal.base.entity.Menu" useCache="false">
select distinct t2.*
from smMenuInfo t1
join smMenu t2 on t1.meParent = t2.meId
where t1.meId = #{id}
</select>
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select *
from smMenu where meId=#{id}
</select>
<insert id="insert" parameterType="cn.runsa.portal.base.entity.Menu" useGeneratedKeys="true" keyProperty="id">
insert into smMenu(
meId,ptUpTime,ptUpdater
<if test="code!=null and code!='' ">
,meCode
</if>
<if test="name!=null and name!=''">
,meName
</if>
<if test="asname!=null and asname!=''">
,meAsName
</if>
<if test="level!=null ">
,meLevel
</if>
<if test="pltId!=null ">
,pltId
</if>
<if test="parent!=null ">
,meParent
</if>
<if test="type!=null ">
,meType
</if>
<if test="url!=null ">
,meUrl
</if>
)
values(
#{id},now(),#{updater}
<if test="code!=null and code!='' ">
,#{code}
</if>
<if test="name!=null and name!=''">
,#{name}
</if>
<if test="asname!=null and asname!=''">
,#{asname}
</if>
<if test="Level!=null">
,#{Level}
</if>
<if test="pltId!=null">
,#{pltId}
</if>
<if test="parent!=null ">
,#{parent}
</if>
<if test="type!=null ">
,#{type}
</if>
<if test="url!=null and url!=''">
,#{url}
</if>
)
</insert>
<update id="update" parameterType="cn.runsa.portal.base.entity.Menu" >
update smMenu set ptUpTime=now(),ptUpdater=#{updater}
<if test="code!=null and code!='' ">
,meCode=#{code}
</if>
<if test="name!=null and name!=''">
,meName=#{name}
</if>
<if test="asname!=null and asname!=''">
,meAsName=#{asname}
</if>
<if test="Level!=null">
,meLevel=#{Level}
</if>
<if test="pltId!=null">
,pltId=#{pltId}
</if>
<if test="parent!=null ">
,meParent=#{parent}
</if>
<if test="type!=null ">
,meType=#{type}
</if>
<if test="url!=null and url!=''">
,meUrl=#{url}
</if>
where meId = #{id}
</update>
<delete id="delete" parameterType="cn.runsa.portal.base.entity.Menu" >
delete smMenu where meId=#{id}
</delete>
</mapper>