<?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.AppGameMoneyMapper">
    
    <resultMap type="com.game.business.domain.AppGameMoney" id="AppGameMoneyResult">
        <result property="id"    column="id"    />
        <result property="appGameId"    column="app_game_id"    />
        <result property="bettingMoney"    column="betting_money"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAppGameMoneyVo">
        select id, app_game_id, betting_money, del_flag from app_game_money
    </sql>

    <select id="selectAppGameMoneyList" parameterType="com.game.business.domain.AppGameMoney" resultMap="AppGameMoneyResult">
        <include refid="selectAppGameMoneyVo"/>
        <where>
            del_flag = 0
            <if test="appGameId != null "> and app_game_id = #{appGameId}</if>
            <if test="bettingMoney != null "> and betting_money = #{bettingMoney}</if>
        </where>
    </select>
    
    <select id="selectAppGameMoneyById" parameterType="Long" resultMap="AppGameMoneyResult">
        <include refid="selectAppGameMoneyVo"/>
        where id = #{id} and del_flag = 0
    </select>
        
    <insert id="insertAppGameMoney" parameterType="com.game.business.domain.AppGameMoney" useGeneratedKeys="true" keyProperty="id">
        insert into app_game_money
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="appGameId != null">app_game_id,</if>
            <if test="bettingMoney != null">betting_money,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="appGameId != null">#{appGameId},</if>
            <if test="bettingMoney != null">#{bettingMoney},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateAppGameMoney" parameterType="com.game.business.domain.AppGameMoney">
        update app_game_money
        <trim prefix="SET" suffixOverrides=",">
            <if test="appGameId != null">app_game_id = #{appGameId},</if>
            <if test="bettingMoney != null">betting_money = #{bettingMoney},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteAppGameMoneyById" parameterType="Long">
        update app_game_money set del_flag = 1 where id = #{id}
    </update>

    <delete id="deleteAppGameMoneyByIds" parameterType="String">
        update app_game_money set del_flag = 1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>