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

    <resultMap type="FsUserIntegralLogs" id="FsUserIntegralLogsResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="logType"    column="log_type"    />
        <result property="integral"    column="integral"    />
        <result property="balance"    column="balance"    />
        <result property="businessId"    column="business_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="businessType"    column="business_type"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectFsUserIntegralLogsVo">
        select id, user_id,status, log_type,business_type, integral, balance, business_id, create_time from fs_user_integral_logs
    </sql>

    <select id="selectFsUserIntegralLogsList" parameterType="FsUserIntegralLogs" resultMap="FsUserIntegralLogsResult">
        <include refid="selectFsUserIntegralLogsVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="logType != null  and logType != ''"> and log_type = #{logType}</if>
            <if test="integral != null "> and integral = #{integral}</if>
            <if test="balance != null "> and balance = #{balance}</if>
            <if test="businessId != null  and businessId != ''"> and business_id = #{businessId}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
            <if test="businessType != null "> and business_type = #{businessType}</if>
        </where>
    </select>

    <select id="selectFsUserIntegralLogsById" parameterType="Long" resultMap="FsUserIntegralLogsResult">
        <include refid="selectFsUserIntegralLogsVo"/>
        where id = #{id}
    </select>

    <insert id="insertFsUserIntegralLogs" parameterType="FsUserIntegralLogs">
        insert into fs_user_integral_logs
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="logType != null">log_type,</if>
            <if test="integral != null">integral,</if>
            <if test="balance != null">balance,</if>
            <if test="businessId != null">business_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="businessType != null">business_type,</if>
            <if test="status != null">status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="logType != null">#{logType},</if>
            <if test="integral != null">#{integral},</if>
            <if test="balance != null">#{balance},</if>
            <if test="businessId != null">#{businessId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="businessType != null">#{businessType},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateFsUserIntegralLogs" parameterType="FsUserIntegralLogs">
        update fs_user_integral_logs
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="logType != null">log_type = #{logType},</if>
            <if test="integral != null">integral = #{integral},</if>
            <if test="balance != null">balance = #{balance},</if>
            <if test="businessId != null">business_id = #{businessId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="businessType != null">business_type = #{businessType},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsUserIntegralLogsById" parameterType="Long">
        delete from fs_user_integral_logs where id = #{id}
    </delete>

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