提交 | 用户 | 时间
|
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.RoleMapper"> |
|
4 |
|
|
5 |
<!-- 通用查询映射结果 --> |
|
6 |
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.sys.modular.system.entity.Role"> |
|
7 |
<id column="role_id" property="roleId" /> |
|
8 |
<result column="pid" property="pid" /> |
|
9 |
<result column="name" property="name" /> |
|
10 |
<result column="description" property="description" /> |
|
11 |
<result column="sort" property="sort" /> |
|
12 |
<result column="version" property="version" /> |
|
13 |
<result column="create_time" property="createTime" /> |
|
14 |
<result column="update_time" property="updateTime" /> |
|
15 |
<result column="create_user" property="createUser" /> |
|
16 |
<result column="update_user" property="updateUser" /> |
|
17 |
</resultMap> |
|
18 |
|
|
19 |
<!-- 通用查询结果列 --> |
|
20 |
<sql id="Base_Column_List"> |
|
21 |
role_id AS "roleId", pid AS "pid", name AS "name", description AS "description", sort AS "sort", version AS "version", create_time AS "createTime", update_time AS "updateTime", create_user AS "createUser", update_user AS "updateUser" |
|
22 |
</sql> |
|
23 |
|
|
24 |
<select id="selectRoles" resultType="map"> |
|
25 |
select |
|
26 |
<include refid="Base_Column_List"/> |
|
27 |
from sys_role |
|
28 |
<if test="condition != null"> |
|
29 |
where name like CONCAT('%',#{condition},'%') |
|
30 |
</if> |
|
31 |
order by sort asc |
|
32 |
</select> |
|
33 |
|
|
34 |
<select id="selectRoles" resultType="map" databaseId="pgsql"> |
|
35 |
select |
|
36 |
<include refid="Base_Column_List"/> |
|
37 |
from sys_role |
|
38 |
<if test="condition != null"> |
|
39 |
where name like '%' || #{condition} || '%' |
|
40 |
</if> |
|
41 |
order by sort asc |
|
42 |
</select> |
|
43 |
|
|
44 |
<select id="selectRoles" resultType="map" databaseId="oracle"> |
|
45 |
select |
|
46 |
<include refid="Base_Column_List"/> |
|
47 |
from sys_role |
|
48 |
<if test="condition != null"> |
|
49 |
where name like '%' || #{condition} || '%' |
|
50 |
</if> |
|
51 |
order by sort asc |
|
52 |
</select> |
|
53 |
|
|
54 |
<delete id="deleteRolesById"> |
|
55 |
delete from sys_relation where role_id = #{roleId} |
|
56 |
</delete> |
|
57 |
|
|
58 |
<select id="roleTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
59 |
select role_id AS id, pid as "pId", |
|
60 |
name as name, (case when (pid = 0 or pid is null) then 'true' |
|
61 |
else 'false' end) as "open" from sys_role |
|
62 |
</select> |
|
63 |
|
|
64 |
<select id="roleTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="pgsql"> |
|
65 |
select role_id AS id, pid as "pId", |
|
66 |
name as name, (case when (pid = 0 or pid is null) then '1' |
|
67 |
else '0' end) as "open" from sys_role |
|
68 |
</select> |
|
69 |
|
|
70 |
<select id="roleTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
71 |
select role_id AS id, pid as "pId", |
|
72 |
name as name, (case when (pid = 0 or pid is null) then '1' |
|
73 |
else '0' end) as "open" from sys_role |
|
74 |
</select> |
|
75 |
|
|
76 |
<select id="roleTreeListByRoleId" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
77 |
SELECT |
|
78 |
r.role_id as id, |
|
79 |
pid as "pId", |
|
80 |
name AS "name", |
|
81 |
( |
|
82 |
CASE |
|
83 |
WHEN (pid = 0 OR pid IS NULL) THEN |
|
84 |
'true' |
|
85 |
ELSE |
|
86 |
'false' |
|
87 |
END |
|
88 |
) as "open", |
|
89 |
( |
|
90 |
CASE |
|
91 |
WHEN (r1.role_id = 0 OR r1.role_id IS NULL) THEN |
|
92 |
'false' |
|
93 |
ELSE |
|
94 |
'true' |
|
95 |
END |
|
96 |
) as "checked" |
|
97 |
FROM |
|
98 |
sys_role r |
|
99 |
LEFT JOIN ( |
|
100 |
SELECT |
|
101 |
role_id |
|
102 |
FROM |
|
103 |
sys_role |
|
104 |
WHERE |
|
105 |
role_id IN |
|
106 |
|
|
107 |
<foreach collection="array" index="index" item="i" open="(" separator="," close=")"> |
|
108 |
#{i} |
|
109 |
</foreach> |
|
110 |
|
|
111 |
) r1 ON r.role_id = r1.role_id |
|
112 |
ORDER BY pid,sort ASC |
|
113 |
</select> |
|
114 |
|
|
115 |
<select id="roleTreeListByRoleId" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="pgsql"> |
|
116 |
SELECT |
|
117 |
r.role_id as id, |
|
118 |
pid as "pId", |
|
119 |
name AS "name", |
|
120 |
( |
|
121 |
CASE |
|
122 |
WHEN (pid = 0 OR pid IS NULL) THEN |
|
123 |
'1' |
|
124 |
ELSE |
|
125 |
'0' |
|
126 |
END |
|
127 |
) as "open", |
|
128 |
( |
|
129 |
CASE |
|
130 |
WHEN (r1.role_id = 0 OR r1.role_id IS NULL) THEN |
|
131 |
'0' |
|
132 |
ELSE |
|
133 |
'1' |
|
134 |
END |
|
135 |
) as "checked" |
|
136 |
FROM |
|
137 |
sys_role r |
|
138 |
LEFT JOIN ( |
|
139 |
SELECT |
|
140 |
role_id |
|
141 |
FROM |
|
142 |
sys_role |
|
143 |
WHERE |
|
144 |
role_id IN |
|
145 |
|
|
146 |
<foreach collection="array" index="index" item="i" open="(" separator="," close=")"> |
|
147 |
#{i} |
|
148 |
</foreach> |
|
149 |
|
|
150 |
) r1 ON r.role_id = r1.role_id |
|
151 |
ORDER BY pid,sort ASC |
|
152 |
</select> |
|
153 |
|
|
154 |
<select id="roleTreeListByRoleId" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
155 |
SELECT |
|
156 |
r.role_id as id, |
|
157 |
pid as "pId", |
|
158 |
name AS "name", |
|
159 |
( |
|
160 |
CASE |
|
161 |
WHEN (pid = 0 OR pid IS NULL) THEN |
|
162 |
'1' |
|
163 |
ELSE |
|
164 |
'0' |
|
165 |
END |
|
166 |
) as "open", |
|
167 |
( |
|
168 |
CASE |
|
169 |
WHEN (r1.role_id = 0 OR r1.role_id IS NULL) THEN |
|
170 |
'0' |
|
171 |
ELSE |
|
172 |
'1' |
|
173 |
END |
|
174 |
) as "checked" |
|
175 |
FROM |
|
176 |
sys_role r |
|
177 |
LEFT JOIN ( |
|
178 |
SELECT |
|
179 |
role_id |
|
180 |
FROM |
|
181 |
sys_role |
|
182 |
WHERE |
|
183 |
role_id IN |
|
184 |
|
|
185 |
<foreach collection="array" index="index" item="i" open="(" separator="," close=")"> |
|
186 |
#{i} |
|
187 |
</foreach> |
|
188 |
|
|
189 |
) r1 ON r.role_id = r1.role_id |
|
190 |
ORDER BY pid,sort ASC |
|
191 |
</select> |
|
192 |
|
|
193 |
<select id="listRole" resultType="map"> |
|
194 |
select |
|
195 |
role_id as id, |
|
196 |
name, |
|
197 |
description |
|
198 |
from sys_role |
|
199 |
where 1=1 |
|
200 |
<if test="name != null and name != ''"> |
|
201 |
and name LIKE CONCAT('%', #{name},'%') |
|
202 |
</if> |
|
203 |
</select> |
|
204 |
|
|
205 |
<select id="listRole" resultType="map" databaseId="pgsql"> |
|
206 |
select |
|
207 |
role_id as id, |
|
208 |
name, |
|
209 |
description |
|
210 |
from sys_role |
|
211 |
where 1=1 |
|
212 |
<if test="name != null and name != ''"> |
|
213 |
and name LIKE '%' || #{name} || '%' |
|
214 |
</if> |
|
215 |
</select> |
|
216 |
|
|
217 |
<select id="listRole" resultType="map" databaseId="oracle"> |
|
218 |
select |
|
219 |
role_id as "id", |
|
220 |
name as "name", |
|
221 |
description as "description" |
|
222 |
from sys_role |
|
223 |
where 1=1 |
|
224 |
<if test="name != null and name != ''"> |
|
225 |
and name LIKE '%' || #{name} || '%' |
|
226 |
</if> |
|
227 |
</select> |
|
228 |
|
|
229 |
</mapper> |