<?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.DdAftersaleMsgMapper">

    <resultMap id="BaseResultMap" type="com.ms.dal.entity.DdAftersaleMsg">
            <id property="ddAftersaleMsgId" column="dd_aftersale_msg_id" jdbcType="BIGINT"/>
            <result property="msgId" column="msg_id" jdbcType="VARCHAR"/>
            <result property="shopId" column="shop_id" jdbcType="BIGINT"/>
            <result property="tag" column="tag" jdbcType="SMALLINT"/>
            <result property="data" column="data" jdbcType="VARCHAR"/>
            <result property="status" column="status" jdbcType="VARCHAR"/>
            <result property="reason" column="reason" jdbcType="VARCHAR"/>
            <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
            <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        dd_aftersale_msg_id,msg_id,shop_id,
        tag,data,status,
        reason,gmt_create,gmt_modified
    </sql>

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

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from dd_aftersale_msg
        where  dd_aftersale_msg_id = #{ddAftersaleMsgId,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="dd_aftersale_msg_id" keyProperty="ddAftersaleMsgId" parameterType="com.ms.dal.entity.DdAftersaleMsg" useGeneratedKeys="true">
        insert into dd_aftersale_msg
        ( dd_aftersale_msg_id,msg_id,shop_id
        ,tag,data,status
        ,reason,gmt_create,gmt_modified
        )
        values (#{ddAftersaleMsgId,jdbcType=BIGINT},#{msgId,jdbcType=VARCHAR},#{shopId,jdbcType=BIGINT}
        ,#{tag,jdbcType=SMALLINT},#{data,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR}
        ,#{reason,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP}
        )
    </insert>
    <update id="insertOrUpdate"  keyColumn="dd_aftersale_msg_id" keyProperty="ddAftersaleMsgId" parameterType="com.ms.dal.entity.DdAftersaleMsg"
        useGeneratedKeys="true">
        insert into dd_aftersale_msg
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="ddAftersaleMsgId != null">dd_aftersale_msg_id,</if>
                <if test="msgId != null">msg_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="tag != null">tag,</if>
                <if test="data != null">data,</if>
                <if test="status != null">status,</if>
                <if test="reason != null">reason,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="ddAftersaleMsgId != null">#{ddAftersaleMsgId,jdbcType=BIGINT},</if>
                <if test="msgId != null">#{msgId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="tag != null">#{tag,jdbcType=SMALLINT},</if>
                <if test="data != null">#{data,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="reason != null">#{reason,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="msgId != null">
                    msg_id = #{msgId,jdbcType=VARCHAR},
                </if>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="tag != null">
                    tag = #{tag,jdbcType=SMALLINT},
                </if>
                <if test="data != null">
                    data = #{data,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="reason != null">
                    reason = #{reason,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="dd_aftersale_msg_id" keyProperty="ddAftersaleMsgId" parameterType="com.ms.dal.entity.DdAftersaleMsg" useGeneratedKeys="true">
        insert into dd_aftersale_msg
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="ddAftersaleMsgId != null">dd_aftersale_msg_id,</if>
                <if test="msgId != null">msg_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="tag != null">tag,</if>
                <if test="data != null">data,</if>
                <if test="status != null">status,</if>
                <if test="reason != null">reason,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="ddAftersaleMsgId != null">#{ddAftersaleMsgId,jdbcType=BIGINT},</if>
                <if test="msgId != null">#{msgId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="tag != null">#{tag,jdbcType=SMALLINT},</if>
                <if test="data != null">#{data,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="reason != null">#{reason,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.DdAftersaleMsg">
        update dd_aftersale_msg
        <set>
                <if test="msgId != null">
                    msg_id = #{msgId,jdbcType=VARCHAR},
                </if>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="tag != null">
                    tag = #{tag,jdbcType=SMALLINT},
                </if>
                <if test="data != null">
                    data = #{data,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="reason != null">
                    reason = #{reason,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   dd_aftersale_msg_id = #{ddAftersaleMsgId,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.DdAftersaleMsg">
        update dd_aftersale_msg
        set 
            msg_id =  #{msgId,jdbcType=VARCHAR},
            shop_id =  #{shopId,jdbcType=BIGINT},
            tag =  #{tag,jdbcType=SMALLINT},
            data =  #{data,jdbcType=VARCHAR},
            status =  #{status,jdbcType=VARCHAR},
            reason =  #{reason,jdbcType=VARCHAR},
            gmt_create =  #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified =  #{gmtModified,jdbcType=TIMESTAMP}
        where   dd_aftersale_msg_id = #{ddAftersaleMsgId,jdbcType=BIGINT} 
    </update>
</mapper>
