<?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.playlet.system.mapper.PlayletUserAccountMapper">

    <resultMap type="PlayletUserAccount" id="PlayletUserAccountResult">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="userId"    column="user_id"    />
        <result property="realName"    column="real_name"    />
        <result property="zfbAccount"    column="zfb_account"    />
        <result property="bankCardType"    column="bank_card_type"    />
        <result property="bankCardAccountName"    column="bank_card_account_name"    />
        <result property="bankCardArea"    column="bank_card_area"    />
        <result property="bankCardSubBranchName"    column="bank_card_sub_branch_name"    />
        <result property="bankCardNumber"    column="bank_card_number"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectPlayletUserAccountVo">
        select id, create_time, update_time, create_by, update_by, user_id, real_name, zfb_account, bank_card_type, bank_card_account_name, bank_card_area, bank_card_sub_branch_name, bank_card_number, remark from playlet_user_account
    </sql>

    <select id="selectPlayletUserAccountList" parameterType="PlayletUserAccount" resultMap="PlayletUserAccountResult">
        <include refid="selectPlayletUserAccountVo"/>
        <where>
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="realName != null  and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
            <if test="zfbAccount != null  and zfbAccount != ''"> and zfb_account = #{zfbAccount}</if>
            <if test="bankCardType != null "> and bank_card_type = #{bankCardType}</if>
            <if test="bankCardAccountName != null  and bankCardAccountName != ''"> and bank_card_account_name like concat('%', #{bankCardAccountName}, '%')</if>
            <if test="bankCardArea != null  and bankCardArea != ''"> and bank_card_area = #{bankCardArea}</if>
            <if test="bankCardSubBranchName != null  and bankCardSubBranchName != ''"> and bank_card_sub_branch_name like concat('%', #{bankCardSubBranchName}, '%')</if>
            <if test="bankCardNumber != null  and bankCardNumber != ''"> and bank_card_number = #{bankCardNumber}</if>
        </where>
    </select>

    <select id="selectPlayletUserAccountById" parameterType="Long" resultMap="PlayletUserAccountResult">
        <include refid="selectPlayletUserAccountVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlayletUserAccount" parameterType="PlayletUserAccount" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_user_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="userId != null and userId != ''">user_id,</if>
            <if test="realName != null and realName != ''">real_name,</if>
            <if test="zfbAccount != null and zfbAccount != ''">zfb_account,</if>
            <if test="bankCardType != null">bank_card_type,</if>
            <if test="bankCardAccountName != null and bankCardAccountName != ''">bank_card_account_name,</if>
            <if test="bankCardArea != null and bankCardArea != ''">bank_card_area,</if>
            <if test="bankCardSubBranchName != null and bankCardSubBranchName != ''">bank_card_sub_branch_name,</if>
            <if test="bankCardNumber != null and bankCardNumber != ''">bank_card_number,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="userId != null and userId != ''">#{userId},</if>
            <if test="realName != null and realName != ''">#{realName},</if>
            <if test="zfbAccount != null and zfbAccount != ''">#{zfbAccount},</if>
            <if test="bankCardType != null">#{bankCardType},</if>
            <if test="bankCardAccountName != null and bankCardAccountName != ''">#{bankCardAccountName},</if>
            <if test="bankCardArea != null and bankCardArea != ''">#{bankCardArea},</if>
            <if test="bankCardSubBranchName != null and bankCardSubBranchName != ''">#{bankCardSubBranchName},</if>
            <if test="bankCardNumber != null and bankCardNumber != ''">#{bankCardNumber},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletUserAccount" parameterType="PlayletUserAccount">
        update playlet_user_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="userId != null and userId != ''">user_id = #{userId},</if>
            <if test="realName != null and realName != ''">real_name = #{realName},</if>
            <if test="zfbAccount != null and zfbAccount != ''">zfb_account = #{zfbAccount},</if>
            <if test="bankCardType != null">bank_card_type = #{bankCardType},</if>
            <if test="bankCardAccountName != null and bankCardAccountName != ''">bank_card_account_name = #{bankCardAccountName},</if>
            <if test="bankCardArea != null and bankCardArea != ''">bank_card_area = #{bankCardArea},</if>
            <if test="bankCardSubBranchName != null and bankCardSubBranchName != ''">bank_card_sub_branch_name = #{bankCardSubBranchName},</if>
            <if test="bankCardNumber != null and bankCardNumber != ''">bank_card_number = #{bankCardNumber},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlayletUserAccountById" parameterType="Long">
        delete from playlet_user_account where id = #{id}
    </delete>

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

</mapper>