<?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.miaxis.record.mapper.BrowseRecordInfoMapper">

    <resultMap type="BrowseRecordInfo" id="BrowseRecordInfoResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="customerId"    column="customer_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectBrowseRecordInfoVo">
        select * from browse_record_info
    </sql>


    <select id="getBrowseRecordInfoList" resultType="com.miaxis.record.vo.BrowseRecordCustomerVo">
        SELECT
        bri.id,
        ci.id as customerId,
        ci.corporate_name,
        ci.applet_address,
        f1.file_url as corporateLogoFileUrl,
        f2.file_url as appletLogoFileUrl,
        f3.file_url as appletQrCodeFileUrl,
        ci.applet_introduce,
        bri.update_time,
        ci.status
        FROM `customer_info` ci
        LEFT JOIN file_info f1 on f1.file_id = ci.corporate_logo
        LEFT JOIN file_info f2 on f2.file_id = ci.applet_logo
        LEFT JOIN file_info f3 on f3.file_id = ci.applet_qr_code
        LEFT JOIN browse_record_info bri ON bri.customer_id = ci.id
        WHERE ci.id IN ( select bri.customer_id from browse_record_info bri where bri.user_id = #{id})

    </select>

</mapper>
