<?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.ruoyi.jarvis.mapper.XbMessageMapper">

    <resultMap type="XbMessage" id="XbMessageResult">
        <result property="id" column="id"/>
        <result property="createDate" column="create_date"/>
        <result property="skuid" column="skuid"/>
        <result property="tipOriginalMessage" column="tip_original_message"/>
        <result property="fromWxid" column="from_wxid"/>
        <result property="firstLine" column="first_line"/>
        <result property="firstSkuName" column="first_sku_name"/>
        <result property="firstPrice" column="first_price"/>
    </resultMap>

    <sql id="selectXbMessageVo">
        select id, create_date, skuid, tip_original_message, from_wxid, first_line, first_sku_name, first_price from xb_message
    </sql>

    <select id="selectXbMessageList" parameterType="XbMessage" resultMap="XbMessageResult">
        <include refid="selectXbMessageVo"/>
        <where>
            <if test="createDate != null">and create_date = #{createDate}</if>
            <if test="skuid != null and skuid != ''">and skuid = #{skuid}</if>
            <if test="tipOriginalMessage != null and tipOriginalMessage != ''">and tip_original_message = #{tipOriginalMessage}</if>
            <if test="fromWxid != null and fromWxid != ''">and from_wxid = #{fromWxid}</if>
            <if test="firstLine != null and firstLine != ''">and first_line = #{firstLine}</if>
            <if test="firstSkuName != null and firstSkuName != ''">and first_sku_name = #{firstSkuName}</if>
            <if test="firstPrice != null">and first_price = #{firstPrice}</if>
        </where>
        order by create_date desc
    </select>

    <select id="selectXbMessageById" parameterType="Integer" resultMap="XbMessageResult">
        <include refid="selectXbMessageVo"/>
        where id = #{id}
    </select>

    <insert id="insertXbMessage" parameterType="XbMessage" useGeneratedKeys="true" keyProperty="id">
        insert into xb_message
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="createDate != null">create_date,</if>
            <if test="skuid != null and skuid != ''">skuid,</if>
            <if test="tipOriginalMessage != null and tipOriginalMessage != ''">tip_original_message,</if>
            <if test="fromWxid != null and fromWxid != ''">from_wxid,</if>
            <if test="firstLine != null and firstLine != ''">first_line,</if>
            <if test="firstSkuName != null and firstSkuName != ''">first_sku_name,</if>
            <if test="firstPrice != null">first_price,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createDate != null">#{createDate},</if>
            <if test="skuid != null and skuid != ''">#{skuid},</if>
            <if test="tipOriginalMessage != null and tipOriginalMessage != ''">#{tipOriginalMessage},</if>
            <if test="fromWxid != null and fromWxid != ''">#{fromWxid},</if>
            <if test="firstLine != null and firstLine != ''">#{firstLine},</if>
            <if test="firstSkuName != null and firstSkuName != ''">#{firstSkuName},</if>
            <if test="firstPrice != null">#{firstPrice},</if>
        </trim>
    </insert>

    <update id="updateXbMessage" parameterType="XbMessage">
        update xb_message
        <set>
            <if test="createDate != null">create_date = #{createDate},</if>
            <if test="skuid != null and skuid != ''">skuid = #{skuid},</if>
            <if test="tipOriginalMessage != null and tipOriginalMessage != ''">tip_original_message = #{tipOriginalMessage},</if>
            <if test="fromWxid != null and fromWxid != ''">from_wxid = #{fromWxid},</if>
            <if test="firstLine != null and firstLine != ''">first_line = #{firstLine},</if>
            <if test="firstSkuName != null and firstSkuName != ''">first_sku_name = #{firstSkuName},</if>
            <if test="firstPrice != null">first_price = #{firstPrice},</if>
        </set>
        where id = #{id}
    </update>

    <delete id="deleteXbMessageById" parameterType="Integer">
        delete from xb_message where id = #{id}
    </delete>

    <delete id="deleteXbMessageByIds" parameterType="String">
        delete from xb_message where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>
