<?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.AppDealScaleMapper">
    
    <resultMap type="com.game.business.domain.AppDealScale" id="AppDealScaleResult">
        <result property="id"    column="id"    />
        <result property="dealScale"    column="deal_scale"    />
        <result property="isTrue"    column="is_true"    />
        <result property="planId"    column="plan_id"    />
        <result property="tranType2"    column="tran_type2"    />
        <result property="tranType3"    column="tran_type3"    />
        <result property="uid"    column="uid"    />
    </resultMap>

    <sql id="selectAppDealScaleVo">
        select id, deal_scale, is_true, plan_id, tran_type2, tran_type3, uid from app_deal_scale
    </sql>

    <select id="selectAppDealScaleList" parameterType="com.game.business.domain.AppDealScale" resultMap="AppDealScaleResult">
        <include refid="selectAppDealScaleVo"/>
        <where>  
            <if test="dealScale != null "> and deal_scale = #{dealScale}</if>
            <if test="isTrue != null "> and is_true = #{isTrue}</if>
            <if test="planId != null "> and plan_id = #{planId}</if>
            <if test="tranType2 != null "> and tran_type2 = #{tranType2}</if>
            <if test="tranType3 != null "> and tran_type3 = #{tranType3}</if>
            <if test="uid != null "> and uid = #{uid}</if>
        </where>
    </select>
    
    <select id="selectAppDealScaleById" parameterType="Long" resultMap="AppDealScaleResult">
        <include refid="selectAppDealScaleVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAppDealScale" parameterType="com.game.business.domain.AppDealScale">
        insert into app_deal_scale
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="dealScale != null">deal_scale,</if>
            <if test="isTrue != null">is_true,</if>
            <if test="planId != null">plan_id,</if>
            <if test="tranType2 != null">tran_type2,</if>
            <if test="tranType3 != null">tran_type3,</if>
            <if test="uid != null">uid,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="dealScale != null">#{dealScale},</if>
            <if test="isTrue != null">#{isTrue},</if>
            <if test="planId != null">#{planId},</if>
            <if test="tranType2 != null">#{tranType2},</if>
            <if test="tranType3 != null">#{tranType3},</if>
            <if test="uid != null">#{uid},</if>
         </trim>
    </insert>

    <update id="updateAppDealScale" parameterType="com.game.business.domain.AppDealScale">
        update app_deal_scale
        <trim prefix="SET" suffixOverrides=",">
            <if test="dealScale != null">deal_scale = #{dealScale},</if>
            <if test="isTrue != null">is_true = #{isTrue},</if>
            <if test="planId != null">plan_id = #{planId},</if>
            <if test="tranType2 != null">tran_type2 = #{tranType2},</if>
            <if test="tranType3 != null">tran_type3 = #{tranType3},</if>
            <if test="uid != null">uid = #{uid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppDealScaleById" parameterType="Long">
        delete from app_deal_scale where id = #{id}
    </delete>

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