PERMISSIONMapper.xml
8.3 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
<?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.tianbo.warehouse.dao.PERMISSIONMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.PERMISSION" >
<id column="permission_id" property="permissionId" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="permission_order" property="permissionOrder" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="ismenu" property="ismenu" jdbcType="BOOLEAN" />
<result column="hidden" property="hidden" jdbcType="BOOLEAN" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="path" property="path" jdbcType="VARCHAR" />
<result column="url" property="url" jdbcType="VARCHAR" />
<result column="method" property="method" jdbcType="VARCHAR" />
<result column="iconCls" property="iconCls" jdbcType="VARCHAR" />
<result column="component" property="component" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
permission_id, name, permission_order, description, ismenu,hidden,parent_id,
path, url, method, iconCls, component
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from permission
where permission_id = #{permissionId,jdbcType=INTEGER} ORDER BY permission_order
</select>
<select id="findAll" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from permission
<if test="name != '' and name !=null" >
where name = #{name, jdbcType=VARCHAR}
</if>
ORDER BY permission_order
</select>
<select id="getRolePermisson" resultMap="BaseResultMap" parameterType="java.lang.Integer">
SELECT P.*
FROM role R
LEFT JOIN role_permission RP ON R.role_id = RP.role_id
LEFT JOIN permission P ON RP.permission_id = P.permission_id
WHERE R.role_id=#{roleId,jdbcType=INTEGER}
ORDER BY P.ismenu,P.name,P.permission_order DESC
</select>
<select id="getAllMenus" resultMap="BaseResultMap" >
SELECT
P.*
FROM
permission P
WHERE
P.permission_id IN (
SELECT
RP.permission_id
FROM
role_permission RP
WHERE
RP.role_id IN (
SELECT
R.role_id
FROM
role R
WHERE
R.role_id IN (
SELECT
UR.role_id
FROM
user_role UR
WHERE
UR.user_id = #{userId,jdbcType=INTEGER} AND P.ismenu is TRUE
)
)
) ORDER BY P.permission_order
<!--select-->
<!--<include refid="Base_Column_List" />-->
<!--from permission where ismenu is TRUE ORDER BY permission_order-->
</select>
<select id="findRoleListByUrl" resultType="java.lang.String" parameterType="java.lang.String">
SELECT
R.role_name
FROM
permission P
LEFT JOIN role_permission RP ON P.permission_id = RP.permission_id
LEFT JOIN role R ON R.role_id= RP.role_id
where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
</select>
<select id="findByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT
P.*
FROM
permission P
WHERE
P.permission_id IN (
SELECT
RP.permission_id
FROM
role_permission RP
WHERE
RP.role_id IN (
SELECT
R.role_id
FROM
role R
WHERE
R.role_id IN (
SELECT
UR.role_id
FROM
user_role UR
WHERE
UR.user_id = #{userId,jdbcType=INTEGER}
)
)
) ORDER BY permission_order
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from permission
where permission_id = #{permissionId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.PERMISSION" >
insert into permission (permission_id, name, permission_order,
description, ismenu,hidden, parent_id,
path, url, method, iconCls,
component)
values (#{permissionId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{permissionOrder,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{ismenu,jdbcType=BOOLEAN},#{hidden,jdbcType=BOOLEAN},#{parentId,jdbcType=INTEGER},
#{path,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{iconCls,jdbcType=VARCHAR},
#{component,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.PERMISSION" >
insert into permission
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="permissionId != null" >
permission_id,
</if>
<if test="name != null" >
name,
</if>
<if test="permissionOrder != null" >
permission_order,
</if>
<if test="description != null" >
description,
</if>
<if test="ismenu != null" >
ismenu,
</if>
<if test="hidden != null" >
hidden,
</if>
<if test="parentId != null" >
parent_id,
</if>
<if test="path != null" >
path,
</if>
<if test="url != null" >
url,
</if>
<if test="method != null" >
method,
</if>
<if test="iconCls != null" >
iconCls,
</if>
<if test="component != null" >
component,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="permissionId != null" >
#{permissionId,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="permissionOrder != null" >
#{permissionOrder,jdbcType=VARCHAR},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
<if test="ismenu != null" >
#{ismenu,jdbcType=BOOLEAN},
</if>
<if test="hidden != null" >
#{hidden,jdbcType=BOOLEAN},
</if>
<if test="parentId != null" >
#{parentId,jdbcType=INTEGER},
</if>
<if test="path != null" >
#{path,jdbcType=VARCHAR},
</if>
<if test="url != null" >
#{url,jdbcType=VARCHAR},
</if>
<if test="method != null" >
#{method,jdbcType=VARCHAR},
</if>
<if test="iconCls != null" >
#{iconCls,jdbcType=VARCHAR},
</if>
<if test="component != null" >
#{component,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.PERMISSION" >
update permission
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="permissionOrder != null" >
permission_order = #{permissionOrder,jdbcType=VARCHAR},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="ismenu != null" >
ismenu = #{ismenu,jdbcType=BOOLEAN},
</if>
<if test="hidden != null" >
hidden = #{hidden,jdbcType=BOOLEAN},
</if>
<if test="parentId != null" >
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="path != null" >
path = #{path,jdbcType=VARCHAR},
</if>
<if test="url != null" >
url = #{url,jdbcType=VARCHAR},
</if>
<if test="method != null" >
method = #{method,jdbcType=VARCHAR},
</if>
<if test="iconCls != null" >
iconCls = #{iconCls,jdbcType=VARCHAR},
</if>
<if test="component != null" >
component = #{component,jdbcType=VARCHAR},
</if>
</set>
where permission_id = #{permissionId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.PERMISSION" >
update permission
set name = #{name,jdbcType=VARCHAR},
permission_order = #{permissionOrder,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
ismenu = #{ismenu,jdbcType=BOOLEAN},
hidden = #{hidden,jdbcType=BOOLEAN},
parent_id = #{parentId,jdbcType=INTEGER},
path = #{path,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
method = #{method,jdbcType=VARCHAR},
iconCls = #{iconCls,jdbcType=VARCHAR},
component = #{component,jdbcType=VARCHAR}
where permission_id = #{permissionId,jdbcType=INTEGER}
</update>
</mapper>