<?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.dsk.system.mapper.CustomerFollowRecordMapper">

    <sql id="Base_Bean">
        cfr.id, cfr.customer_id, cfr.user_id, cfr.visit_mode, cfr.next_visit_time, cfr.name, cfr.position,
        cfr.content, cfr.create_time
    </sql>

    <select id="selectList" resultType="com.dsk.system.domain.customer.CustomerFollowRecord">
        select
        <include refid="Base_Bean"></include>
        from customer_follow_record cfr
        join sys_user u on u.user_id = cfr.user_id
        join sys_dept d on d.dept_id = u.dept_id
        where cfr.user_id = #{dto.userId}
        <if test="dto.customerId != null and dto.customerId != '' "> and cfr.customer_id = #{dto.customerId} </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by cfr.create_time desc
    </select>

</mapper>

