SmartSceneDataMapper.xml
9.34 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
<?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.glsx.smart.dao.mapper.SmartSceneDataMapper">
<resultMap id="BaseResultMap" type="com.glsx.smart.dao.entity.SmartSceneData">
<!--@mbg.generated-->
<!--@Table smart_scene_data-->
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="scene_id" jdbcType="BIGINT" property="sceneId"/>
<result column="type" jdbcType="TINYINT" property="type"/>
<result column="sort" jdbcType="TINYINT" property="sort"/>
<result column="param_key" jdbcType="VARCHAR" property="paramKey"/>
<result column="param_value" jdbcType="VARCHAR" property="paramValue"/>
<result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, scene_id, `type`, sort, param_key, device_id, param_value
</sql>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update smart_scene_data
<trim prefix="set" suffixOverrides=",">
<trim prefix="scene_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.sceneId,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="`type` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.type,jdbcType=TINYINT}
</foreach>
</trim>
<trim prefix="sort = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.sort,jdbcType=TINYINT}
</foreach>
</trim>
<trim prefix="param_key = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.paramKey,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="param_value = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.paramValue,jdbcType=VARCHAR}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update smart_scene_data
<trim prefix="set" suffixOverrides=",">
<trim prefix="scene_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.sceneId != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.sceneId,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="`type` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.type != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.type,jdbcType=TINYINT}
</if>
</foreach>
</trim>
<trim prefix="sort = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.sort != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.sort,jdbcType=TINYINT}
</if>
</foreach>
</trim>
<trim prefix="param_key = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.paramKey != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.paramKey,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
<trim prefix="param_value = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.paramValue != null">
when id = #{item.id,jdbcType=BIGINT} then
#{item.paramValue,jdbcType=VARCHAR}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_scene_data
(scene_id, `type`, sort, param_key, device_id, param_value)
values
<foreach collection="list" item="item" separator=",">
(#{item.sceneId,jdbcType=BIGINT}, #{item.type,jdbcType=TINYINT},
#{item.sort,jdbcType=TINYINT}, #{item.paramKey,jdbcType=VARCHAR},
#{item.deviceId,jdbcType=VARCHAR}, #{item.paramValue,jdbcType=VARCHAR})
</foreach>
</insert>
<delete id="deleteBySceneId" parameterType="java.lang.Long">
delete from smart_scene_data
where scene_id = #{id,jdbcType=BIGINT}
</delete>
<select id="getBySceneId" parameterType="java.lang.Long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from smart_scene_data
where scene_id = #{sceneId,jdbcType=BIGINT}
</select>
<insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
parameterType="com.glsx.smart.dao.entity.SmartSceneData" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_scene_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
scene_id,
`type`,
sort,
param_key,
param_value,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
#{sceneId,jdbcType=BIGINT},
#{type,jdbcType=TINYINT},
#{sort,jdbcType=TINYINT},
#{paramKey,jdbcType=VARCHAR},
#{paramValue,jdbcType=VARCHAR},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=BIGINT},
</if>
scene_id = #{sceneId,jdbcType=BIGINT},
`type` = #{type,jdbcType=TINYINT},
sort = #{sort,jdbcType=TINYINT},
param_key = #{paramKey,jdbcType=VARCHAR},
param_value = #{paramValue,jdbcType=VARCHAR},
</trim>
</insert>
<insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
parameterType="com.glsx.smart.dao.entity.SmartSceneData" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_scene_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="sceneId != null">
scene_id,
</if>
<if test="type != null">
`type`,
</if>
<if test="sort != null">
sort,
</if>
<if test="paramKey != null and paramKey != ''">
param_key,
</if>
<if test="paramValue != null and paramValue != ''">
param_value,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="sceneId != null">
#{sceneId,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=TINYINT},
</if>
<if test="sort != null">
#{sort,jdbcType=TINYINT},
</if>
<if test="paramKey != null and paramKey != ''">
#{paramKey,jdbcType=VARCHAR},
</if>
<if test="paramValue != null and paramValue != ''">
#{paramValue,jdbcType=VARCHAR},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=BIGINT},
</if>
<if test="sceneId != null">
scene_id = #{sceneId,jdbcType=BIGINT},
</if>
<if test="type != null">
`type` = #{type,jdbcType=TINYINT},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=TINYINT},
</if>
<if test="paramKey != null and paramKey != ''">
param_key = #{paramKey,jdbcType=VARCHAR},
</if>
<if test="paramValue != null and paramValue != ''">
param_value = #{paramValue,jdbcType=VARCHAR},
</if>
</trim>
</insert>
</mapper>