<?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.FsStoreAfterSalesItemMapper">
    
    <resultMap type="FsStoreAfterSalesItem" id="FsStoreAfterSalesItemResult">
        <result property="id"    column="id"    />
        <result property="storeAfterSalesId"    column="store_after_sales_id"    />
        <result property="productId"    column="product_id"    />
        <result property="jsonInfo"    column="json_info"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectFsStoreAfterSalesItemVo">
        select id, store_after_sales_id, product_id, json_info, is_del from fs_store_after_sales_item
    </sql>

    <select id="selectFsStoreAfterSalesItemList" parameterType="FsStoreAfterSalesItem" resultMap="FsStoreAfterSalesItemResult">
        <include refid="selectFsStoreAfterSalesItemVo"/>
        <where>  
            <if test="storeAfterSalesId != null "> and store_after_sales_id = #{storeAfterSalesId}</if>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="jsonInfo != null  and jsonInfo != ''"> and json_info = #{jsonInfo}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectFsStoreAfterSalesItemById" parameterType="Long" resultMap="FsStoreAfterSalesItemResult">
        <include refid="selectFsStoreAfterSalesItemVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreAfterSalesItem" parameterType="FsStoreAfterSalesItem" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_after_sales_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="storeAfterSalesId != null">store_after_sales_id,</if>
            <if test="productId != null">product_id,</if>
            <if test="jsonInfo != null and jsonInfo != ''">json_info,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="storeAfterSalesId != null">#{storeAfterSalesId},</if>
            <if test="productId != null">#{productId},</if>
            <if test="jsonInfo != null and jsonInfo != ''">#{jsonInfo},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateFsStoreAfterSalesItem" parameterType="FsStoreAfterSalesItem">
        update fs_store_after_sales_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="storeAfterSalesId != null">store_after_sales_id = #{storeAfterSalesId},</if>
            <if test="productId != null">product_id = #{productId},</if>
            <if test="jsonInfo != null and jsonInfo != ''">json_info = #{jsonInfo},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreAfterSalesItemById" parameterType="Long">
        delete from fs_store_after_sales_item where id = #{id}
    </delete>

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