<?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.ygtx.gxt.mapper.GxtRepairOrderFlowMapper">
    
    <resultMap type="GxtRepairOrderFlow" id="GxtRepairOrderFlowResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="order_id"    />
        <result property="orderCode"    column="order_code"    />
        <result property="actionType"    column="action_type"    />
        <result property="fromStatus"    column="from_status"    />
        <result property="toStatus"    column="to_status"    />
        <result property="operatorId"    column="operator_id"    />
        <result property="operatorName"    column="operator_name"    />
        <result property="actionTime"    column="action_time"    />
        <result property="actionRemark"    column="action_remark"    />
        <result property="fromScoreStatus"    column="from_score_status"    />
        <result property="toScoreStatus"    column="to_score_status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectGxtRepairOrderFlowVo">
        select id, order_id, order_code, action_type, from_status, to_status, operator_id, operator_name, action_time, action_remark, from_score_status, to_score_status, create_by, create_time from gxt_repair_order_flow
    </sql>

    <select id="selectGxtRepairOrderFlowList" parameterType="GxtRepairOrderFlow" resultMap="GxtRepairOrderFlowResult">
        <include refid="selectGxtRepairOrderFlowVo"/>
        <where>  
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="orderCode != null  and orderCode != ''"> and order_code = #{orderCode}</if>
            <if test="actionType != null  and actionType != ''"> and action_type = #{actionType}</if>
            <if test="fromStatus != null  and fromStatus != ''"> and from_status = #{fromStatus}</if>
            <if test="toStatus != null  and toStatus != ''"> and to_status = #{toStatus}</if>
            <if test="operatorId != null "> and operator_id = #{operatorId}</if>
            <if test="operatorName != null  and operatorName != ''"> and operator_name like concat('%', #{operatorName}, '%')</if>
            <if test="actionTime != null "> and action_time = #{actionTime}</if>
            <if test="actionRemark != null  and actionRemark != ''"> and action_remark = #{actionRemark}</if>
            <if test="fromScoreStatus != null and fromScoreStatus != ''"> and from_score_status = #{fromScoreStatus}</if>
            <if test="toScoreStatus != null and toScoreStatus != ''"> and to_score_status = #{toScoreStatus}</if>
        </where>
    </select>
    
    <select id="selectGxtRepairOrderFlowListByOrderId" parameterType="Long" resultMap="GxtRepairOrderFlowResult">
        <include refid="selectGxtRepairOrderFlowVo"/>
        where order_id = #{orderId}
    </select>
    
    <select id="selectGxtRepairOrderFlowById" parameterType="Long" resultMap="GxtRepairOrderFlowResult">
        <include refid="selectGxtRepairOrderFlowVo"/>
        where id = #{id}
    </select>

    <insert id="insertGxtRepairOrderFlow" parameterType="GxtRepairOrderFlow" useGeneratedKeys="true" keyProperty="id">
        insert into gxt_repair_order_flow
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="orderCode != null and orderCode != ''">order_code,</if>
            <if test="actionType != null and actionType != ''">action_type,</if>
            <if test="fromStatus != null">from_status,</if>
            <if test="toStatus != null and toStatus != ''">to_status,</if>
            <if test="operatorId != null">operator_id,</if>
            <if test="operatorName != null">operator_name,</if>
            <if test="actionTime != null">action_time,</if>
            <if test="actionRemark != null">action_remark,</if>
            <if test="fromScoreStatus != null">from_score_status,</if>
            <if test="toScoreStatus != null">to_score_status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
            <if test="actionType != null and actionType != ''">#{actionType},</if>
            <if test="fromStatus != null">#{fromStatus},</if>
            <if test="toStatus != null and toStatus != ''">#{toStatus},</if>
            <if test="operatorId != null">#{operatorId},</if>
            <if test="operatorName != null">#{operatorName},</if>
            <if test="actionTime != null">#{actionTime},</if>
            <if test="actionRemark != null">#{actionRemark},</if>
            <if test="fromScoreStatus != null">#{fromScoreStatus},</if>
            <if test="toScoreStatus != null">#{toScoreStatus},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateGxtRepairOrderFlow" parameterType="GxtRepairOrderFlow">
        update gxt_repair_order_flow
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
            <if test="actionType != null and actionType != ''">action_type = #{actionType},</if>
            <if test="fromStatus != null">from_status = #{fromStatus},</if>
            <if test="toStatus != null and toStatus != ''">to_status = #{toStatus},</if>
            <if test="operatorId != null">operator_id = #{operatorId},</if>
            <if test="operatorName != null">operator_name = #{operatorName},</if>
            <if test="actionTime != null">action_time = #{actionTime},</if>
            <if test="actionRemark != null">action_remark = #{actionRemark},</if>
            <if test="fromScoreStatus != null">from_score_status = #{fromScoreStatus},</if>
            <if test="toScoreStatus != null">to_score_status = #{toScoreStatus},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGxtRepairOrderFlowById" parameterType="Long">
        delete from gxt_repair_order_flow where id = #{id}
    </delete>

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