<?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.AppGameMapper">
    
    <resultMap type="com.game.business.domain.AppGame" id="AppGameResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="classifyId"    column="classify_id"    />
        <result property="logoUrl"    column="logo_url"    />
        <result property="gamePath"    column="game_path"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="orderno"    column="orderno"    />
        <result property="gameExpand1"    column="game_expand1"    />
        <result property="gameExpand2"    column="game_expand2"    />
        <result property="gameExpand3"    column="game_expand3"    />
        <result property="gameExpand4"    column="game_expand4"    />
    </resultMap>

    <sql id="selectAppGameVo">
        select id, name, classify_id, logo_url, game_path, status, create_time, orderno, game_expand1, game_expand2, game_expand3, game_expand4 from app_game
    </sql>

    <select id="selectAppGameList" parameterType="com.game.business.domain.AppGame" resultMap="AppGameResult">
        <include refid="selectAppGameVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="classifyId != null "> and classify_id = #{classifyId}</if>
            <if test="logoUrl != null  and logoUrl != ''"> and logo_url = #{logoUrl}</if>
            <if test="gamePath != null  and gamePath != ''"> and game_path = #{gamePath}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="orderno != null "> and orderno = #{orderno}</if>
            <if test="gameExpand1 != null  and gameExpand1 != ''"> and game_expand1 = #{gameExpand1}</if>
            <if test="gameExpand2 != null  and gameExpand2 != ''"> and game_expand2 = #{gameExpand2}</if>
            <if test="gameExpand3 != null  and gameExpand3 != ''"> and game_expand3 = #{gameExpand3}</if>
            <if test="gameExpand4 != null  and gameExpand4 != ''"> and game_expand4 = #{gameExpand4}</if>
        </where>
    </select>
    
    <select id="selectAppGameById" parameterType="Long" resultMap="AppGameResult">
        <include refid="selectAppGameVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAppGame" parameterType="com.game.business.domain.AppGame">
        insert into app_game
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="classifyId != null">classify_id,</if>
            <if test="logoUrl != null">logo_url,</if>
            <if test="gamePath != null">game_path,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="orderno != null">orderno,</if>
            <if test="gameExpand1 != null">game_expand1,</if>
            <if test="gameExpand2 != null">game_expand2,</if>
            <if test="gameExpand3 != null">game_expand3,</if>
            <if test="gameExpand4 != null">game_expand4,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="classifyId != null">#{classifyId},</if>
            <if test="logoUrl != null">#{logoUrl},</if>
            <if test="gamePath != null">#{gamePath},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="orderno != null">#{orderno},</if>
            <if test="gameExpand1 != null">#{gameExpand1},</if>
            <if test="gameExpand2 != null">#{gameExpand2},</if>
            <if test="gameExpand3 != null">#{gameExpand3},</if>
            <if test="gameExpand4 != null">#{gameExpand4},</if>
         </trim>
    </insert>

    <update id="updateAppGame" parameterType="com.game.business.domain.AppGame">
        update app_game
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="classifyId != null">classify_id = #{classifyId},</if>
            <if test="logoUrl != null">logo_url = #{logoUrl},</if>
            <if test="gamePath != null">game_path = #{gamePath},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="orderno != null">orderno = #{orderno},</if>
            <if test="gameExpand1 != null">game_expand1 = #{gameExpand1},</if>
            <if test="gameExpand2 != null">game_expand2 = #{gameExpand2},</if>
            <if test="gameExpand3 != null">game_expand3 = #{gameExpand3},</if>
            <if test="gameExpand4 != null">game_expand4 = #{gameExpand4},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppGameById" parameterType="Long">
        delete from app_game where id = #{id}
    </delete>

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