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

    <resultMap type="FsStoreVisit" id="FsStoreVisitResult">
        <result property="id"    column="id"    />
        <result property="productId"    column="product_id"    />
        <result property="productType"    column="product_type"    />
        <result property="cateId"    column="cate_id"    />
        <result property="userId"    column="user_id"    />
        <result property="count"    column="count"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFsStoreVisitVo">
        select id, product_id, product_type, cate_id, user_id, count, content, create_time,update_time from fs_store_visit
    </sql>

    <select id="selectFsStoreVisitList" parameterType="FsStoreVisit" resultMap="FsStoreVisitResult">
        <include refid="selectFsStoreVisitVo"/>
        <where>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="productType != null  and productType != ''"> and product_type = #{productType}</if>
            <if test="cateId != null "> and cate_id = #{cateId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="count != null "> and count = #{count}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectFsStoreVisitById" parameterType="Long" resultMap="FsStoreVisitResult">
        <include refid="selectFsStoreVisitVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreVisit" parameterType="FsStoreVisit" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_visit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productId != null">product_id,</if>
            <if test="productType != null">product_type,</if>
            <if test="cateId != null">cate_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="count != null">count,</if>
            <if test="content != null">content,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="productId != null">#{productId},</if>
            <if test="productType != null">#{productType},</if>
            <if test="cateId != null">#{cateId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="count != null">#{count},</if>
            <if test="content != null">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateFsStoreVisit" parameterType="FsStoreVisit">
        update fs_store_visit
        <trim prefix="SET" suffixOverrides=",">
            <if test="productId != null">product_id = #{productId},</if>
            <if test="productType != null">product_type = #{productType},</if>
            <if test="cateId != null">cate_id = #{cateId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="count != null">count = #{count},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreVisitById" parameterType="Long">
        delete from fs_store_visit where id = #{id}
    </delete>

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