<?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.game.business.mapper.AppUsersCashAccountMapper">
    
    <resultMap type="com.game.business.domain.AppUsersCashAccount" id="AppUsersCashAccountResult">
        <result property="id"    column="id"    />
        <result property="account"    column="account"    />
        <result property="accountBank"    column="account_bank"    />
        <result property="addtime"    column="addtime"    />
        <result property="branch"    column="branch"    />
        <result property="isDefault"    column="is_default"    />
        <result property="name"    column="name"    />
        <result property="type"    column="type"    />
        <result property="channelId"    column="channel_id"    />
        <result property="uid"    column="uid"    />
    </resultMap>

    <sql id="selectAppUsersCashAccountVo">
        select id, account, account_bank, addtime, branch, is_default, name, type, uid,channel_id from app_users_cash_account
    </sql>

    <select id="selectAppUsersCashAccountList" parameterType="com.game.business.domain.AppUsersCashAccount" resultMap="AppUsersCashAccountResult">
        <include refid="selectAppUsersCashAccountVo"/>
        <where>  
            <if test="account != null  and account != ''"> and account = #{account}</if>
            <if test="accountBank != null  and accountBank != ''"> and account_bank = #{accountBank}</if>
            <if test="addtime != null "> and addtime = #{addtime}</if>
            <if test="branch != null  and branch != ''"> and branch = #{branch}</if>
            <if test="isDefault != null "> and is_default = #{isDefault}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="channelId != null "> and channel_id = #{channelId}</if>
        </where>
    </select>
    
    <select id="selectAppUsersCashAccountById" parameterType="Long" resultMap="AppUsersCashAccountResult">
        <include refid="selectAppUsersCashAccountVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAppUsersCashAccount" parameterType="com.game.business.domain.AppUsersCashAccount">
        insert into app_users_cash_account
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="account != null">account,</if>
            <if test="accountBank != null">account_bank,</if>
            <if test="addtime != null">addtime,</if>
            <if test="branch != null">branch,</if>
            <if test="isDefault != null">is_default,</if>
            <if test="name != null">name,</if>
            <if test="type != null">type,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="uid != null">uid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="account != null">#{account},</if>
            <if test="accountBank != null">#{accountBank},</if>
            <if test="addtime != null">#{addtime},</if>
            <if test="branch != null">#{branch},</if>
            <if test="isDefault != null">#{isDefault},</if>
            <if test="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="uid != null">#{uid},</if>
         </trim>
    </insert>

    <update id="updateAppUsersCashAccount" parameterType="com.game.business.domain.AppUsersCashAccount">
        update app_users_cash_account
        <trim prefix="SET" suffixOverrides=",">
            <if test="account != null">account = #{account},</if>
            <if test="accountBank != null">account_bank = #{accountBank},</if>
            <if test="addtime != null">addtime = #{addtime},</if>
            <if test="branch != null">branch = #{branch},</if>
            <if test="isDefault != null">is_default = #{isDefault},</if>
            <if test="name != null">name = #{name},</if>
            <if test="type != null">type = #{type},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="uid != null">uid = #{uid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppUsersCashAccountById" parameterType="Long">
        delete from app_users_cash_account where id = #{id}
    </delete>

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