<?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.inspur.mapper.ElevatorWorkNodeMapper">
    
    <resultMap type="ElevatorWorkNode" id="ElevatorWorkNodeResult">
        <result property="id"    column="id"    />
        <result property="workOrderId"    column="work_order_id"    />
        <result property="nodeName"    column="node_name"    />
        <result property="nodeTime"    column="node_time"    />
        <result property="contentName"    column="content_name"    />
        <result property="contentRemark"    column="content_remark"    />
        <result property="type"    column="type"    />
        <result property="isSuccess"    column="is_success"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectElevatorWorkNodeVo">
        select id, work_order_id, node_name, node_time, content_name, content_remark, type, is_success, create_time from elevator_work_node
    </sql>

    <select id="selectElevatorWorkNodeList" parameterType="ElevatorWorkNode" resultMap="ElevatorWorkNodeResult">
        <include refid="selectElevatorWorkNodeVo"/>
        <where>  
            <if test="workOrderId != null "> and work_order_id = #{workOrderId}</if>
            <if test="nodeName != null  and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
            <if test="nodeTime != null "> and node_time = #{nodeTime}</if>
            <if test="contentName != null  and contentName != ''"> and content_name like concat('%', #{contentName}, '%')</if>
            <if test="contentRemark != null  and contentRemark != ''"> and content_remark = #{contentRemark}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="isSuccess != null  and isSuccess != ''"> and is_success = #{isSuccess}</if>
        </where>
    </select>
    
    <select id="selectElevatorWorkNodeById" parameterType="Long" resultMap="ElevatorWorkNodeResult">
        <include refid="selectElevatorWorkNodeVo"/>
        where id = #{id}
    </select>

    <insert id="insertElevatorWorkNode" parameterType="ElevatorWorkNode" useGeneratedKeys="true" keyProperty="id">
        insert into elevator_work_node
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workOrderId != null">work_order_id,</if>
            <if test="nodeName != null">node_name,</if>
            <if test="nodeTime != null">node_time,</if>
            <if test="contentName != null">content_name,</if>
            <if test="contentRemark != null">content_remark,</if>
            <if test="type != null and type != ''">type,</if>
            <if test="isSuccess != null">is_success,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workOrderId != null">#{workOrderId},</if>
            <if test="nodeName != null">#{nodeName},</if>
            <if test="nodeTime != null">#{nodeTime},</if>
            <if test="contentName != null">#{contentName},</if>
            <if test="contentRemark != null">#{contentRemark},</if>
            <if test="type != null and type != ''">#{type},</if>
            <if test="isSuccess != null">#{isSuccess},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateElevatorWorkNode" parameterType="ElevatorWorkNode">
        update elevator_work_node
        <trim prefix="SET" suffixOverrides=",">
            <if test="workOrderId != null">work_order_id = #{workOrderId},</if>
            <if test="nodeName != null">node_name = #{nodeName},</if>
            <if test="nodeTime != null">node_time = #{nodeTime},</if>
            <if test="contentName != null">content_name = #{contentName},</if>
            <if test="contentRemark != null">content_remark = #{contentRemark},</if>
            <if test="type != null and type != ''">type = #{type},</if>
            <if test="isSuccess != null">is_success = #{isSuccess},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteElevatorWorkNodeById" parameterType="Long">
        delete from elevator_work_node where id = #{id}
    </delete>

    <delete id="deleteElevatorWorkNodeByIds" parameterType="String">
        delete from elevator_work_node where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>