<?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.zkqy.system.mapper.BpmNodeHandleUserMapper">

    <resultMap type="com.zkqy.system.entity.BpmNodeHandleUser" id="BpmNodeHandleUserResult">
        <result property="id" column="id"/>
        <result property="virtuallyRole" column="virtually_role"/>
        <result property="realRole" column="real_role"/>
        <result property="executeUserNo" column="execute_user_no"/>
    </resultMap>

    <sql id="selectBpmNodeHandleUserVo">
        select id, virtually_role, real_role, execute_user_no
        from bpm_node_handle_user
    </sql>

    <select id="selectBpmNodeHandleUserList" parameterType="com.zkqy.system.entity.BpmNodeHandleUser"
            resultMap="BpmNodeHandleUserResult">
        <include refid="selectBpmNodeHandleUserVo"/>
        <where>
            <if test="virtuallyRole != null  and virtuallyRole != ''">and virtually_role = #{virtuallyRole}</if>
            <if test="realRole != null  and realRole != ''">and real_role = #{realRole}</if>
            <if test="executeUserNo != null  and executeUserNo != ''">and execute_user_no = #{executeUserNo}</if>
        </where>
    </select>

    <select id="selectBpmNodeHandleUserById" parameterType="Long" resultMap="BpmNodeHandleUserResult">
        <include refid="selectBpmNodeHandleUserVo"/>
        where id = #{id}
    </select>

    <insert id="insertBpmNodeHandleUser" parameterType="java.util.List">
        insert into bpm_node_handle_user(virtually_role,real_role,execute_user_no)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.virtuallyRole},#{item.realRole},#{item.executeUserNo})
        </foreach>
    </insert>
    <!--<foreach collection="list" item="item" index="index" separator=";">-->
    <update id="updateBpmNodeHandleUser" parameterType="com.zkqy.system.entity.BpmNodeHandleUser">
        update bpm_node_handle_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="virtuallyRole != null">virtually_role = #{virtuallyRole},</if>
            <if test="realRole != null">real_role = #{realRole},</if>
            <if test="executeUserNo != null">execute_user_no = #{executeUserNo},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBpmNodeHandleUserById" parameterType="Long">
        delete from bpm_node_handle_user
        where id = #{id}
    </delete>

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

    <select id="selectBpmNodeHandleUserByVirtuallyRole" parameterType="String" resultMap="BpmNodeHandleUserResult">
        <include refid="selectBpmNodeHandleUserVo"/>
        where virtually_role = #{virtuallyKole}
    </select>

</mapper>