<?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.ruoyi.frequency.rechargecoin.mapper.RechargeCoinMapper">
    
    <resultMap type="com.ruoyi.frequency.rechargecoin.entity.RechargeCoin" id="RechargeCoinResult">
        <result property="id"    column="id"    />
        <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="delFlag"    column="del_flag"    />
        <result property="coin"    column="coin"    />
        <result property="price"    column="price"    />
        <result property="phoneType"    column="phone_type"    />
    </resultMap>

    <sql id="selectRechargeCoinVo">
        select id, create_by, create_time, update_by, update_time, del_flag, coin, price, phone_type from t_recharge_coin
    </sql>

    <select id="selectRechargeCoinList" parameterType="com.ruoyi.frequency.rechargecoin.entity.RechargeCoin" resultMap="RechargeCoinResult">
        <include refid="selectRechargeCoinVo"/>
        <where> and del_flag != 2
            <if test="coin != null "> and coin = #{coin}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="phoneType != null "> and phone_type = #{phoneType}</if>
        </where>
        order by price desc
    </select>
    
    <select id="selectRechargeCoinById" parameterType="String" resultMap="RechargeCoinResult">
        <include refid="selectRechargeCoinVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRechargeCoin" parameterType="com.ruoyi.frequency.rechargecoin.entity.RechargeCoin">
        insert into t_recharge_coin
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</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="delFlag != null">del_flag,</if>
            <if test="coin != null">coin,</if>
            <if test="price != null">price,</if>
            <if test="phoneType != null">phone_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</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="delFlag != null">#{delFlag},</if>
            <if test="coin != null">#{coin},</if>
            <if test="price != null">#{price},</if>
            <if test="phoneType != null">#{phoneType},</if>
         </trim>
    </insert>

    <update id="updateRechargeCoin" parameterType="com.ruoyi.frequency.rechargecoin.entity.RechargeCoin">
        update t_recharge_coin
        <trim prefix="SET" suffixOverrides=",">
            <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="delFlag != null">del_flag = #{delFlag},</if>
            <if test="coin != null">coin = #{coin},</if>
            <if test="price != null">price = #{price},</if>
            <if test="phoneType != null">phone_type = #{phoneType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRechargeCoinById" parameterType="String">
        delete from t_recharge_coin where id = #{id}
    </delete>

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