SysRoleSmapper.xml
10 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
<?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.zteits.sys.mapper.smapper.SysRoleSmapper">
<resultMap id="BaseResultMap" type="com.zteits.sys.domain.SysRole" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="role_code" property="roleCode" jdbcType="CHAR" />
<result column="role_name" property="roleName" jdbcType="VARCHAR" />
<result column="role_desc" property="roleDesc" jdbcType="VARCHAR" />
<result column="sys_code" property="sysCode" jdbcType="VARCHAR" />
<result column="data_state" property="dataState" jdbcType="INTEGER" />
<result column="create_empid" property="createEmpid" jdbcType="VARCHAR" />
<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
<result column="modfiy_empid" property="modfiyEmpid" jdbcType="VARCHAR" />
<result column="modfiy_date" property="modfiyDate" jdbcType="TIMESTAMP" />
<result column="create_empname" property="createEmpname" jdbcType="VARCHAR" />
<result column="org_id" property="orgId" jdbcType="BIGINT" />
</resultMap>
<sql id="Base_Column_List">
id, role_code, role_name, role_desc, sys_code, data_state, create_empid, create_date,
modfiy_empid, modfiy_date, create_empname, org_id
</sql>
<update id="updateBatchSysRoles">
update sys_role
<set>
<if test="sysRole.roleCode != null">
role_code = #{sysRole.roleCode,jdbcType=CHAR},
</if>
<if test="sysRole.roleName != null">
role_name = #{sysRole.roleName,jdbcType=VARCHAR},
</if>
<if test="sysRole.roleDesc != null">
role_desc = #{sysRole.roleDesc,jdbcType=VARCHAR},
</if>
<if test="sysRole.dataState != null">
data_state = #{sysRole.dataState,jdbcType=INTEGER},
</if>
<if test="sysRole.modfiyEmpid != null">
modfiy_empid = #{sysRole.modfiyEmpid,jdbcType=VARCHAR},
</if>
modfiy_date =
<choose>
<when test="sysRole.modfiyDate != null">
#{sysRole.modfiyDate,jdbcType=TIMESTAMP},
</when>
<otherwise>
NOW()
</otherwise>
</choose>
</set>
<where>
<choose>
<when test="ids==null || ids.size==0">
1==2
</when>
<otherwise>
id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id,jdbcType=BIGINT}
</foreach>
</otherwise>
</choose>
AND sys_code = #{sysCode,jdbcType=VARCHAR}
</where>
</update>
<delete id="deleteBatchSysRoleByIds">
delete from sys_role
<where>
<choose>
<when test="ids==null or ids.size==0">
1==2
</when>
<otherwise>
id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id,jdbcType=BIGINT}
</foreach>
</otherwise>
</choose>
AND sys_code = #{sysCode,jdbcType=VARCHAR}
</where>
</delete>
<insert id="saveBatchSysRole">
insert into sys_role (role_code, role_name,
role_desc, sys_code, data_state,
create_empid, create_date, modfiy_empid,
modfiy_date)VALUES
<foreach collection="sysRoles" item="sysRole" index="index" separator=",">
(
<trim>
#{sysRole.roleCode,jdbcType=CHAR},
#{sysRole.roleName,jdbcType=VARCHAR},
#{sysRole.roleDesc,jdbcType=VARCHAR},
#{sysCode,jdbcType=VARCHAR},
<choose>
<when test="sysRole.dataState != null">
#{sysRole.dataState,jdbcType=INTEGER},
</when>
<otherwise>
1,
</otherwise>
</choose>
#{sysRole.createEmpid,jdbcType=VARCHAR},
<choose>
<when test="sysRole.createDate != null">
#{sysRole.createDate,jdbcType=TIMESTAMP},
</when>
<otherwise>
NOW(),
</otherwise>
</choose>
#{sysRole.modfiyEmpid,jdbcType=VARCHAR},
<choose>
<when test="sysRole.modfiyDate != null">
#{sysRole.modfiyDate,jdbcType=TIMESTAMP})
</when>
<otherwise>
NOW()
</otherwise>
</choose>
</trim>
)
</foreach>
</insert>
<!--通过角色名称查询是否存在-->
<select id="queryRoleExistByRoleName" parameterType="com.zteits.clouds.api.dto.sys.param.QueryRoleExistByRoleNameRequest"
resultType="java.lang.Integer">
SELECT
count(1)
FROM
sys_role a
WHERE a.data_state=1
and a.role_name=#{roleName,jdbcType=VARCHAR}
AND a.sys_code=#{sysCode,jdbcType=VARCHAR}
</select>
<select id="queryPageSysRole" resultMap="BaseResultMap" parameterType="com.zteits.sys.domain.SysRole">
select
<include refid="Base_Column_List"/>
from sys_role
<where>
sys_code = #{sysCode,jdbcType=VARCHAR}
<if test="sysRole.id != null">
and id= #{sysRole.id,jdbcType=BIGINT}
</if>
<if test="sysRole.roleCode != null and sysRole.roleCode !=''">
and role_code = #{sysRole.roleCode,jdbcType=CHAR}
</if>
<if test="sysRole.roleName != null and sysRole.roleName != ''">
and role_name like CONCAT('%',#{sysRole.roleName,jdbcType=VARCHAR},'%')
</if>
<if test="sysRole.roleDesc != null and sysRole.roleDesc != ''">
and role_desc = #{sysRole.roleDesc,jdbcType=VARCHAR}
</if>
<if test="sysRole.dataState != null">
and data_state = #{sysRole.dataState,jdbcType=INTEGER}
</if>
<if test="sysRole.createEmpid != null">
and create_empid = #{sysRole.createEmpid,jdbcType=VARCHAR}
</if>
<if test="sysRole.createDate != null">
and create_date = #{sysRole.createDate,jdbcType=TIMESTAMP}
</if>
<if test="sysRole.modfiyEmpid != null">
and modfiy_empid = #{sysRole.modfiyEmpid,jdbcType=VARCHAR}
</if>
<if test="sysRole.modfiyDate != null">
and modfiy_date = #{sysRole.modfiyDate,jdbcType=TIMESTAMP}
</if>
<if test="sysRole.orgId != null" >
and org_id=#{sysRole.orgId,jdbcType=BIGINT}
</if>
</where>
order by id desc
</select>
<!-- 通过用户Id查询角色信息 wangfs Edit-->
<select id="queryRolesByUserId" resultMap="BaseResultMap" parameterType="com.zteits.clouds.api.dto.sys.param.QueryRolesByUserIdRequest">
select
a.id,
a.role_name
from sys_role a ,sys_op_role b
where a.id=b.sys_role_id
and b.sys_op_id =#{id}
</select>
<!--通过sysCode查询角色列表 wangfs Edit-->
<select id="queryRoleBySysCode" resultMap="BaseResultMap" parameterType="com.zteits.clouds.api.dto.sys.param.SysRoleQueryByOpIdRequest">
select
<include refid="Base_Column_List"/>
from sys_role
where 1=1
and data_state = 1
and sys_code = #{sysCode,jdbcType=VARCHAR}
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
</select>
<select id="queryPageSysRoleForList" resultMap="BaseResultMap" parameterType="com.zteits.sys.domain.SysRole">
select
<include refid="Base_Column_List"/>
from sys_role
<where>
sys_code = #{sysCode,jdbcType=VARCHAR}
<if test="sysRole.id != null">
and id= #{sysRole.id,jdbcType=BIGINT}
</if>
<if test="sysRole.roleCode != null">
and role_code = #{sysRole.roleCode,jdbcType=CHAR}
</if>
<if test="sysRole.roleName != null">
and role_name = #{sysRole.roleName,jdbcType=VARCHAR}
</if>
<if test="sysRole.roleDesc != null">
and role_desc = #{sysRole.roleDesc,jdbcType=VARCHAR}
</if>
<if test="sysRole.dataState != null">
and data_state = #{sysRole.dataState,jdbcType=INTEGER}
</if>
<if test="sysRole.createEmpid != null">
and create_empid = #{sysRole.createEmpid,jdbcType=VARCHAR}
</if>
<if test="sysRole.createDate != null">
and create_date = #{sysRole.createDate,jdbcType=TIMESTAMP}
</if>
<if test="sysRole.modfiyEmpid != null">
and modfiy_empid = #{sysRole.modfiyEmpid,jdbcType=VARCHAR}
</if>
<if test="sysRole.modfiyDate != null">
and modfiy_date = #{sysRole.modfiyDate,jdbcType=TIMESTAMP}
</if>
<if test=""></if>
</where>
</select>
<select id="queryBatchSysRoleById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
from sys_role
<where>
sys_code = #{sysCode,jdbcType=VARCHAR}
AND id IN
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
<if test="dataStatus != null">
AND data_state = #{dataStatus,jdbcType=INTEGER}
</if>
</where>
</select>
</mapper>