<?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.ms.dal.mapper.DoudianTradeMsgBufferMapper">

    <resultMap id="BaseResultMap" type="com.ms.dal.entity.DoudianTradeMsgBuffer">
            <id property="doudianTradeMsgBufferId" column="doudian_trade_msg_buffer_id" jdbcType="BIGINT"/>
            <result property="shopId" column="shop_id" jdbcType="BIGINT"/>
            <result property="msgId" column="msg_id" jdbcType="VARCHAR"/>
            <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
            <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        doudian_trade_msg_buffer_id,shop_id,msg_id,
        gmt_create,gmt_modified
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from doudian_trade_msg_buffer
        where  doudian_trade_msg_buffer_id = #{doudianTradeMsgBufferId,jdbcType=BIGINT} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from doudian_trade_msg_buffer
        where  doudian_trade_msg_buffer_id = #{doudianTradeMsgBufferId,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="doudian_trade_msg_buffer_id" keyProperty="doudianTradeMsgBufferId" parameterType="com.ms.dal.entity.DoudianTradeMsgBuffer" useGeneratedKeys="true">
        insert into doudian_trade_msg_buffer
        ( doudian_trade_msg_buffer_id,shop_id,msg_id
        ,gmt_create,gmt_modified)
        values (#{doudianTradeMsgBufferId,jdbcType=BIGINT},#{shopId,jdbcType=BIGINT},#{msgId,jdbcType=VARCHAR}
        ,#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP})
    </insert>
    <update id="insertOrUpdate"  keyColumn="doudian_trade_msg_buffer_id" keyProperty="doudianTradeMsgBufferId" parameterType="com.ms.dal.entity.DoudianTradeMsgBuffer"
        useGeneratedKeys="true">
        insert into doudian_trade_msg_buffer
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="doudianTradeMsgBufferId != null">doudian_trade_msg_buffer_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="msgId != null">msg_id,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="doudianTradeMsgBufferId != null">#{doudianTradeMsgBufferId,jdbcType=BIGINT},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="msgId != null">#{msgId,jdbcType=VARCHAR},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
        ON DUPLICATE KEY UPDATE
        <trim  suffixOverrides=",">
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="msgId != null">
                    msg_id = #{msgId,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </trim>
    </update>
    <insert id="insertSelective" keyColumn="doudian_trade_msg_buffer_id" keyProperty="doudianTradeMsgBufferId" parameterType="com.ms.dal.entity.DoudianTradeMsgBuffer" useGeneratedKeys="true">
        insert into doudian_trade_msg_buffer
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="doudianTradeMsgBufferId != null">doudian_trade_msg_buffer_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="msgId != null">msg_id,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="doudianTradeMsgBufferId != null">#{doudianTradeMsgBufferId,jdbcType=BIGINT},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="msgId != null">#{msgId,jdbcType=VARCHAR},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.DoudianTradeMsgBuffer">
        update doudian_trade_msg_buffer
        <set>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="msgId != null">
                    msg_id = #{msgId,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   doudian_trade_msg_buffer_id = #{doudianTradeMsgBufferId,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.DoudianTradeMsgBuffer">
        update doudian_trade_msg_buffer
        set 
            shop_id =  #{shopId,jdbcType=BIGINT},
            msg_id =  #{msgId,jdbcType=VARCHAR},
            gmt_create =  #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified =  #{gmtModified,jdbcType=TIMESTAMP}
        where   doudian_trade_msg_buffer_id = #{doudianTradeMsgBufferId,jdbcType=BIGINT} 
    </update>
</mapper>
