<?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.ff.common.mapper.CurrencyMapper">
    
    <resultMap type="Currency" id="CurrencyResult">
        <result property="id"    column="id"    />
        <result property="status"    column="status"    />
        <result property="country"    column="country"    />
        <result property="currencyCode"    column="currency_code"    />
        <result property="currencySign"    column="currency_sign"    />
        <result property="gameRate"    column="game_rate"    />
        <result property="currencyDisplay"    column="currency_display"    />
        <result property="currencyName"    column="currency_name"    />
        <result property="fullName"    column="full_name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCurrencyVo">
        select id, status, country, currency_code, currency_sign, game_rate, currency_display, currency_name, full_name, create_by, create_time, update_by, update_time, remark from ff_currency
    </sql>

    <select id="selectCurrencyList" parameterType="Currency" resultMap="CurrencyResult">
        <include refid="selectCurrencyVo"/>
        <where>  
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="country != null  and country != ''"> and country = #{country}</if>
            <if test="currencyCode != null  and currencyCode != ''"> and currency_code = #{currencyCode}</if>
            <if test="currencySign != null  and currencySign != ''"> and currency_sign = #{currencySign}</if>
            <if test="gameRate != null "> and game_rate = #{gameRate}</if>
            <if test="currencyDisplay != null  and currencyDisplay != ''"> and currency_display = #{currencyDisplay}</if>
            <if test="currencyName != null  and currencyName != ''"> and currency_name like concat('%', #{currencyName}, '%')</if>
            <if test="fullName != null  and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
        </where>
    </select>
    
    <select id="selectCurrencyById" parameterType="Long" resultMap="CurrencyResult">
        <include refid="selectCurrencyVo"/>
        where id = #{id}
    </select>

    <insert id="insertCurrency" parameterType="Currency" useGeneratedKeys="true" keyProperty="id">
        insert into ff_currency
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="status != null">status,</if>
            <if test="country != null">country,</if>
            <if test="currencyCode != null">currency_code,</if>
            <if test="currencySign != null">currency_sign,</if>
            <if test="gameRate != null">game_rate,</if>
            <if test="currencyDisplay != null">currency_display,</if>
            <if test="currencyName != null">currency_name,</if>
            <if test="fullName != null">full_name,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="status != null">#{status},</if>
            <if test="country != null">#{country},</if>
            <if test="currencyCode != null">#{currencyCode},</if>
            <if test="currencySign != null">#{currencySign},</if>
            <if test="gameRate != null">#{gameRate},</if>
            <if test="currencyDisplay != null">#{currencyDisplay},</if>
            <if test="currencyName != null">#{currencyName},</if>
            <if test="fullName != null">#{fullName},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCurrency" parameterType="Currency">
        update ff_currency
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
            <if test="country != null">country = #{country},</if>
            <if test="currencyCode != null">currency_code = #{currencyCode},</if>
            <if test="currencySign != null">currency_sign = #{currencySign},</if>
            <if test="gameRate != null">game_rate = #{gameRate},</if>
            <if test="currencyDisplay != null">currency_display = #{currencyDisplay},</if>
            <if test="currencyName != null">currency_name = #{currencyName},</if>
            <if test="fullName != null">full_name = #{fullName},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCurrencyById" parameterType="Long">
        delete from ff_currency where id = #{id}
    </delete>

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