<?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.store.mapper.FsStoreAfterSalesStatusMapper">
    
    <resultMap type="FsStoreAfterSalesStatus" id="FsStoreAfterSalesStatusResult">
        <result property="id"    column="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"    />
    </resultMap>

    <sql id="selectFsStoreAfterSalesStatusVo">
        select id, store_after_sales_id, change_type, change_message, change_time, operator from fs_store_after_sales_status
    </sql>

    <select id="selectFsStoreAfterSalesStatusList" parameterType="FsStoreAfterSalesStatus" resultMap="FsStoreAfterSalesStatusResult">
        <include refid="selectFsStoreAfterSalesStatusVo"/>
        <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>
        </where>
    </select>
    
    <select id="selectFsStoreAfterSalesStatusById" parameterType="Long" resultMap="FsStoreAfterSalesStatusResult">
        <include refid="selectFsStoreAfterSalesStatusVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreAfterSalesStatus" parameterType="FsStoreAfterSalesStatus" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_after_sales_status
        <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>
         </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>
         </trim>
    </insert>

    <update id="updateFsStoreAfterSalesStatus" parameterType="FsStoreAfterSalesStatus">
        update fs_store_after_sales_status
        <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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreAfterSalesStatusById" parameterType="Long">
        delete from fs_store_after_sales_status where id = #{id}
    </delete>

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