<?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.FsUserExtractMapper">
    
    <resultMap type="FsUserExtract" id="FsUserExtractResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="realName"    column="real_name"    />
        <result property="extractType"    column="extract_type"    />
        <result property="bankCode"    column="bank_code"    />
        <result property="bankAddress"    column="bank_address"    />
        <result property="alipayCode"    column="alipay_code"    />
        <result property="extractPrice"    column="extract_price"    />
        <result property="mark"    column="mark"    />
        <result property="balance"    column="balance"    />
        <result property="failMsg"    column="fail_msg"    />
        <result property="failTime"    column="fail_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
        <result property="wechat"    column="wechat"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectFsUserExtractVo">
        select id, user_id, real_name, extract_type, bank_code, bank_address, alipay_code, extract_price, mark, balance, fail_msg, fail_time, create_time, update_time, status, wechat, is_del from fs_user_extract
    </sql>

    <select id="selectFsUserExtractList" parameterType="FsUserExtract" resultMap="FsUserExtractResult">
        <include refid="selectFsUserExtractVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="realName != null  and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
            <if test="extractType != null  and extractType != ''"> and extract_type = #{extractType}</if>
            <if test="bankCode != null  and bankCode != ''"> and bank_code = #{bankCode}</if>
            <if test="bankAddress != null  and bankAddress != ''"> and bank_address = #{bankAddress}</if>
            <if test="alipayCode != null  and alipayCode != ''"> and alipay_code = #{alipayCode}</if>
            <if test="extractPrice != null "> and extract_price = #{extractPrice}</if>
            <if test="mark != null  and mark != ''"> and mark = #{mark}</if>
            <if test="balance != null "> and balance = #{balance}</if>
            <if test="failMsg != null  and failMsg != ''"> and fail_msg = #{failMsg}</if>
            <if test="failTime != null "> and fail_time = #{failTime}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="wechat != null  and wechat != ''"> and wechat = #{wechat}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectFsUserExtractById" parameterType="Long" resultMap="FsUserExtractResult">
        <include refid="selectFsUserExtractVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsUserExtract" parameterType="FsUserExtract" useGeneratedKeys="true" keyProperty="id">
        insert into fs_user_extract
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="realName != null">real_name,</if>
            <if test="extractType != null">extract_type,</if>
            <if test="bankCode != null">bank_code,</if>
            <if test="bankAddress != null">bank_address,</if>
            <if test="alipayCode != null">alipay_code,</if>
            <if test="extractPrice != null">extract_price,</if>
            <if test="mark != null">mark,</if>
            <if test="balance != null">balance,</if>
            <if test="failMsg != null">fail_msg,</if>
            <if test="failTime != null">fail_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
            <if test="wechat != null">wechat,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="realName != null">#{realName},</if>
            <if test="extractType != null">#{extractType},</if>
            <if test="bankCode != null">#{bankCode},</if>
            <if test="bankAddress != null">#{bankAddress},</if>
            <if test="alipayCode != null">#{alipayCode},</if>
            <if test="extractPrice != null">#{extractPrice},</if>
            <if test="mark != null">#{mark},</if>
            <if test="balance != null">#{balance},</if>
            <if test="failMsg != null">#{failMsg},</if>
            <if test="failTime != null">#{failTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>
            <if test="wechat != null">#{wechat},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateFsUserExtract" parameterType="FsUserExtract">
        update fs_user_extract
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="realName != null">real_name = #{realName},</if>
            <if test="extractType != null">extract_type = #{extractType},</if>
            <if test="bankCode != null">bank_code = #{bankCode},</if>
            <if test="bankAddress != null">bank_address = #{bankAddress},</if>
            <if test="alipayCode != null">alipay_code = #{alipayCode},</if>
            <if test="extractPrice != null">extract_price = #{extractPrice},</if>
            <if test="mark != null">mark = #{mark},</if>
            <if test="balance != null">balance = #{balance},</if>
            <if test="failMsg != null">fail_msg = #{failMsg},</if>
            <if test="failTime != null">fail_time = #{failTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="wechat != null">wechat = #{wechat},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsUserExtractById" parameterType="Long">
        delete from fs_user_extract where id = #{id}
    </delete>

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