<?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.goldenwater.slgc.mapper.PlayerItemMapper">

    <resultMap type="PlayerItem" id="PlayerItemResult">
        <result property="id" column="ID"/>
        <result property="plyId" column="PLY_ID"/>
        <result property="imgText" column="IMG_TEXT"/>
        <result property="imgUrl" column="IMG_URL"/>
        <result property="linkUrl" column="LINK_URL"/>
        <result property="linkType" column="LINK_TYPE"/>
        <result property="note" column="NOTE"/>
    </resultMap>

    <sql id="selectPlayerItemVo">
        select ID, PLY_ID, IMG_TEXT, IMG_URL, LINK_URL, LINK_TYPE, NOTE
        from BIZ_PLAYER_ITEM
    </sql>

    <select id="selectPlayerItemList" parameterType="PlayerItem" resultMap="PlayerItemResult">
        <include refid="selectPlayerItemVo"/>
        <where>
            <if test="plyId != null and plyId != ''">
                and PLY_ID = #{plyId}
            </if>
            <if test="linkType != null and linkType != ''">
                and LINK_TYPE = #{linkType}
            </if>
        </where>
        order by ID
    </select>

    <select id="selectAll" resultMap="PlayerItemResult">
        <include refid="selectPlayerItemVo"/>
        order by ID
    </select>

    <select id="selectPlayerItemById" parameterType="String" resultMap="PlayerItemResult">
        <include refid="selectPlayerItemVo"/>
        where ID = #{id}
    </select>

    <delete id="deletePlayerItemById" parameterType="String">
        delete from BIZ_PLAYER_ITEM where ID = #{id}
    </delete>

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

    <delete id="deleteByPlyId" parameterType="String">
        delete from BIZ_PLAYER_ITEM where PLY_ID = #{plyId}
    </delete>

    <insert id="insertPlayerItem" parameterType="PlayerItem">
        insert into BIZ_PLAYER_ITEM
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">ID,</if>
            <if test="plyId != null">PLY_ID,</if>
            <if test="imgText != null">IMG_TEXT,</if>
            <if test="imgUrl != null">IMG_URL,</if>
            <if test="linkUrl != null">LINK_URL,</if>
            <if test="linkType != null">LINK_TYPE,</if>
            <if test="note != null">NOTE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plyId != null">#{plyId},</if>
            <if test="imgText != null">#{imgText},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="linkUrl != null">#{linkUrl},</if>
            <if test="linkType != null">#{linkType},</if>
            <if test="note != null">#{note},</if>
        </trim>
    </insert>

    <update id="updatePlayerItem" parameterType="PlayerItem">
        update BIZ_PLAYER_ITEM
        <trim prefix="SET" suffixOverrides=",">
            <if test="plyId != null">PLY_ID = #{plyId},</if>
            <if test="imgText != null">IMG_TEXT = #{imgText},</if>
            <if test="imgUrl != null">IMG_URL = #{imgUrl},</if>
            <if test="linkUrl != null">LINK_URL = #{linkUrl},</if>
            <if test="linkType != null">LINK_TYPE = #{linkType},</if>
            <if test="note != null">NOTE = #{note},</if>
        </trim>
        where ID = #{id}
    </update>

</mapper>
