<?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.zehong.system.mapper.TMapDeviceMonitorMapper">
    
    <resultMap type="TMapDeviceMonitor" id="TMapDeviceMonitorResult">
        <result property="monitorId"    column="monitor_id"    />
        <result property="monitorValue"    column="monitor_value"    />
        <result property="monitorDeviceStatus"    column="monitor_device_status"    />
        <result property="monitorDeviceNum"    column="monitor_device_num"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTMapDeviceMonitorVo">
        select monitor_id, monitor_value, monitor_device_status, monitor_device_num, create_by, create_time, update_by, update_time, is_del, remark from t_map_device_monitor
    </sql>

    <select id="selectTMapDeviceMonitorList" parameterType="TMapDeviceMonitor" resultMap="TMapDeviceMonitorResult">
        <include refid="selectTMapDeviceMonitorVo"/>
        <where>  
            <if test="monitorValue != null "> and monitor_value = #{monitorValue}</if>
            <if test="monitorDeviceStatus != null  and monitorDeviceStatus != ''"> and monitor_device_status = #{monitorDeviceStatus}</if>
            <if test="monitorDeviceNum != null  and monitorDeviceNum != ''"> and monitor_device_num = #{monitorDeviceNum}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectTMapDeviceMonitorById" parameterType="Long" resultMap="TMapDeviceMonitorResult">
        <include refid="selectTMapDeviceMonitorVo"/>
        where monitor_id = #{monitorId}
    </select>
        
    <insert id="insertTMapDeviceMonitor" parameterType="TMapDeviceMonitor" useGeneratedKeys="true" keyProperty="monitorId">
        insert into t_map_device_monitor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="monitorValue != null">monitor_value,</if>
            <if test="monitorDeviceStatus != null">monitor_device_status,</if>
            <if test="monitorDeviceNum != null">monitor_device_num,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="monitorValue != null">#{monitorValue},</if>
            <if test="monitorDeviceStatus != null">#{monitorDeviceStatus},</if>
            <if test="monitorDeviceNum != null">#{monitorDeviceNum},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTMapDeviceMonitor" parameterType="TMapDeviceMonitor">
        update t_map_device_monitor
        <trim prefix="SET" suffixOverrides=",">
            <if test="monitorValue != null">monitor_value = #{monitorValue},</if>
            <if test="monitorDeviceStatus != null">monitor_device_status = #{monitorDeviceStatus},</if>
            <if test="monitorDeviceNum != null">monitor_device_num = #{monitorDeviceNum},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where monitor_id = #{monitorId}
    </update>

    <delete id="deleteTMapDeviceMonitorById" parameterType="Long">
        delete from t_map_device_monitor where monitor_id = #{monitorId}
    </delete>

    <delete id="deleteTMapDeviceMonitorByIds" parameterType="String">
        delete from t_map_device_monitor where monitor_id in 
        <foreach item="monitorId" collection="array" open="(" separator="," close=")">
            #{monitorId}
        </foreach>
    </delete>
</mapper>