<?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.AppGameCommissionMapper">
    
    <resultMap type="com.game.business.domain.AppGameCommission" id="AppGameCommissionResult">
        <result property="id"    column="id"    />
        <result property="gameId"    column="game_id"    />
        <result property="userId"    column="user_id"    />
        <result property="pid"    column="pid"    />
        <result property="gameRate"    column="game_rate"    />
    </resultMap>

    <sql id="selectAppGameCommissionVo">
        select id, game_id, user_id, pid, game_rate from app_game_commission
    </sql>

    <select id="selectAppGameCommissionList" parameterType="com.game.business.domain.AppGameCommission" resultMap="AppGameCommissionResult">
        <include refid="selectAppGameCommissionVo"/>
        <where>  
            <if test="gameId != null "> and game_id = #{gameId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="pid != null "> and pid = #{pid}</if>
            <if test="gameRate != null "> and game_rate = #{gameRate}</if>
        </where>
    </select>
    
    <select id="selectAppGameCommissionById" parameterType="Long" resultMap="AppGameCommissionResult">
        <include refid="selectAppGameCommissionVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAppGameCommission" parameterType="com.game.business.domain.AppGameCommission">
        insert into app_game_commission
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="gameId != null">game_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="pid != null">pid,</if>
            <if test="gameRate != null">game_rate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="gameId != null">#{gameId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="pid != null">#{pid},</if>
            <if test="gameRate != null">#{gameRate},</if>
         </trim>
    </insert>

    <update id="updateAppGameCommission" parameterType="com.game.business.domain.AppGameCommission">
        update app_game_commission
        <trim prefix="SET" suffixOverrides=",">
            <if test="gameId != null">game_id = #{gameId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="pid != null">pid = #{pid},</if>
            <if test="gameRate != null">game_rate = #{gameRate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppGameCommissionById" parameterType="Long">
        delete from app_game_commission where id = #{id}
    </delete>

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