<?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.younike.system.mapper.OrderVerificationRecordMapper">

    <resultMap type="com.younike.system.domain.OrderVerificationRecord" id="OrderVerificationRecordResult">
        <result property="orderVerificationRecordId"    column="order_verification_record_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="memberId"    column="member_id"    />
        <result property="serverId"    column="server_id"    />
        <result property="appointmentTime"    column="appointment_time"    />
        <result property="appointmentStatus"    column="appointment_status"    />
        <result property="orderVerificationCode"    column="order_verification_code"    />
        <result property="delFlag"    column="del_flag"    />
        <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"    />
        <result property="orderVerificationCode"    column="order_verification_code"    />

    </resultMap>

    <sql id="selectOrderVerificationRecordVo">
        select order_verification_record_id, order_id, member_id, server_id, appointment_time, appointment_status, order_verification_code, del_flag, create_by, create_time, update_by, update_time, remark from order_verification_record
    </sql>

    <select id="selectOrderVerificationRecordList" parameterType="com.younike.system.domain.OrderVerificationRecord" resultMap="OrderVerificationRecordResult">
        <include refid="selectOrderVerificationRecordVo"/>
        <where>
            <if test="orderId != null ">and order_id = #{orderId}</if>
            <if test="memberId != null ">and member_id = #{memberId}</if>
            <if test="serverId != null ">and server_id = #{serverId}</if>
            <if test="appointmentTime != null ">and appointment_time = #{appointmentTime}</if>
            <if test="appointmentStatus != null  and appointmentStatus != ''">and appointment_status =
                #{appointmentStatus}
            </if>
            <if test="delFlag != null and delFlag !='' ">and del_flag = #{delFlag}</if>
            <if test="orderVerificationCode != null  and orderVerificationCode != ''">and order_verification_code =
                #{orderVerificationCode}
            </if>
        </where>
        order by appointment_time asc
    </select>

    <select id="selectOrderVerificationRecordByOrderVerificationRecordId" parameterType="Long" resultMap="OrderVerificationRecordResult">
        <include refid="selectOrderVerificationRecordVo"/>
        where order_verification_record_id = #{orderVerificationRecordId}
    </select>

    <insert id="insertOrderVerificationRecord" parameterType="com.younike.system.domain.OrderVerificationRecord" useGeneratedKeys="true" keyProperty="orderVerificationRecordId">
        insert into order_verification_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="memberId != null">member_id,</if>
            <if test="serverId != null">server_id,</if>
            <if test="appointmentTime != null">appointment_time,</if>
            <if test="appointmentStatus != null and appointmentStatus != ''">appointment_status,</if>
            <if test="orderVerificationCode != null and orderVerificationCode != ''">order_verification_code,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</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 and remark != ''">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="memberId != null">#{memberId},</if>
            <if test="serverId != null">#{serverId},</if>
            <if test="appointmentTime != null">#{appointmentTime},</if>
            <if test="appointmentStatus != null and appointmentStatus != ''">#{appointmentStatus},</if>
            <if test="orderVerificationCode != null and orderVerificationCode != ''">#{orderVerificationCode},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</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 and remark != ''">#{remark},</if>
         </trim>
    </insert>

    <update id="updateOrderVerificationRecord" parameterType="com.younike.system.domain.OrderVerificationRecord">
        update order_verification_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="serverId != null">server_id = #{serverId},</if>
            <if test="appointmentTime != null">appointment_time = #{appointmentTime},</if>
            <if test="appointmentStatus != null and appointmentStatus != ''">appointment_status = #{appointmentStatus},</if>
            <if test="orderVerificationCode != null and orderVerificationCode != ''">order_verification_code = #{orderVerificationCode},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</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 and remark != ''">remark = #{remark},</if>
        </trim>
        where order_verification_record_id = #{orderVerificationRecordId}
    </update>

    <delete id="deleteOrderVerificationRecordByOrderVerificationRecordId" parameterType="Long">
        delete from order_verification_record where order_verification_record_id = #{orderVerificationRecordId}
    </delete>

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