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

    <resultMap type="LiveAfterSalesLogs" id="LiveAfterSalesLogsResult">
        <result property="logsId"    column="logs_id"    />
        <result property="storeAfterSalesId"    column="store_after_sales_id"    />
        <result property="changeType"    column="change_type"    />
        <result property="changeMessage"    column="change_message"    />
        <result property="changeTime"    column="change_time"    />
        <result property="operator"    column="operator"    />
        <result property="companyId"    column="company_id"    />
        <result property="storeId"    column="store_id"    />
    </resultMap>

    <sql id="selectLiveAfterSalesLogsVo">
        select logs_id, store_after_sales_id, change_type, change_message, change_time, operator, company_id, store_id from live_after_sales_logs
    </sql>

    <select id="selectLiveAfterSalesLogsList" parameterType="LiveAfterSalesLogs" resultMap="LiveAfterSalesLogsResult">
        <include refid="selectLiveAfterSalesLogsVo"/>
        <where>
            <if test="storeAfterSalesId != null "> and store_after_sales_id = #{storeAfterSalesId}</if>
            <if test="changeType != null "> 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>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="storeId != null "> and store_id = #{storeId}</if>
        </where>
    </select>

    <select id="selectLiveAfterSalesLogsByLogsId" parameterType="Long" resultMap="LiveAfterSalesLogsResult">
        <include refid="selectLiveAfterSalesLogsVo"/>
        where logs_id = #{logsId}
    </select>

    <insert id="insertLiveAfterSalesLogs" parameterType="LiveAfterSalesLogs" useGeneratedKeys="true" keyProperty="logsId">
        insert into live_after_sales_logs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="storeAfterSalesId != null">store_after_sales_id,</if>
            <if test="changeType != null">change_type,</if>
            <if test="changeMessage != null">change_message,</if>
            <if test="changeTime != null">change_time,</if>
            <if test="operator != null">operator,</if>
            <if test="companyId != null">company_id,</if>
            <if test="storeId != null">store_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="storeAfterSalesId != null">#{storeAfterSalesId},</if>
            <if test="changeType != null">#{changeType},</if>
            <if test="changeMessage != null">#{changeMessage},</if>
            <if test="changeTime != null">#{changeTime},</if>
            <if test="operator != null">#{operator},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="storeId != null">#{storeId},</if>
         </trim>
    </insert>

    <update id="updateLiveAfterSalesLogs" parameterType="LiveAfterSalesLogs">
        update live_after_sales_logs
        <trim prefix="SET" suffixOverrides=",">
            <if test="storeAfterSalesId != null">store_after_sales_id = #{storeAfterSalesId},</if>
            <if test="changeType != null">change_type = #{changeType},</if>
            <if test="changeMessage != null">change_message = #{changeMessage},</if>
            <if test="changeTime != null">change_time = #{changeTime},</if>
            <if test="operator != null">operator = #{operator},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="storeId != null">store_id = #{storeId},</if>
        </trim>
        where logs_id = #{logsId}
    </update>

    <delete id="deleteLiveAfterSalesLogsByLogsId" parameterType="Long">
        delete from live_after_sales_logs where logs_id = #{logsId}
    </delete>

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