IotProductMapper.xml
4.7 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
<?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.ruoyi.system.mapper.IotProductMapper">
<resultMap type="IotProduct" id="IotProductResult">
<result property="create_time" column="create_time" />
<result property="encryption_type" column="encryption_type" />
<result property="id" column="id" />
<result property="open_encryption" column="open_encryption" />
<result property="mqtt_password" column="mqtt_password" />
<result property="role_id" column="role_id" />
<result property="mqtt_salt" column="mqtt_salt" />
<result property="used" column="used" />
<result property="mqtt_username" column="mqtt_username" />
<result property="product_name" column="product_name" />
</resultMap>
<sql id="selectIotProductVo">
select `id`,`mqtt_username`,`mqtt_password`,`product_name`,`mqtt_salt`,`create_time`,`encryption_type`,`open_encryption`,`used`,`role_id` from iot_product
</sql>
<select id="selectIotProductList" parameterType="IotProduct" resultMap="IotProductResult">
<include refid="selectIotProductVo"/>
<where>
<if test="product_name != null and product_name != ''">
AND `product_name` like concat('%', #{product_name}, '%')
</if>
<if test="role_id !=null and role_id != ''">
and role_id = #{role_id}
</if>
<if test="mqtt_username != null and mqtt_username != ''">
AND `mqtt_username` like concat('%', #{mqtt_username}, '%')
</if>
</where>
</select>
<select id="selectIotProductById" parameterType="Integer" resultMap="IotProductResult">
<include refid="selectIotProductVo"/>
where id = #{id}
</select>
<insert id="insertIotProduct" parameterType="IotProduct" useGeneratedKeys="true" keyProperty="id">
insert into iot_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="encryption_type != null">encryption_type,</if>
<if test="open_encryption != null">open_encryption,</if>
<if test="mqtt_password != null and mqtt_password != ''">mqtt_password,</if>
<if test="role_id != null">role_id,</if>
<if test="mqtt_salt != null">mqtt_salt,</if>
<if test="used != null">used,</if>
<if test="mqtt_username != null and mqtt_username != ''">mqtt_username,</if>
<if test="product_name != null and product_name != ''">product_name,</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="encryption_type != null">#{encryption_type},</if>
<if test="open_encryption != null">#{open_encryption},</if>
<if test="mqtt_password != null and mqtt_password != ''">#{mqtt_password},</if>
<if test="role_id != null">#{role_id},</if>
<if test="mqtt_salt != null">#{mqtt_salt},</if>
<if test="used != null">#{used},</if>
<if test="mqtt_username != null and mqtt_username != ''">#{mqtt_username},</if>
<if test="product_name != null and product_name != ''">#{product_name},</if>
UNIX_TIMESTAMP(NOW()),
</trim>
</insert>
<update id="updateIotProduct" parameterType="IotProduct">
update iot_product
<trim prefix="SET" suffixOverrides=",">
<if test="create_time != null">create_time = #{create_time},</if>
<if test="encryption_type != null">encryption_type = #{encryption_type},</if>
<if test="open_encryption != null">open_encryption = #{open_encryption},</if>
<if test="mqtt_password != null and mqtt_password != ''">mqtt_password = #{mqtt_password},</if>
<if test="role_id != null">role_id = #{role_id},</if>
<if test="mqtt_salt != null">mqtt_salt = #{mqtt_salt},</if>
<if test="used != null">used = #{used},</if>
<if test="mqtt_username != null and mqtt_username != ''">mqtt_username = #{mqtt_username},</if>
<if test="product_name != null and product_name != ''">product_name = #{product_name},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteIotProductById" parameterType="Integer">
delete from iot_product where id = #{id}
</delete>
<delete id="deleteIotProductByIds" parameterType="String">
delete from iot_product where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>