<?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.tofly.scada.mapper.MessagerecipientWMapper">

    <resultMap id="BaseResultMap" type="com.tofly.scada.entity.MessagerecipientW">
            <id property="id" column="ID" jdbcType="DECIMAL"/>
            <result property="messageId" column="MESSAGE_ID" jdbcType="DECIMAL"/>
            <result property="recipient" column="RECIPIENT" jdbcType="DECIMAL"/>
            <result property="flag" column="FLAG" jdbcType="VARCHAR"/>
            <result property="recipientTime" column="RECIPIENT_TIME" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        ID,MESSAGE_ID,RECIPIENT,
        FLAG,RECIPIENT_TIME
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from TF_YWPN_MESSAGERECIPIENT_W
        where  ID = #{id,jdbcType=DECIMAL} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from TF_YWPN_MESSAGERECIPIENT_W
        where  ID = #{id,jdbcType=DECIMAL} 
    </delete>
    <insert id="insert" keyColumn="ID" keyProperty="id" parameterType="com.tofly.scada.entity.MessagerecipientW" useGeneratedKeys="true">
        <selectKey  keyProperty="id" resultType="int" order="BEFORE">
            select nvl(max(ID),0)+1 from TF_YWPN_MESSAGERECIPIENT_W
        </selectKey>
        insert into TF_YWPN_MESSAGERECIPIENT_W
        ( ID,MESSAGE_ID,RECIPIENT
        ,FLAG,RECIPIENT_TIME)
        values (#{id,jdbcType=DECIMAL},#{messageId,jdbcType=DECIMAL},#{recipient,jdbcType=DECIMAL}
        ,#{flag,jdbcType=VARCHAR},#{recipientTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="ID" keyProperty="id" parameterType="com.tofly.scada.entity.MessagerecipientW" useGeneratedKeys="true">
        <selectKey  keyProperty="id" resultType="long" order="BEFORE">
            select nvl(max(ID),0)+1 from TF_YWPN_MESSAGERECIPIENT_W
        </selectKey>
        insert into TF_YWPN_MESSAGERECIPIENT_W
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">ID,</if>
                <if test="messageId != null">MESSAGE_ID,</if>
                <if test="recipient != null">RECIPIENT,</if>
                <if test="flag != null">FLAG,</if>
                <if test="recipientTime != null">RECIPIENT_TIME,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=DECIMAL},</if>
                <if test="messageId != null">#{messageId,jdbcType=DECIMAL},</if>
                <if test="recipient != null">#{recipient,jdbcType=DECIMAL},</if>
                <if test="flag != null">#{flag,jdbcType=VARCHAR},</if>
                <if test="recipientTime != null">#{recipientTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.tofly.scada.entity.MessagerecipientW">
        update TF_YWPN_MESSAGERECIPIENT_W
        <set>
                <if test="messageId != null">
                    MESSAGE_ID = #{messageId,jdbcType=DECIMAL},
                </if>
                <if test="recipient != null">
                    RECIPIENT = #{recipient,jdbcType=DECIMAL},
                </if>
                <if test="flag != null">
                    FLAG = #{flag,jdbcType=VARCHAR},
                </if>
                <if test="recipientTime != null">
                    RECIPIENT_TIME = #{recipientTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   ID = #{id,jdbcType=DECIMAL} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.tofly.scada.entity.MessagerecipientW">
        update TF_YWPN_MESSAGERECIPIENT_W
        set 
            MESSAGE_ID =  #{messageId,jdbcType=DECIMAL},
            RECIPIENT =  #{recipient,jdbcType=DECIMAL},
            FLAG =  #{flag,jdbcType=VARCHAR},
            RECIPIENT_TIME =  #{recipientTime,jdbcType=TIMESTAMP}
        where   ID = #{id,jdbcType=DECIMAL} 
    </update>
</mapper>
