<?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.repair.mapper.RepairTrackRecordMapper">
    <resultMap type="com.repair.model.vo.TrackDetailsVo" id="detailDatasMap">
        <result property="id" column="id"/>
        <result property="maintenanceState" column="maintenance_state"/>
        <result property="content" column="content"/>
        <result property="createTime" column="create_time"/>
        <result property="userName" column="user_name"/>
        <result property="userZzstr" column="user_zzstr"/>
        <result property="image" column="image"/>
        <result property="voice" column="voice"/>
        <result property="voiceLength" column="voice_length"/>
    </resultMap>
    <select id="queryDetailData" resultType="com.repair.model.vo.TrackDetailsVo" resultMap="detailDatasMap">
        select rtr.id,rtr.maintenance_state,rtr.content as content,rtr.create_time,ru.user_name,rtr.user_zzstr,rtr.image,rtr.voice,rtr.voice_length from repair_track_record rtr
        left join repair_user ru on ru.deleted = 0 and ru.id = rtr.user_id
        where rtr.deleted = 0
        <if test="recordId != null and recordId != ''">
            and rtr.record_id = #{recordId}
        </if>
        order by rtr.create_time asc
    </select>

</mapper>
