<?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.cmvr.inspection.mapper.InspectionTaskLogMapper">
    
    <resultMap type="com.cmvr.inspection.domain.InspectionTaskLog" id="InspectionTaskLogResult">
        <result property="id"    column="id"    />
        <result property="taskInstanceId"    column="task_instance_id"    />
        <result property="taskId"    column="task_id"    />
        <result property="itemId"    column="item_id"    />
        <result property="nodeId"    column="node_id"    />
        <result property="nodeName"    column="node_name"    />
        <result property="logType"    column="log_type"    />
        <result property="logContent"    column="log_content"    />
        <result property="mediaUrl"    column="media_url"    />
        <result property="status"    column="status"    />
        <result property="progress"    column="progress"    />
        <result property="logTime"    column="log_time"    />
        <result property="extraInfo"    column="extra_info"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectInspectionTaskLogVo">
        select id, task_instance_id, task_id, item_id, node_id, node_name,
               log_type, log_content, media_url, status, progress, log_time, extra_info, 
               create_by, create_time, update_by, update_time, remark
        from inspection_task_log
    </sql>

    <select id="selectInspectionTaskLogList" resultMap="InspectionTaskLogResult">
        <include refid="selectInspectionTaskLogVo"/>
        where task_instance_id = #{taskInstanceId}
        order by log_time asc
    </select>

    <insert id="batchInsertInspectionTaskLog">
        insert into inspection_task_log(
            id, task_instance_id, task_id, item_id, node_id, node_name,
            log_type, log_content, media_url, status, progress, log_time, extra_info,
            create_by, create_time, remark
        ) values
        <foreach collection="list" item="item" separator=",">
            (
                #{item.id}, #{item.taskInstanceId}, #{item.taskId}, #{item.itemId},
                #{item.nodeId}, #{item.nodeName},
                #{item.logType}, #{item.logContent}, #{item.mediaUrl}, #{item.status}, 
                #{item.progress}, #{item.logTime}, #{item.extraInfo},
                #{item.createBy}, #{item.createTime}, #{item.remark}
            )
        </foreach>
    </insert>

</mapper>
