<?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.zehong.system.mapper.SysRealTimeAdRangeMapper">
    
    <resultMap type="SysRealTimeAdRange" id="SysRealTimeAdRangeResult">
        <result property="id"    column="f_id"    />
        <result property="realTimeAdMin"    column="f_real_time_ad_min"    />
        <result property="realTimeAdMax"    column="f_real_time_ad_max"    />
    </resultMap>

    <sql id="selectSysRealTimeAdRangeVo">
        select f_id, f_real_time_ad_min, f_real_time_ad_max from t_sys_real_time_ad_range
    </sql>

    <select id="selectSysRealTimeAdRangeList" parameterType="SysRealTimeAdRange" resultMap="SysRealTimeAdRangeResult">
        <include refid="selectSysRealTimeAdRangeVo"/>
        <where>  
            <if test="realTimeAdMin != null "> and f_real_time_ad_min = #{realTimeAdMin}</if>
            <if test="realTimeAdMax != null "> and f_real_time_ad_max = #{realTimeAdMax}</if>
        </where>
    </select>
    <select id="getTopOne" resultMap="SysRealTimeAdRangeResult">
        <include refid="selectSysRealTimeAdRangeVo"/>
        limit 1
    </select>
    
    <select id="selectSysRealTimeAdRangeById" parameterType="Long" resultMap="SysRealTimeAdRangeResult">
        <include refid="selectSysRealTimeAdRangeVo"/>
        where f_id = #{id}
    </select>
        
    <insert id="insertSysRealTimeAdRange" parameterType="SysRealTimeAdRange" useGeneratedKeys="true" keyProperty="id">
        insert into t_sys_real_time_ad_range
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="realTimeAdMin != null">f_real_time_ad_min,</if>
            <if test="realTimeAdMax != null">f_real_time_ad_max,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="realTimeAdMin != null">#{realTimeAdMin},</if>
            <if test="realTimeAdMax != null">#{realTimeAdMax},</if>
         </trim>
    </insert>

    <update id="updateSysRealTimeAdRange" parameterType="SysRealTimeAdRange">
        update t_sys_real_time_ad_range
        <trim prefix="SET" suffixOverrides=",">
            <if test="realTimeAdMin != null">f_real_time_ad_min = #{realTimeAdMin},</if>
            <if test="realTimeAdMax != null">f_real_time_ad_max = #{realTimeAdMax},</if>
        </trim>
        where f_id = #{id}
    </update>

    <delete id="deleteSysRealTimeAdRangeById" parameterType="Long">
        delete from t_sys_real_time_ad_range where f_id = #{id}
    </delete>

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