IotAlertLogMapper.xml
4.3 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
<?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.IotAlertLogMapper">
<resultMap type="com.zhonglai.luhui.device.domain.IotAlertLog" id="AlertLogResult">
<result property="alertLogId" column="alert_log_id" />
<result property="alertName" column="alert_name" />
<result property="alertId" column="alert_id" />
<result property="alertLevel" column="alert_level" />
<result property="status" column="status" />
<result property="deviceId" column="device_id" />
<result property="create_time" column="create_time" />
<result property="type" column="type" />
<result property="user_id" column="user_id" />
</resultMap>
<sql id="selectAlertLogVo">
select alert_log_id, alert_name,alert_id, alert_level, `status`, device_id, create_time, `type`,user_id from iot_alert_log
</sql>
<select id="selectAlertLogList" parameterType="com.zhonglai.luhui.device.domain.IotAlertLog" resultMap="AlertLogResult">
<include refid="selectAlertLogVo"/>
<where>
<if test="alertName != null and alertName != ''"> and alert_name like concat('%', #{alertName}, '%')</if>
<if test="alertLevel != null "> and alert_level = #{alertLevel}</if>
<if test="status != null "> and status = #{status}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="type != null "> and type = #{type}</if>
<if test="params.beginTime != null "> and create_time >= #{params.beginTime}</if>
<if test="params.endTime != null "> and create_time <= #{params.endTime}</if>
</where>
</select>
<select id="selectAlertLogByAlertLogId" parameterType="Long" resultMap="AlertLogResult">
<include refid="selectAlertLogVo"/>
where alert_log__id = #{alertLogId}
</select>
<insert id="insertAlertLog" parameterType="com.zhonglai.luhui.device.domain.IotAlertLog" useGeneratedKeys="true" keyProperty="alertLogId">
insert into iot_alert_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">alert_name,</if>
<if test="alertId != null">alert_id,</if>
<if test="alertLevel != null">alert_level,</if>
<if test="status != null">status,</if>
<if test="deviceId != null">device_id,</if>
<if test="create_time != null">create_time,</if>
<if test="type != null">`type`,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="alertName != null and alertName != ''">#{alertName},</if>
<if test="alertId != null">#{alertId},</if>
<if test="alertLevel != null">#{alertLevel},</if>
<if test="status != null">#{status},</if>
<if test="deviceId != null">#{deviceId},</if>
<if test="create_time != null">#{createTime},</if>
<if test="type != null">#{type},</if>
</trim>
</insert>
<update id="updateAlertLog" parameterType="com.zhonglai.luhui.device.domain.IotAlertLog">
update iot_alert_log
<trim prefix="SET" suffixOverrides=",">
<if test="alertName != null and alertName != ''">alert_name = #{alertName},</if>
<if test="alertId != null">alert_id = #{alertId},</if>
<if test="alertLevel != null">alert_level = #{alertLevel},</if>
<if test="status != null">status = #{status},</if>
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="create_time != null">create_time = #{create_time},</if>
<if test="type != null">`type` = #{type},</if>
</trim>
where alert_log__id = #{alertLogId}
</update>
<delete id="deleteAlertLogByAlertLogId" parameterType="Long">
delete from iot_alert_log where alert_log__id = #{alertLogId}
</delete>
<delete id="deleteAlertLogByAlertLogIds" parameterType="String">
delete from iot_alert_log where alert_log__id in
<foreach item="alertLogId" collection="array" open="(" separator="," close=")">
#{alertLogId}
</foreach>
</delete>
</mapper>