RoleMapper.xml
5.74 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
<?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.runsa.portal.base.dao.RoleMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Role" >
<id column="roId" property="id" />
<result column="roName" property="name" />
<result column="roCode" property="code" />
<result column="roDesc" property="desc" />
<result column="ptValid" property="valid" />
<result column="roType" property="type" />
<result column="ptUpTime" property="uptime" />
<result column="ptUpdater" property="updater" />
<association property="platform" javaType="cn.runsa.portal.base.entity.Platform">
<id column="plId" property="id" />
<result column="plName" property="name"/>
</association>
<association property="platType" javaType="cn.runsa.portal.base.entity.PlatformType">
<id column="pltId" property="id" />
<result column="pltName" property="name"/>
</association>
</resultMap>
<select id="selectPageList" parameterType="cn.runsa.portal.base.entity.Role" resultType="cn.runsa.portal.base.entity.Role">
select t1.* from smRole t1 where 1=1
<if test="id!=null">
and t1.id=#{id}
</if>
<if test="pltId!=null">
and t1.pltId=#{pltId}
</if>
<if test="plId!=null">
and t1.plId=#{plId}
</if>
<if test="code!=null and code!='' ">
and t1.roCode=#{code}
</if>
<if test="name!=null and name!=''">
and t1.roName=#{name}
</if>
<if test="desc!=null and desc!=''">
and t1.roDesc=#{desc}
</if>
<if test="valid!=null ">
and t1.roValid=#{valid}
</if>
<if test="type!=null ">
and t1.roType=#{type}
</if>
<if test="startDate!=null and startDate!=''">
and ptUptime >= #{startDate}
</if>
<if test="endDate!=null and endDate!=''">
and ptUptime <= #{endDate}
</if>
<if test="updater!=null and updater!=''">
and t1.ptUpdater=#{updater}
</if>
limit #{offset},#{pageSize}
</select>
<select id="selectCount" parameterType="cn.runsa.portal.base.entity.Role" resultType="java.lang.Integer">
select count(*) from smRole t1 where 1=1
<if test="id!=null">
and t1.id=#{id}
</if>
<if test="pltId!=null">
and t1.pltId=#{pltId}
</if>
<if test="plId!=null">
and t1.plId=#{plId}
</if>
<if test="code!=null and code!='' ">
and t1.roCode=#{code}
</if>
<if test="name!=null and name!=''">
and t1.roName=#{name}
</if>
<if test="desc!=null and desc!=''">
and t1.roDesc=#{desc}
</if>
<if test="valid!=null ">
and t1.roValid=#{valid}
</if>
<if test="type!=null ">
and t1.roType=#{type}
</if>
<if test="startDate!=null and startDate!=''">
and ptUptime >= #{startDate}
</if>
<if test="endDate!=null and endDate!=''">
and ptUptime <= #{endDate}
</if>
<if test="updater!=null and updater!=''">
and t1.ptUpdater=#{updater}
</if>
</select>
<select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select t1.roId,t1.plId,t2.plName,t1.pltId,t3.pltName,t1.roName,t1.roCode,t1.roDesc,t1.ptValid,t1.roType,t1.ptUpdater,t1.ptUptime
from smRole t1
left join smPlatform t2 on t1.plId=t2.plId
left join smPlatformType t3 on t1.pltId=t3.pltId
where t1.roId=#{id}
</select>
<select id="existsCode" resultType="Boolean">
select count(*)
from smRole
where roCode=#{code}
<if test="id != null">
and roId<![CDATA[<>]]>#{id}
</if>
</select>
<select id="existsName" resultType="Boolean">
select count(*)
from smRole
where roName=#{name}
<if test="id != null">
and roId<![CDATA[<>]]>#{id}
</if>
</select>
<insert id="insert" parameterType="cn.runsa.portal.base.entity.Role">
<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into smRole(
roId,ptUpTime,ptUpdater
<if test="platType !=null and platType.id !=null ">
,pltId
</if>
<if test="platform !=null and platform.id !=null ">
,plId
</if>
<if test="code!=null and code!='' ">
,roCode
</if>
<if test="name!=null and name!=''">
,roName
</if>
<if test="desc!=null and desc!=''">
,roDesc
</if>
<if test="valid!=null ">
,ptValid
</if>
<if test="type!=null ">
,roType
</if>
)
values(
#{id},now(),#{updater}
<if test="platType !=null and platType.id !=null ">
,#{platType.id}
</if>
<if test="platform !=null and platform.id !=null ">
,#{platform.id}
</if>
<if test="code!=null and code!='' ">
,#{code}
</if>
<if test="name!=null and name!=''">
,#{name}
</if>
<if test="desc!=null and desc!=''">
,#{desc}
</if>
<if test="valid!=null ">
,#{valid}
</if>
<if test="type!=null ">
,#{type}
</if>
)
</insert>
<update id="update" parameterType="cn.runsa.portal.base.entity.Role" >
update smRole set ptUpTime=now(),ptUpdater=#{updater}
<if test="platType !=null and platType.id !=null ">
,pltId=#{platType.id}
</if>
<if test="platform !=null and platform.id !=null ">
,plId=#{platform.id}
</if>
<if test="code!=null and code!='' ">
,roCode=#{code}
</if>
<if test="name!=null and name!=''">
,roName=#{name}
</if>
<if test="desc!=null and desc!=''">
,roDesc=#{desc}
</if>
<if test="valid!=null ">
,ptValid=#{valid}
</if>
<if test="type!=null ">
,roType=#{type}
</if>
where roId=#{id}
</update>
<delete id="delete" parameterType="Integer" >
delete from smRole where roId=#{id}
</delete>
<insert id="insertMenuAction" parameterType="cn.runsa.portal.base.entity.Role">
insert into smRoleMenuAction(roId,meaId) values
<foreach collection="actions" item="item" separator=",">
(#{id},#{item.id})
</foreach>
</insert>
<delete id="deleteMenuAction" parameterType="Integer">
delete from smRoleMenuAction where roId=#{id}
</delete>
</mapper>