<?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.mall.mapper.MallSeckillTimeMapper">

    <resultMap type="MallSeckillTime" id="MallSeckillTimeResult">
        <result property="id"    column="id"    />
        <result property="timeHour"    column="time_hour"    />
        <result property="timeEnd"    column="time_end"    />
        <result property="createAt"    column="create_at"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <resultMap type="SeckillTimeVO" id="SeckillTimeVOResult">
        <result property="id"    column="id"    />
        <result property="timeHour"    column="time_hour"    />
        <result property="timeEnd"    column="time_end"    />
    </resultMap>

    <sql id="selectMallSeckillTimeVo">
        select id, time_hour, time_end, create_at, status, del_flag from mall_seckill_time
    </sql>

    <select id="getSeckillTimeList" parameterType="MallSeckillTime" resultMap="SeckillTimeVOResult">
        select id, time_hour, time_end from mall_seckill_time
        where status = '0' and del_flag = '0'
        order by time_hour asc
    </select>

    <select id="selectMallSeckillTimeList" parameterType="MallSeckillTime" resultMap="MallSeckillTimeResult">
        <include refid="selectMallSeckillTimeVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="timeHour != null  and timeHour != ''"> and time_hour = #{timeHour}</if>
            <if test="timeEnd != null  and timeEnd != ''"> and time_end = #{timeEnd}</if>
            <if test="createAt != null  and createAt != ''"> and create_at = #{createAt}</if>
            and del_flag = '0'
        </where>
        order by time_hour asc
    </select>

    <select id="selectMallSeckillTimeById" parameterType="Integer" resultMap="MallSeckillTimeResult">
        <include refid="selectMallSeckillTimeVo"/>
        where id = #{id}
    </select>

    <insert id="insertMallSeckillTime" parameterType="MallSeckillTime" useGeneratedKeys="true" keyProperty="id">
        insert into mall_seckill_time
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="timeHour != null">time_hour,</if>
            <if test="timeEnd != null">time_end,</if>
            <if test="createAt != null">create_at,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="timeHour != null">#{timeHour},</if>
            <if test="timeEnd != null">#{timeEnd},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateMallSeckillTime" parameterType="MallSeckillTime">
        update mall_seckill_time
        <trim prefix="SET" suffixOverrides=",">
            <if test="timeHour != null">time_hour = #{timeHour},</if>
            <if test="timeEnd != null">time_end = #{timeEnd},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallSeckillTimeById" parameterType="Integer">
        <!--delete from mall_seckill_time where id = #{id}-->
        update mall_seckill_time set del_flag = '1' where id = #{id}
    </delete>

    <delete id="deleteMallSeckillTimeByIds" parameterType="String">
        <!--delete from mall_seckill_time where id in-->
        update mall_seckill_time set del_flag = '1' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
