IotThingsModelMapper.xml
10.5 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
<?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.IotThingsModelMapper">
<resultMap type="IotThingsModel" id="IotThingsModelResult">
<result property="create_by" column="create_by" />
<result property="create_time" column="create_time" />
<result property="data_type" column="data_type" />
<result property="del_flag" column="del_flag" />
<result property="identifier" column="identifier" />
<result property="is_monitor" column="is_monitor" />
<result property="is_save_log" column="is_save_log" />
<result property="is_top" column="is_top" />
<result property="model_id" column="model_id" />
<result property="model_name" column="model_name" />
<result property="remark" column="remark" />
<result property="specs" column="specs" />
<result property="type" column="type" />
<result property="update_by" column="update_by" />
<result property="update_time" column="update_time" />
<result property="product_id" column="product_id" />
<result property="is_config" column="is_config" />
<result property="mqtt_username" column="mqtt_username" />
<result property="config_names" column="config_names" />
<result property="view_type" column="view_type" />
<result property="ascription" column="ascription" />
<result property="sys_user_id" column="sys_user_id" />
</resultMap>
<sql id="selectIotThingsModelVo">
select a.* from iot_things_model a
</sql>
<select id="selectIotThingsModelList" parameterType="IotThingsModel" resultMap="IotThingsModelResult">
<include refid="selectIotThingsModelVo"/>
LEFT JOIN `sys_user` u ON u.user_id = a.sys_user_id
<where>
<if test="create_by !=null and create_by != ''">
and a.create_by = #{create_by}
</if>
<if test="data_type !=null and data_type != ''">
and a.data_type = #{data_type}
</if>
<if test="identifier !=null and identifier != ''">
and a.identifier = #{identifier}
</if>
<if test="is_save_log !=null and is_save_log != ''">
and a.is_save_log = #{is_save_log}
</if>
<if test="is_monitor !=null and is_monitor != ''">
and a.is_monitor = #{is_monitor}
</if>
<if test="model_id !=null and model_id != ''">
and a.model_id = #{model_id}
</if>
<if test="model_name !=null and model_name != ''">
and a.model_name = #{model_name}
</if>
<if test="type !=null and type != ''">
and `type` = #{type}
</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="ascription !=null and ascription != ''">
and a.ascription = #{ascription}
</if>
<if test="sys_user_id !=null and sys_user_id != ''">
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="selectIotThingsModelListByIds" parameterType="Integer" resultMap="IotThingsModelResult">
select a.create_by, a.create_time, a.data_type, a.del_flag, a.identifier, a.is_monitor, a.is_save_log, a.is_top, a.model_id, a.model_name, a.remark, a.specs, a.`type`, a.update_by, a.update_time, a.product_id,a.is_config,a.view_type,a.ascription,b.mqtt_username mqtt_username FROM `mqtt_broker`.`iot_things_model` a LEFT JOIN `mqtt_broker`.`iot_product` b ON a.`product_id`=b.`id`
where a.model_id in
<foreach item="model_id" collection="array" open="(" separator="," close=")">
#{model_id}
</foreach>
</select>
<select id="selectIotThingsModelByModel_id" parameterType="Integer" resultMap="IotThingsModelResult">
<include refid="selectIotThingsModelVo"/>
where model_id = #{model_id}
</select>
<insert id="insertIotThingsModel" parameterType="IotThingsModel" useGeneratedKeys="true" keyProperty="model_id">
insert into iot_things_model
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="create_by != null">create_by,</if>
<if test="data_type != null and data_type != ''">data_type,</if>
<if test="del_flag != null">del_flag,</if>
<if test="identifier != null and identifier != ''">identifier,</if>
<if test="is_monitor != null">is_monitor,</if>
<if test="is_save_log != null">is_save_log,</if>
<if test="is_top != null">is_top,</if>
<if test="model_name != null and model_name != ''">model_name,</if>
<if test="remark != null">remark,</if>
<if test="specs != null">specs,</if>
<if test="type != null">`type`,</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="is_config != null">is_config,</if>
<if test="config_names != null">config_names,</if>
<if test="view_type != null">view_type,</if>
<if test="mqtt_username != null">mqtt_username,</if>
<if test="ascription != null">ascription,</if>
<if test="sys_user_id != null">sys_user_id,</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="create_by != null">#{create_by},</if>
<if test="data_type != null and data_type != ''">#{data_type},</if>
<if test="del_flag != null">#{del_flag},</if>
<if test="identifier != null and identifier != ''">#{identifier},</if>
<if test="is_monitor != null">#{is_monitor},</if>
<if test="is_save_log != null">#{is_save_log},</if>
<if test="is_top != null">#{is_top},</if>
<if test="model_name != null and model_name != ''">#{model_name},</if>
<if test="remark != null">#{remark},</if>
<if test="specs != null">#{specs},</if>
<if test="type != null">#{type},</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="is_config != null">#{is_config},</if>
<if test="config_names != null">#{config_names},</if>
<if test="view_type != null">#{view_type},</if>
<if test="mqtt_username != null">#{mqtt_username},</if>
<if test="ascription != null">#{ascription},</if>
<if test="sys_user_id != null">#{sys_user_id},</if>
TIMESTAMP(NOW()),
</trim>
</insert>
<update id="updateIotThingsModel" parameterType="IotThingsModel">
update iot_things_model
<trim prefix="SET" suffixOverrides=",">
<if test="create_by != null">create_by = #{create_by},</if>
<if test="create_time != null">create_time = #{create_time},</if>
<if test="data_type != null and data_type != ''">data_type = #{data_type},</if>
<if test="del_flag != null">del_flag = #{del_flag},</if>
<if test="identifier != null and identifier != ''">identifier = #{identifier},</if>
<if test="is_monitor != null">is_monitor = #{is_monitor},</if>
<if test="is_save_log != null">is_save_log = #{is_save_log},</if>
<if test="is_top != null">is_top = #{is_top},</if>
<if test="model_name != null and model_name != ''">model_name = #{model_name},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="specs != null">specs = #{specs},</if>
<if test="type != null">type = #{type},</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="is_config != null">is_config = #{is_config},</if>
<if test="config_names != null">config_names = #{config_names},</if>
<if test="view_type != null">view_type = #{view_type},</if>
<if test="mqtt_username != null">mqtt_username = #{mqtt_username},</if>
<if test="ascription != null">ascription = #{ascription},</if>
<if test="sys_user_id != null">sys_user_id = #{sys_user_id},</if>
</trim>
where model_id = #{model_id}
</update>
<delete id="deleteIotThingsModelByModel_id" parameterType="Integer">
delete from iot_things_model where model_id = #{model_id}
</delete>
<delete id="deleteIotThingsModelByModel_ids" parameterType="Integer">
delete from iot_things_model where model_id in
<foreach item="model_id" collection="array" open="(" separator="," close=")">
#{model_id}
</foreach>
</delete>
<insert id="distributionIotThingsModelTemplate" parameterType="DistributionCurrencyModel">
INSERT INTO `iot_things_model`(`model_name`,`identifier`,`type`,`data_type`,`specs`,`is_top`,`is_monitor`,`del_flag`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,`product_id`,`mqtt_username`,`is_save_log`,`is_config`,`config_names`,`view_type`,`ascription`) SELECT `model_name`,`identifier`,`type`,`data_type`,`specs`,`is_top`,`is_monitor`,`del_flag`,`create_by`,`create_time`,`update_by`,`update_time`,`remark`,#{product_id,jdbcType=INTEGER} `product_id`,#{mqtt_username,jdbcType=VARCHAR} `mqtt_username`,`is_save_log`,`is_config`,`config_names`,`view_type`,`ascription` FROM `iot_things_model_template` WHERE `model_id` IN
<foreach item="model_id" collection="model_ids" open="(" separator="," close=")">
#{model_id}
</foreach>
</insert>
</mapper>