<?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="cn.com.ty.lift.business.emergency.mapper.EmergencyHistoryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.com.ty.lift.business.emergency.dto.HistoryResponse">
        <id column="id" property="id"/>
        <result column="er_record_id" property="erRecordId"/>
        <result column="operator_id" property="operatorId"/>
        <result column="operator" property="operator"/>
        <result column="operate_date" property="operateDate"/>
        <result column="operate" property="operate"/>
        <result column="description" property="description"/>
        <result column="before_content" property="beforeContent"/>
        <result column="after_content" property="afterContent"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, er_record_id, operator_id, operate_date, description, before_content, after_content
    </sql>

    <select id="pageByEmergencyRepair" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.business.emergency.dto.RepairRequest">
        SELECT
            eh.*,
            ui.`name` AS operator
        FROM
            emergency_history eh
            LEFT JOIN user_info ui ON eh.operator_id = ui.user_id
        WHERE
            eh.er_record_id = #{cond.id}
    </select>
</mapper>
