RoleMapper.xml
6.5 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
<?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.com.glsx.shield.modules.mapper.RoleMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.shield.modules.entity.Role">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
<result column="role_permission_type" jdbcType="TINYINT" property="rolePermissionType"/>
<result column="max_user" jdbcType="INTEGER" property="maxUser"/>
<result column="repel_roles" jdbcType="VARCHAR" property="repelRoles"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="tenant_id" jdbcType="INTEGER" property="tenantId"/>
<result column="role_visibility" jdbcType="INTEGER" property="roleVisibility"/>
<!-- <result column="role_tenants" jdbcType="VARCHAR" property="roleTenants"/>-->
<result column="enable_status" jdbcType="TINYINT" property="enableStatus"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
id
, role_name, role_permission_type, max_user, repel_roles,
remark, tenant_id, role_visibility, enable_status, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_role
where del_flag = 0
and id = #{id}
</select>
<update id="logicDeleteById">
update t_role
set del_flag = -1
where id = #{id}
</update>
<select id="selectList" resultMap="BaseResultMap"
parameterType="cn.com.glsx.shield.modules.model.param.RoleSearch">
select
<include refid="Base_Column_List"/>
from t_role
where del_flag = 0
<if test="roleName != null and roleName != ''">
and role_name like concat('%',#{roleName},'%')
</if>
<if test="enableStatus != null">
and enable_status = #{enableStatus}
</if>
<if test="roleVisibility != null">
and role_visibility = #{roleVisibility}
</if>
order by id desc
</select>
<select id="selectAssignTenantsList" resultMap="BaseResultMap"
parameterType="cn.com.glsx.shield.modules.model.param.RoleSearch">
select * from (
select tr1.*
from t_role tr1
where tr1.del_flag = 0
and tr1.role_visibility = 0
union
select tr.*
from t_role tr,
t_role_tenant trt
where tr.del_flag = 0
and trt.del_flag = 0
and tr.role_visibility = 2
and tr.id = trt.role_id
and trt.tenant_id in (select trdp.ref_id from t_role_data_permission trdp where trdp.type = 0 and trdp.role_id =
#{roleId})
) tall where 1=1
<if test="roleName != null and roleName != ''">
and role_name like concat('%',#{roleName},'%')
</if>
<if test="enableStatus != null">
and enable_status = #{enableStatus}
</if>
order by id desc
</select>
<select id="selectVisibilityList" resultMap="BaseResultMap"
parameterType="cn.com.glsx.shield.modules.model.param.RoleSearch">
select * from (
select tr1.*
from t_role tr1
where tr1.del_flag = 0
and tr1.role_visibility = 0
union
select tr.*
from t_role tr,
t_role_tenant trt
where tr.del_flag = 0
and trt.del_flag = 0
and tr.role_visibility = 2
and tr.id = trt.role_id
and trt.tenant_id in
<foreach collection="tenantIds" open="(" close=")" separator="," item="tenantId">
#{tenantId}
</foreach>
) tall where 1=1
<if test="roleName != null and roleName != ''">
and role_name like concat('%',#{roleName},'%')
</if>
<if test="enableStatus != null">
and enable_status = #{enableStatus}
</if>
order by id desc
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_role
where del_flag = 0
and id in
<foreach collection="ids" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</select>
<select id="selectUserRoleList" resultType="cn.com.glsx.shield.modules.entity.Role">
select r.id id, r.role_name roleName, r.role_permission_type rolePermissionType
from t_role r,
t_user_role_relation urr
where r.del_flag = 0
and urr.del_flag = 0
and r.role_id = urr.role_id
and urr.user_id = #{userId}
</select>
<select id="selectCntByName" resultType="java.lang.Integer">
select count(role_name)
from t_role
where del_flag = 0
and role_name = #{roleName}
</select>
<select id="selectByName" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_role
where del_flag = 0
and role_name = #{roleName}
limit 1
</select>
<select id="selectByVisibilityType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_role
where del_flag = 0
and enable_status = 1
and role_visibility = #{roleVisibility}
</select>
<select id="selectRoleIdsByVisibilityType" resultMap="BaseResultMap">
select id
from t_role
where del_flag = 0
and enable_status = 1
and role_visibility = #{roleVisibility}
</select>
<select id="selectByTenantIds" resultMap="BaseResultMap">
select tr.*
from t_role tr,t_role_tenant trt
where tr.del_flag = 0
and trt.del_flag = 0
and tr.enable_status = 1
and tr.id = trt.role_id
and trt.tenant_id in
<foreach collection="tenantIds" open="(" close=")" separator="," item="tenantId">
#{tenantId}
</foreach>
order by tr.id
</select>
</mapper>