<?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.leromro.core.mapper.VolunteerReservationTimeMapper">
    
    <resultMap type="VolunteerReservationTime" id="VolunteerReservationTimeResult">
        <result property="volunteerReservationTimeId"    column="volunteer_reservation_time_id"    />
        <result property="volunteerId"    column="volunteer_id"    />
        <result property="reservationDate"    column="reservation_date"    />
        <result property="reservationTime"    column="reservation_time"    />
        <result property="clientId"    column="client_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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectVolunteerReservationTimeVo">
        select volunteer_reservation_time_id, volunteer_id, reservation_date, reservation_time, client_id, create_by, create_time, update_by, update_time, remark from l_volunteer_reservation_time
    </sql>

    <select id="selectVolunteerReservationTimeList" parameterType="VolunteerReservationTime" resultMap="VolunteerReservationTimeResult">
        <include refid="selectVolunteerReservationTimeVo"/>
        <where>  
            <if test="volunteerId != null "> and volunteer_id = #{volunteerId}</if>
            <if test="reservationDate != null "> and reservation_date = #{reservationDate}</if>
            <if test="reservationTime != null "> and reservation_time = #{reservationTime}</if>
            <if test="clientId != null "> and client_id = #{clientId}</if>
        </where>
    </select>
    
    <select id="selectVolunteerReservationTimeByVolunteerReservationTimeId" parameterType="Long" resultMap="VolunteerReservationTimeResult">
        <include refid="selectVolunteerReservationTimeVo"/>
        where volunteer_reservation_time_id = #{volunteerReservationTimeId}
    </select>

    <insert id="insertVolunteerReservationTime" parameterType="VolunteerReservationTime" useGeneratedKeys="true" keyProperty="volunteerReservationTimeId">
        insert into l_volunteer_reservation_time
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="volunteerId != null">volunteer_id,</if>
            <if test="reservationDate != null">reservation_date,</if>
            <if test="reservationTime != null">reservation_time,</if>
            <if test="clientId != null">client_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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="volunteerId != null">#{volunteerId},</if>
            <if test="reservationDate != null">#{reservationDate},</if>
            <if test="reservationTime != null">#{reservationTime},</if>
            <if test="clientId != null">#{clientId},</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="updateVolunteerReservationTime" parameterType="VolunteerReservationTime">
        update l_volunteer_reservation_time
        <trim prefix="SET" suffixOverrides=",">
            <if test="volunteerId != null">volunteer_id = #{volunteerId},</if>
            <if test="reservationDate != null">reservation_date = #{reservationDate},</if>
            <if test="reservationTime != null">reservation_time = #{reservationTime},</if>
            <if test="clientId != null">client_id = #{clientId},</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 volunteer_reservation_time_id = #{volunteerReservationTimeId}
    </update>

    <delete id="deleteVolunteerReservationTimeByVolunteerReservationTimeId" parameterType="Long">
        delete from l_volunteer_reservation_time where volunteer_reservation_time_id = #{volunteerReservationTimeId}
    </delete>

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