<?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="io.renren.dao.ConsumeTimeIntervalMapper">

    <resultMap type="ConsumeTimeInterval" id="ConsumeTimeIntervalResult">
        <result property="id"    column="id"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="useMode"    column="use_mode"    />
        <result property="tmrtype"    column="tmrtype"    />
        <result property="mark"    column="mark"    />
        <result property="level"    column="level"    />
        <result property="maxcount"    column="maxcount"    />
        <result property="fixmoney"    column="fixmoney"    />
        <result property="consumeType"    column="consume_type"    />
        <result property="paramId"    column="param_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"    />
    </resultMap>

    <sql id="selectConsumeTimeIntervalVo">
        select id, start_time, end_time, use_mode, tmrtype, mark, level, maxcount, fixmoney, consume_type, param_id, create_by, create_time, update_by, update_time from consume_time_interval
    </sql>

    <select id="selectConsumeTimeIntervalList" parameterType="ConsumeTimeInterval" resultMap="ConsumeTimeIntervalResult">
        <include refid="selectConsumeTimeIntervalVo"/>
        <where>
            <if test="startTime != null  and startTime != ''"> and start_time = #{startTime}</if>
            <if test="endTime != null  and endTime != ''"> and end_time = #{endTime}</if>
            <if test="useMode != null  and useMode != ''"> and use_mode = #{useMode}</if>
            <if test="consumeType != null  and consumeType != ''"> and consume_type = #{consumeType}</if>
        </where>
    </select>

    <select id="selectConsumeTimeIntervalById" parameterType="Long" resultMap="ConsumeTimeIntervalResult">
        <include refid="selectConsumeTimeIntervalVo"/>
        where id = #{id}
    </select>

    <insert id="insertConsumeTimeInterval" parameterType="ConsumeTimeInterval" useGeneratedKeys="true" keyProperty="id">
        insert into consume_time_interval
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="useMode != null">use_mode,</if>
            <if test="tmrtype != null">tmrtype,</if>
            <if test="mark != null">mark,</if>
            <if test="level != null">level,</if>
            <if test="maxcount != null">maxcount,</if>
            <if test="fixmoney != null">fixmoney,</if>
            <if test="consumeType != null">consume_type,</if>
            <if test="paramId != null">param_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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="useMode != null">#{useMode},</if>
            <if test="tmrtype != null">#{tmrtype},</if>
            <if test="mark != null">#{mark},</if>
            <if test="level != null">#{level},</if>
            <if test="maxcount != null">#{maxcount},</if>
            <if test="fixmoney != null">#{fixmoney},</if>
            <if test="consumeType != null">#{consumeType},</if>
            <if test="paramId != null">#{paramId},</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>
         </trim>
    </insert>

    <update id="updateConsumeTimeInterval" parameterType="ConsumeTimeInterval">
        update consume_time_interval
        <trim prefix="SET" suffixOverrides=",">
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="useMode != null">use_mode = #{useMode},</if>
            <if test="tmrtype != null">tmrtype = #{tmrtype},</if>
            <if test="mark != null">mark = #{mark},</if>
            <if test="level != null">level = #{level},</if>
            <if test="maxcount != null">maxcount = #{maxcount},</if>
            <if test="fixmoney != null">fixmoney = #{fixmoney},</if>
            <if test="consumeType != null">consume_type = #{consumeType},</if>
            <if test="paramId != null">param_id = #{paramId},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteConsumeTimeIntervalById" parameterType="Long">
        delete from consume_time_interval where id = #{id}
    </delete>

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