<?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.ruoyi.flowable.mapper.WfModelProcdefMapper">

    <resultMap type="WfModelProcdef" id="WfModelProcdefResult">
        <result property="modelId" column="model_id"/>
        <result property="procdefId" column="procdef_id"/>
        <result property="formType" column="form_type"/>
        <result property="formCreatePath" column="form_create_path"/>
        <result property="formViewPath" column="form_view_path"/>
    </resultMap>

    <sql id="selectWfModelProcdefVo">
        select model_id, procdef_id, form_type, form_create_path, form_view_path
        from wf_model_procdef
    </sql>

    <select id="selectWfModelProcdefList" parameterType="WfModelProcdef" resultMap="WfModelProcdefResult">
        <include refid="selectWfModelProcdefVo"/>
        <where>
            <if test="modelId != null  and modelId != ''">and model_id = #{modelId}</if>
            <if test="procdefId != null  and procdefId != ''">and procdef_id = #{procdefId}</if>
            <if test="formType != null  and formType != ''">and form_type = #{formType}</if>
            <if test="formCreatePath != null  and formCreatePath != ''">and form_create_path = #{formCreatePath}</if>
            <if test="formViewPath != null  and formViewPath != ''">and form_view_path = #{formViewPath}</if>
        </where>
    </select>

    <select id="selectWfModelProcdefByModelId" parameterType="String" resultMap="WfModelProcdefResult">
        <include refid="selectWfModelProcdefVo"/>
        where model_id = #{modelId}
    </select>

    <select id="selectWfModelProcdefListByModelIdList" resultType="java.lang.String">
        select procdef_id from wf_model_procdef where model_id in
        <foreach item="modelId" collection="modelIdList" open="(" separator="," close=")">
            #{modelId}
        </foreach>
    </select>

    <select id="selectWfModelProcdefByProcdefId" parameterType="String" resultMap="WfModelProcdefResult">
        <include refid="selectWfModelProcdefVo"/>
        where procdef_id = #{procdefId}
    </select>

    <insert id="insertWfModelProcdef" parameterType="WfModelProcdef">
        insert into wf_model_procdef
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="modelId != null">model_id,</if>
            <if test="procdefId != null">procdef_id,</if>
            <if test="formType != null">form_type,</if>
            <if test="formCreatePath != null">form_create_path,</if>
            <if test="formViewPath != null">form_view_path,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="modelId != null">#{modelId},</if>
            <if test="procdefId != null">#{procdefId},</if>
            <if test="formType != null">#{formType},</if>
            <if test="formCreatePath != null">#{formCreatePath},</if>
            <if test="formViewPath != null">#{formViewPath},</if>
        </trim>
    </insert>

    <update id="updateWfModelProcdef" parameterType="WfModelProcdef">
        update wf_model_procdef
        <trim prefix="SET" suffixOverrides=",">
            <if test="procdefId != null">procdef_id = #{procdefId},</if>
            <if test="formType != null">form_type = #{formType},</if>
            <if test="formCreatePath != null">form_create_path = #{formCreatePath},</if>
            <if test="formViewPath != null">form_view_path = #{formViewPath},</if>
        </trim>
        where model_id = #{modelId}
    </update>

    <delete id="deleteWfModelProcdefByModelId" parameterType="String">
        delete
        from wf_model_procdef
        where model_id = #{modelId}
    </delete>

    <delete id="deleteWfModelProcdefByModelIds" parameterType="String">
        delete from wf_model_procdef where model_id in
        <foreach item="modelId" collection="array" open="(" separator="," close=")">
            #{modelId}
        </foreach>
    </delete>

    <delete id="deleteWfModelProcdefByProcdefId">
        delete
        from wf_model_procdef
        where procdef_id = #{procdefId}
    </delete>
</mapper>
