<?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.fateverse.workflow.mapper.FormItemDataMapper">

    <insert id="insert">
        insert into wk_ru_form_item_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="processInstanceId != null and processInstanceId != ''">process_instance_id,</if>
            <if test="isPresent != null ">is_present,</if>
            <if test="isStart != null ">is_start,</if>
            <if test="formData != null and formData != ''">form_data,</if>
            <if test="optionalUser != null and optionalUser != ''">optional_user,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="processInstanceId != null and processInstanceId != ''">#{processInstanceId},</if>
            <if test="isStart != null ">#{isStart},</if>
            <if test="isPresent != null ">#{isPresent},</if>
            <if test="formData != null and formData != ''">#{formData},</if>
            <if test="optionalUser != null and optionalUser != ''">#{optionalUser},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>
    <update id="updatePresentStart">
        update wk_ru_form_item_data
        set is_present = 0
        where process_instance_id = #{processInstanceId}
    </update>

    <select id="selectByProcessInstanceId" resultType="cn.fateverse.workflow.entity.vo.FormItemData">
        select id, process_instance_id, is_start, is_present, form_data,optional_user, create_time, create_by
        from wk_ru_form_item_data
        <where>
            <if test="isPresent != null">and is_present = #{isPresent}</if>
            <if test="processInstanceId != null and processInstanceId != ''">and process_instance_id =
                #{processInstanceId}
            </if>
        </where>
    </select>
</mapper>