<?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.bonus.material.work.mapper.SysWorkflowRecordMapper">


    <insert id="addSysWorkflowRecord" useGeneratedKeys="true" keyProperty="id">
        insert into sys_workflow_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="taskType != null">task_type,</if>
            <if test="taskCode != null">task_code,</if>
            <if test="workflowId != null">workflow_id,</if>
            <if test="workflowStatus != null">workflow_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="taskType != null">#{taskType},</if>
            <if test="taskCode != null">#{taskCode},</if>
            <if test="workflowId != null">#{workflowId},</if>
            <if test="workflowStatus != null">#{workflowStatus},</if>
        </trim>
    </insert>
    <update id="updateSysWorkflowRecord">
        update sys_workflow_record set workflow_status = #{workflowStatus} where task_id = #{taskId}
        <if test="taskType != null">
            and task_type = #{taskType}
        </if>
    </update>


     <select id="getSysWorkflowRecodeByTaskId" parameterType="Integer" resultType="com.bonus.material.work.domain.dto.SysWorkflowAuditDto">
         select
             a.id as id,
             a.task_id as taskId,
             a.task_type as taskType,
             a.task_code as taskCode,
             a.workflow_id as workflowId,
             a.workflow_status as workflowStatus
         from sys_workflow_record a
         <where>
             <if test="taskId != null">
                and a.task_id = #{taskId}
             </if>
         </where>
     </select>
</mapper>
