VariableMapper.xml
6.82 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
<?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.VariableMapper" >
<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Variable" >
<id column="vaId" property="id" />
<result column="vaCode" property="code" />
<result column="vaName" property="name" />
<result column="vaDesc" property="desc" />
<result column="vaType" property="type" />
<result column="vaSys" property="sys" />
<result column="vaBeginDate" property="begindate" />
<result column="vaEndDate" property="enddate" />
<result column="ptRemark" property="remark" />
<result column="ptRemark1" property="remark1" />
<result column="ptRemark2" property="remark2" />
<result column="ptRemark3" property="remark3" />
<result column="ptUpdater" property="updater" />
<result column="ptUptime" property="uptime" />
<collection property="plts" javaType="ArrayList" ofType="cn.runsa.portal.base.entity.Platform">
<id property="id" column="plId" />
<result property="name" column="plName"/>
</collection>
<collection property="items" javaType="ArrayList" ofType="cn.runsa.portal.base.entity.VarItem">
<id column="vaiId" property="id" />
<!-- <result column="vaId" property="vaId" /> -->
<result column="vaiCode" property="code" />
<result column="vaiName" property="name" />
<result column="vaiGroup" property="group" />
<result column="vaiParent" property="parent" />
<result column="vaiSort" property="sort" />
<result column="ptRemark" property="remark" />
<result column="ptRemark1" property="remark1" />
<result column="ptRemark2" property="remark2" />
<result column="ptRemark3" property="remark3" />
</collection>
</resultMap>
<select id="selectPageList" parameterType="cn.runsa.portal.base.entity.Variable" resultMap="BaseResultMap">
select t1.vaId,t1.vaCode,t1.vaName,t1.vaDesc,t1.vaType,t1.vaSys,t1.vaBeginDate,t1.vaEndDate,
t1.ptRemark,t1.ptRemark1,t1.ptRemark2,t1.ptRemark3,t1.ptUpdater,t1.ptUptime,
t3.plId,t3.plName
from mtVariable t1
left join mtVarPlatform t2 on t1.vaId = t2.vaId
left join smPlatform t3 on t2.plId = t3.plId
where 1=1
<if test="id!=null">
and t1.vaid=#{id}
</if>
<if test="code!=null and code!='' ">
and t1.vaCode=#{code}
</if>
<if test="name!=null and name!=''">
and t1.vaName=#{name}
</if>
<if test="desc!=null and desc!=''">
and t1.vaDesc=#{desc}
</if>
<if test="type!=null">
and t1.vaType=#{type}
</if>
<if test="updater!=null and updater!=''">
and t1.ptUpdater=#{type}
</if>
order by t1.vaId desc
limit #{offset},#{pageSize}
</select>
<select id="selectCount" parameterType="cn.runsa.portal.base.entity.Variable" resultType="java.lang.Integer">
select count(*) from mtVariable t1 where 1=1
<if test="id!=null">
and t1.vaid=#{id}
</if>
<if test="code!=null and code!='' ">
and t1.vaCode=#{code}
</if>
<if test="name!=null and name!=''">
and t1.vaName=#{name}
</if>
<if test="desc!=null and desc!=''">
and t1.vaDesc=#{desc}
</if>
<if test="type!=null">
and t1.vaType=#{type}
</if>
<if test="updater!=null and updater!=''">
and t1.ptUpdater=#{type}
</if>
</select>
<select id="selectList" parameterType="cn.runsa.portal.base.entity.Variable" resultMap="BaseResultMap">
select t1.*
from mtVariable t1
left join mtVarPlatform t2 on t1.vaId = t2.vaId
left join smPlatform t3 on t2.plId = t3.plId
where 1=1
<if test="id!=null">
and t1.vaid=#{id}
</if>
<if test="code!=null and code!='' ">
and t1.vaCode=#{code}
</if>
<if test="name!=null and name!=''">
and t1.vaName=#{name}
</if>
<if test="desc!=null and desc!=''">
and t1.vaDesc=#{desc}
</if>
<if test="type!=null">
and t1.vaType=#{type}
</if>
<if test="updater!=null and updater!=''">
and t1.ptUpdater=#{type}
</if>
order by t1.vaId desc
</select>
<select id="findById" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
SELECT
t1.vaId,
t1.vaCode,
t1.vaName,
t1.vaType,
t4.*,
t2.*
FROM
mtVariable t1
LEFT JOIN mtVarItem t2 ON t2.vaId = t1.vaId
LEFT JOIN mtVarPlatform t3 ON t3.vaId = t1.vaId
LEFT JOIN smPlatform t4 ON t4.plId = t3.plId
where t1.vaId=#{vaId}
ORDER BY
t2.vaiSort ASC
</select>
<insert id="insert" parameterType="cn.runsa.portal.base.entity.Variable">
<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into mtVariable(vaCode,vaName,vaDesc,vaType,vaSys
,vaBeginDate,vaEndDate,ptRemark,ptRemark1,ptRemark2
,ptRemark3,ptUpdater,ptUptime)
values(#{code},#{name},#{desc},#{type},#{sys},#{begindate},#{enddate},#{remark},
#{remark1},#{remark2},#{remark3},#{updater},now())
</insert>
<insert id="insertVarPlt" parameterType="cn.runsa.portal.base.entity.Variable">
<!-- delete from mtVarPlatform where vaId=#{id} -->
insert into mtVarPlatform (vaId,plId) values
<foreach collection="plts" item="plt" separator=",">
(#{id},#{plt.id})
</foreach>
</insert>
<update id="updateVar" parameterType="cn.runsa.portal.base.entity.Variable">
update mtVariable set ptUpTime=now(),ptUpdater=#{updater}
<if test="code!=null and code!=''">
,vaCode=#{code}
</if>
<if test="name!=null and name!=''">
,vaName=#{name}
</if>
<if test="desc!=null and desc!=''">
,vaDesc=#{desc}
</if>
<if test="type!=null">
,vaType=#{type}
</if>
<if test="sys!=null">
,vaSys=#{sys}
</if>
<if test="begindate!=null">
,vaBeginDate=#{begindate}
</if>
<if test="enddate!=null">
,vaEndDate=#{enddate}
</if>
<if test="remark!=null and remark!=''">
,ptRemark=#{remark}
</if>
<if test="remark1!=null and remark1!=''">
,ptRemark1=#{remark1}
</if>
<if test="remark2!=null and remark2!=''">
,ptRemark2=#{remark2}
</if>
<if test="remark3!=null and remark3!=''">
,ptRemark3=#{remark3}
</if>
where vaId = #{id}
</update>
<delete id="deleteVariable" parameterType="java.lang.Integer">
delete from mtVariable where vaId=#{vaId}
</delete>
<delete id="deleteVarItem" parameterType="java.lang.Integer">
delete from mtVarItem where vaId=#{vaId}
</delete>
<delete id="deletePlatForm" parameterType="java.lang.Integer">
delete from mtVarPlatform where vaId=#{vaId}
</delete>
<select id="existsName" resultType="java.lang.Integer" parameterType="java.lang.String" >
select
COUNT(*)
from mtVariable
where vaName = #{name,jdbcType=VARCHAR}
</select>
<select id="existsCode" resultType="java.lang.Integer" parameterType="java.lang.String" >
select
COUNT(*)
from mtVariable
where vaCode = #{code,jdbcType=VARCHAR}
</select>
</mapper>