<?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.fs.live.mapper.LiveOrderLogsMapper">

    <resultMap type="LiveOrderLogs" id="LiveOrderLogsResult">
        <result property="logsId"    column="logs_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="changeType"    column="change_type"    />
        <result property="changeMessage"    column="change_message"    />
        <result property="changeTime"    column="change_time"    />
        <result property="operator"    column="operator"    />
    </resultMap>

    <sql id="selectLiveOrderLogsVo">
        select logs_id, order_id, change_type, change_message, change_time, operator from live_order_logs
    </sql>

    <select id="selectLiveOrderLogsList" parameterType="LiveOrderLogs" resultMap="LiveOrderLogsResult">
        <include refid="selectLiveOrderLogsVo"/>
        <where>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="changeType != null  and changeType != ''"> and change_type = #{changeType}</if>
            <if test="changeMessage != null  and changeMessage != ''"> and change_message = #{changeMessage}</if>
            <if test="changeTime != null "> and change_time = #{changeTime}</if>
            <if test="operator != null  and operator != ''"> and operator = #{operator}</if>
        </where>
    </select>

    <select id="selectLiveOrderLogsByLogsId" parameterType="String" resultMap="LiveOrderLogsResult">
        <include refid="selectLiveOrderLogsVo"/>
        where logs_id = #{logsId}
    </select>

    <insert id="insertLiveOrderLogs" parameterType="LiveOrderLogs" useGeneratedKeys="true" keyProperty="logsId">
        insert into live_order_logs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null and orderId != ''">order_id,</if>
            <if test="changeType != null and changeType != ''">change_type,</if>
            <if test="changeMessage != null and changeMessage != ''">change_message,</if>
            <if test="changeTime != null">change_time,</if>
            <if test="operator != null">operator,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null and orderId != ''">#{orderId},</if>
            <if test="changeType != null and changeType != ''">#{changeType},</if>
            <if test="changeMessage != null and changeMessage != ''">#{changeMessage},</if>
            <if test="changeTime != null">#{changeTime},</if>
            <if test="operator != null">#{operator},</if>
         </trim>
    </insert>

    <update id="updateLiveOrderLogs" parameterType="LiveOrderLogs">
        update live_order_logs
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
            <if test="changeType != null and changeType != ''">change_type = #{changeType},</if>
            <if test="changeMessage != null and changeMessage != ''">change_message = #{changeMessage},</if>
            <if test="changeTime != null">change_time = #{changeTime},</if>
            <if test="operator != null">operator = #{operator},</if>
        </trim>
        where logs_id = #{logsId}
    </update>

    <delete id="deleteLiveOrderLogsByLogsId" parameterType="String">
        delete from live_order_logs where logs_id = #{logsId}
    </delete>

    <delete id="deleteLiveOrderLogsByLogsIds" parameterType="String">
        delete from live_order_logs where logs_id in
        <foreach item="logsId" collection="array" open="(" separator="," close=")">
            #{logsId}
        </foreach>
    </delete>
</mapper>
