IotDeviceMapper.xml
10.2 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
<?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.zhonglai.luhui.device.mapper.IotDeviceMapper">
<resultMap type="IotDevice" id="IotDeviceResult">
<result property="active_time" column="active_time" />
<result property="client_id" column="client_id" />
<result property="completion_auth" column="completion_auth" />
<result property="create_by" column="create_by" />
<result property="create_time" column="create_time" />
<result property="del_flag" column="del_flag" />
<result property="firmware_version" column="firmware_version" />
<result property="img_url" column="img_url" />
<result property="is_shadow" column="is_shadow" />
<result property="latitude" column="latitude" />
<result property="location_way" column="location_way" />
<result property="longitude" column="longitude" />
<result property="name" column="name" />
<result property="network_address" column="network_address" />
<result property="network_ip" column="network_ip" />
<result property="remark" column="remark" />
<result property="rssi" column="rssi" />
<result property="status" column="status" />
<result property="summary" column="summary" />
<result property="things_model_value" column="things_model_value" />
<result property="update_by" column="update_by" />
<result property="update_time" column="update_time" />
<result property="product_id" column="product_id" />
<result property="mqtt_username" column="mqtt_username" />
<result property="payload_type" column="payload_type" />
<result property="things_model_config" column="things_model_config" />
<result property="listen_service_ip" column="listen_service_ip" />
<result property="device_life" column="device_life" />
<result property="data_update_time" column="data_update_time" />
<result property="operation_token" column="operation_token" />
<result property="label" column="label" />
<result property="sys_user_id" column="sys_user_id" />
</resultMap>
<sql id="selectIotDeviceVo">
select * from iot_device
</sql>
<select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult">
SELECT a.* FROM iot_device a
LEFT JOIN `sys_user` u ON u.user_id = a.sys_user_id
<where>
<if test="status !=null">
and a.`status` = #{status}
</if>
<if test="product_id !=null and product_id != ''">
and a.product_id = #{product_id}
</if>
<if test="mqtt_username !=null and mqtt_username != ''">
and a.mqtt_username = #{mqtt_username}
</if>
<if test="client_id != null and client_id != ''">
AND a.client_id like concat('%', #{client_id}, '%')
</if>
<if test="sys_user_id !=null">
and a.`sys_user_id` = #{sys_user_id}
</if>
<if test="params!=null and params.dataScope !=null and params.dataScope!=''">
<!-- 数据范围过滤 -->
${params.dataScope}
</if>
</where>
order by a.create_time desc
</select>
<select id="selectIotDeviceByClient_id" parameterType="String" resultMap="IotDeviceResult">
<include refid="selectIotDeviceVo"/>
where client_id = #{client_id}
</select>
<insert id="insertIotDevice" parameterType="IotDevice">
insert into iot_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="active_time != null">active_time,</if>
<if test="client_id != null and client_id != ''">client_id,</if>
<if test="completion_auth != null">completion_auth,</if>
<if test="create_by != null">create_by,</if>
<if test="del_flag != null">del_flag,</if>
<if test="firmware_version != null">firmware_version,</if>
<if test="img_url != null">img_url,</if>
<if test="is_shadow != null">is_shadow,</if>
<if test="latitude != null">latitude,</if>
<if test="location_way != null">location_way,</if>
<if test="longitude != null">longitude,</if>
<if test="name != null">`name`,</if>
<if test="network_address != null">network_address,</if>
<if test="network_ip != null">network_ip,</if>
<if test="remark != null">remark,</if>
<if test="rssi != null">rssi,</if>
<if test="status != null">status,</if>
<if test="summary != null">summary,</if>
<if test="things_model_value != null">things_model_value,</if>
<if test="update_by != null">update_by,</if>
<if test="update_time != null">update_time,</if>
<if test="product_id != null">product_id,</if>
<if test="mqtt_username != null">mqtt_username,</if>
<if test="payload_type != null">payload_type,</if>
<if test="things_model_config != null">things_model_config,</if>
<if test="device_life != null">device_life,</if>
<if test="data_update_time != null">data_update_time,</if>
<if test="sys_user_id != null">sys_user_id,</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="active_time != null">#{active_time},</if>
<if test="client_id != null and client_id != ''">#{client_id},</if>
<if test="completion_auth != null">#{completion_auth},</if>
<if test="create_by != null">#{create_by},</if>
<if test="del_flag != null">#{del_flag},</if>
<if test="firmware_version != null">#{firmware_version},</if>
<if test="img_url != null">#{img_url},</if>
<if test="is_shadow != null">#{is_shadow},</if>
<if test="latitude != null">#{latitude},</if>
<if test="location_way != null">#{location_way},</if>
<if test="longitude != null">#{longitude},</if>
<if test="name != null">#{name},</if>
<if test="network_address != null">#{network_address},</if>
<if test="network_ip != null">#{network_ip},</if>
<if test="remark != null">#{remark},</if>
<if test="rssi != null">#{rssi},</if>
<if test="status != null">#{status},</if>
<if test="summary != null">#{summary},</if>
<if test="things_model_value != null">#{things_model_value},</if>
<if test="update_by != null">#{update_by},</if>
<if test="update_time != null">#{update_time},</if>
<if test="product_id != null">#{product_id},</if>
<if test="mqtt_username != null">#{mqtt_username},</if>
<if test="payload_type != null">#{payload_type},</if>
<if test="things_model_config != null">#{things_model_config},</if>
<if test="device_life != null">#{device_life},</if>
<if test="data_update_time != null">#{data_update_time},</if>
<if test="sys_user_id != null">#{sys_user_id},</if>
UNIX_TIMESTAMP(NOW()),
</trim>
</insert>
<update id="updateIotDevice" parameterType="IotDevice">
update iot_device
<trim prefix="SET" suffixOverrides=",">
<if test="active_time != null">active_time = #{active_time},</if>
<if test="completion_auth != null">completion_auth = #{completion_auth},</if>
<if test="create_by != null">create_by = #{create_by},</if>
<if test="create_time != null">create_time = #{create_time},</if>
<if test="del_flag != null">del_flag = #{del_flag},</if>
<if test="firmware_version != null">firmware_version = #{firmware_version},</if>
<if test="img_url != null">img_url = #{img_url},</if>
<if test="is_shadow != null">is_shadow = #{is_shadow},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="location_way != null">location_way = #{location_way},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="name != null">`name` = #{name},</if>
<if test="network_address != null">network_address = #{network_address},</if>
<if test="network_ip != null">network_ip = #{network_ip},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="rssi != null">rssi = #{rssi},</if>
<if test="status != null">status = #{status},</if>
<if test="summary != null">summary = #{summary},</if>
<if test="things_model_value != null">things_model_value = #{things_model_value},</if>
<if test="update_by != null">update_by = #{update_by},</if>
<if test="update_time != null">update_time = #{update_time},</if>
<if test="product_id != null">product_id = #{product_id},</if>
<if test="mqtt_username != null">mqtt_username = #{mqtt_username},</if>
<if test="payload_type != null">payload_type = #{payload_type},</if>
<if test="things_model_config != null">things_model_config = #{things_model_config},</if>
<if test="device_life != null">device_life = #{device_life},</if>
<if test="data_update_time != null">data_update_time = #{data_update_time},</if>
<if test="sys_user_id != null">sys_user_id = #{sys_user_id},</if>
</trim>
where client_id = #{client_id}
</update>
<delete id="deleteIotDeviceByClient_id" parameterType="String">
delete from iot_device where client_id = #{client_id}
</delete>
<delete id="deleteIotDeviceByClient_ids" parameterType="String">
delete from iot_device where client_id in
<foreach item="client_id" collection="array" open="(" separator="," close=")">
#{client_id}
</foreach>
</delete>
</mapper>