<?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.TEquipmentAlarmDataMapper">
    
    <resultMap type="TEquipmentAlarmData" id="TEquipmentAlarmDataResult">
        <result property="fEquipmentAlarmDataId"    column="f_equipment_alarm_data_id"    />
        <result property="fEquipmentCode"    column="f_equipment_code"    />
        <result property="fAlarmType"    column="f_alarm_type"    />
        <result property="fAlarmData"    column="f_alarm_data"    />
        <result property="fCreateTime"    column="f_create_time"    />
    </resultMap>

    <sql id="selectTEquipmentAlarmDataVo">
        select f_equipment_alarm_data_id, f_equipment_code, f_alarm_type, f_alarm_data, f_create_time from t_equipment_alarm_data
    </sql>

    <select id="selectTEquipmentAlarmDataList" parameterType="TEquipmentAlarmData" resultMap="TEquipmentAlarmDataResult">
        <include refid="selectTEquipmentAlarmDataVo"/>
        <where>  
            <if test="fEquipmentCode != null  and fEquipmentCode != ''"> and f_equipment_code = #{fEquipmentCode}</if>
            <if test="fAlarmType != null  and fAlarmType != ''"> and f_alarm_type = #{fAlarmType}</if>
            <if test="fAlarmData != null  and fAlarmData != ''"> and f_alarm_data = #{fAlarmData}</if>
            <if test="fCreateTime != null "> and f_create_time = #{fCreateTime}</if>
        </where>
    </select>
    
    <select id="selectTEquipmentAlarmDataById" parameterType="Long" resultMap="TEquipmentAlarmDataResult">
        <include refid="selectTEquipmentAlarmDataVo"/>
        where f_equipment_alarm_data_id = #{fEquipmentAlarmDataId}
    </select>
        
    <insert id="insertTEquipmentAlarmData" parameterType="TEquipmentAlarmData">
        insert into t_equipment_alarm_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fEquipmentAlarmDataId != null">f_equipment_alarm_data_id,</if>
            <if test="fEquipmentCode != null">f_equipment_code,</if>
            <if test="fAlarmType != null">f_alarm_type,</if>
            <if test="fAlarmData != null">f_alarm_data,</if>
            <if test="fCreateTime != null">f_create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fEquipmentAlarmDataId != null">#{fEquipmentAlarmDataId},</if>
            <if test="fEquipmentCode != null">#{fEquipmentCode},</if>
            <if test="fAlarmType != null">#{fAlarmType},</if>
            <if test="fAlarmData != null">#{fAlarmData},</if>
            <if test="fCreateTime != null">#{fCreateTime},</if>
         </trim>
    </insert>

    <update id="updateTEquipmentAlarmData" parameterType="TEquipmentAlarmData">
        update t_equipment_alarm_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="fEquipmentCode != null">f_equipment_code = #{fEquipmentCode},</if>
            <if test="fAlarmType != null">f_alarm_type = #{fAlarmType},</if>
            <if test="fAlarmData != null">f_alarm_data = #{fAlarmData},</if>
            <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
        </trim>
        where f_equipment_alarm_data_id = #{fEquipmentAlarmDataId}
    </update>

    <delete id="deleteTEquipmentAlarmDataById" parameterType="Long">
        delete from t_equipment_alarm_data where f_equipment_alarm_data_id = #{fEquipmentAlarmDataId}
    </delete>

    <delete id="deleteTEquipmentAlarmDataByIds" parameterType="String">
        delete from t_equipment_alarm_data where f_equipment_alarm_data_id in 
        <foreach item="fEquipmentAlarmDataId" collection="array" open="(" separator="," close=")">
            #{fEquipmentAlarmDataId}
        </foreach>
    </delete>
</mapper>