<?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.ghy.order.mapper.OrderCallRecordMapper">

    <resultMap type="OrderCallRecord" id="OrderCallRecordResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="order_id"    />
        <result property="orderType"    column="order_type"    />
        <result property="callTime"    column="call_time"    />
    </resultMap>

    <sql id="selectOrderCallRecordVo">
        select id, order_id, order_type, call_time from order_call_record
    </sql>

    <select id="selectOrderCallRecordList" parameterType="OrderCallRecord" resultMap="OrderCallRecordResult">
        <include refid="selectOrderCallRecordVo"/>
        <where>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
            <if test="callTime != null "> and call_time = #{callTime}</if>
        </where>
    </select>

    <select id="selectOrderCallRecordById" parameterType="Long" resultMap="OrderCallRecordResult">
        <include refid="selectOrderCallRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertOrderCallRecord" parameterType="OrderCallRecord" useGeneratedKeys="true" keyProperty="id">
        insert into order_call_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="orderType != null">order_type,</if>
            <if test="callTime != null">call_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="callTime != null">#{callTime},</if>
        </trim>
    </insert>

    <update id="updateOrderCallRecord" parameterType="OrderCallRecord">
        update order_call_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="callTime != null">call_time = #{callTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderCallRecordById" parameterType="Long">
        delete from order_call_record where id = #{id}
    </delete>

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

</mapper>