提交 | 用户 | 时间
|
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.RestRoleMapper"> |
|
4 |
|
|
5 |
<!-- 通用查询映射结果 --> |
|
6 |
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.sys.modular.rest.entity.RestRole"> |
|
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="oracle"> |
|
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 |
<delete id="deleteRolesById"> |
|
45 |
delete from sys_relation where role_id = #{roleId} |
|
46 |
</delete> |
|
47 |
|
|
48 |
<select id="roleTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
49 |
select role_id AS id, pid as "pId", |
|
50 |
name as name, (case when (pid = 0 or pid is null) then 'true' |
|
51 |
else 'false' end) as "open" from sys_role |
|
52 |
</select> |
|
53 |
|
|
54 |
<select id="roleTreeList" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
55 |
select role_id AS id, pid as "pId", |
|
56 |
name as name, (case when (pid = 0 or pid is null) then '1' |
|
57 |
else '0' end) as "open" from sys_role |
|
58 |
</select> |
|
59 |
|
|
60 |
<select id="roleTreeListByRoleId" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode"> |
|
61 |
SELECT |
|
62 |
r.role_id as id, |
|
63 |
pid as "pId", |
|
64 |
name AS "name", |
|
65 |
( |
|
66 |
CASE |
|
67 |
WHEN (pid = 0 OR pid IS NULL) THEN |
|
68 |
'true' |
|
69 |
ELSE |
|
70 |
'false' |
|
71 |
END |
|
72 |
) as "open", |
|
73 |
( |
|
74 |
CASE |
|
75 |
WHEN (r1.role_id = 0 OR r1.role_id IS NULL) THEN |
|
76 |
'false' |
|
77 |
ELSE |
|
78 |
'true' |
|
79 |
END |
|
80 |
) as "checked" |
|
81 |
FROM |
|
82 |
sys_role r |
|
83 |
LEFT JOIN ( |
|
84 |
SELECT |
|
85 |
role_id |
|
86 |
FROM |
|
87 |
sys_role |
|
88 |
WHERE |
|
89 |
role_id IN |
|
90 |
|
|
91 |
<foreach collection="array" index="index" item="i" open="(" separator="," close=")"> |
|
92 |
#{i} |
|
93 |
</foreach> |
|
94 |
|
|
95 |
) r1 ON r.role_id = r1.role_id |
|
96 |
ORDER BY pid,sort ASC |
|
97 |
</select> |
|
98 |
|
|
99 |
<select id="roleTreeListByRoleId" resultType="cn.stylefeng.guns.base.pojo.node.ZTreeNode" databaseId="oracle"> |
|
100 |
SELECT |
|
101 |
r.role_id as id, |
|
102 |
pid as "pId", |
|
103 |
name AS "name", |
|
104 |
( |
|
105 |
CASE |
|
106 |
WHEN (pid = 0 OR pid IS NULL) THEN |
|
107 |
'1' |
|
108 |
ELSE |
|
109 |
'0' |
|
110 |
END |
|
111 |
) as "open", |
|
112 |
( |
|
113 |
CASE |
|
114 |
WHEN (r1.role_id = 0 OR r1.role_id IS NULL) THEN |
|
115 |
'0' |
|
116 |
ELSE |
|
117 |
'1' |
|
118 |
END |
|
119 |
) as "checked" |
|
120 |
FROM |
|
121 |
sys_role r |
|
122 |
LEFT JOIN ( |
|
123 |
SELECT |
|
124 |
role_id |
|
125 |
FROM |
|
126 |
sys_role |
|
127 |
WHERE |
|
128 |
role_id IN |
|
129 |
|
|
130 |
<foreach collection="array" index="index" item="i" open="(" separator="," close=")"> |
|
131 |
#{i} |
|
132 |
</foreach> |
|
133 |
|
|
134 |
) r1 ON r.role_id = r1.role_id |
|
135 |
ORDER BY pid,sort ASC |
|
136 |
</select> |
|
137 |
|
|
138 |
</mapper> |