<?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.house365.ws.dao.mapper.ExternalCusCallLogMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.ExternalCustomerCallbackLogEntity">
        <result property="id" column="id"/>
        <result property="customerId" column="customer_id"/>
        <result property="managerId" column="manager_id"/>
        <result property="managerName" column="manager_name"/>
        <result property="content" column="content"/>
        <result property="createTime" column="create_time"/>
        <result property="result" column="result"/>
        <result property="creater" column="creater"/>
        <result property="callRecordId" column="call_record_id"/>
        <result property="callRecordName" column="call_record_name"/>
        <result property="callRecordDuration" column="call_record_duration"/>
        <result property="source" column="source"/>
    </resultMap>

    <insert id="saveCallBackLog" useGeneratedKeys="true" keyProperty="id"  keyColumn="id" parameterType="com.house365.beans.entity.ExternalCustomerCallbackLogEntity">
        insert into  external_customer_callback_log
        (customer_id,manager_id,manager_name,content,
        create_time,result,creater)
        values
        (
        #{customerId},#{managerId},#{managerName},#{content},
        #{createTime},#{result},#{creater}
        )
    </insert>

    <select id="queryByConditions" parameterType="map" resultMap="infoMap">
        select
        *
        FROM external_customer_callback_log
        where 1 = 1
        <if test="customerId != null and customerId != ''">
            AND customer_id = #{customerId}
        </if>
        <if test="idList != null and idList.size() > 0 ">
            AND customer_id in
            <foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        ORDER BY create_time DESC
    </select>

    <select id="getById" parameterType="map" resultMap="infoMap">
        select
         *
        FROM external_customer_callback_log
        where id = #{id}
    </select>

    <update id="update" parameterType="com.house365.beans.entity.ExternalCustomerCallbackLogEntity">
        UPDATE external_customer_callback_log
        SET
        content = #{content}
        WHERE id = #{id}
    </update>

</mapper>