IotAlertLogMapper.xml 4.3 KB
<?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"    />
    </resultMap>

    <sql id="selectAlertLogVo">
        select alert_log__id, alert_name,alert_id, alert_level, status, device_id, create_time, type 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 &gt;= #{params.beginTime}</if>
            <if test="params.endTime != null "> and create_time &lt;= #{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>