<?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.FsStoreOrderStatusMapper">
    
    <resultMap type="FsStoreOrderStatus" id="FsStoreOrderStatusResult">
        <result property="id"    column="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"    />
    </resultMap>

    <sql id="selectFsStoreOrderStatusVo">
        select id, order_id, change_type, change_message, change_time from fs_store_order_status
    </sql>

    <select id="selectFsStoreOrderStatusList" parameterType="FsStoreOrderStatus" resultMap="FsStoreOrderStatusResult">
        <include refid="selectFsStoreOrderStatusVo"/>
        <where>  
            <if test="orderId != null "> 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>
        </where>
    </select>
    
    <select id="selectFsStoreOrderStatusById" parameterType="Long" resultMap="FsStoreOrderStatusResult">
        <include refid="selectFsStoreOrderStatusVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreOrderStatus" parameterType="FsStoreOrderStatus" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_order_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="changeType != null and changeType != ''">#{changeType},</if>
            <if test="changeMessage != null and changeMessage != ''">#{changeMessage},</if>
            <if test="changeTime != null">#{changeTime},</if>
         </trim>
    </insert>

    <update id="updateFsStoreOrderStatus" parameterType="FsStoreOrderStatus">
        update fs_store_order_status
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreOrderStatusById" parameterType="Long">
        delete from fs_store_order_status where id = #{id}
    </delete>

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