<?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.qmth.themis.business.dao.TEExamStudentLogMapper">

	<select id="getExamStudentLogList" resultType="com.qmth.themis.business.bean.admin.ExamStudentLogDetailListBean">
        select * from
            (select
                    f.create_time createTime,
                    (case
                         when JSON_VALID(f.title) = 1 then convert((f.title->>'$.title') using utf8)
                         else f.title
                        end) as type,
                    f.info remark,
                    f.ip,
                    f.country,
                    f.region,
                    f.province,
                    f.city,
                    f.isp,
                    f.id
                from
                    t_e_exam_student_log f
                where
                    f.exam_student_id = #{examStudentId}
                union all
                select
                    f.send_time createTime,
                    if(f.type = 'TEXT','文本消息','语音消息'),
                    f.content as remark,
                    null as ip,
                    null as country,
                    null as region,
                    null as province,
                    null as city,
                    null as isp,
                    f.id
                from
                    t_ie_exam_invigilate_notice f
                where
                    f.receive_user_id = #{examStudentId}
                union all
                select
                    f.create_time createTime,
                    '多媒体消息' as type,
                    f.content as remark,
                    null as ip,
                    null as country,
                    null as region,
                    null as province,
                    null as city,
                    null as isp,
                    f.id
                from
                    t_ie_exam_media_log f
                where
                    f.exam_student_id = #{examStudentId}) t
        order by t.createTime
    </select>
</mapper>
