<?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.approvalFlow.mapper.AuditItemsUsersMapper">

    <resultMap type="AuditItemsUsers" id="AuditItemsUsersResult">
        <result property="id" column="id"/>
        <result property="pid" column="pid"/>
        <result property="billNo" column="bill_no"/>
        <result property="actId" column="act_id"/>
        <result property="userId" column="user_id"/>
        <result property="auditStatus" column="audit_status"/>
    </resultMap>

    <sql id="selectAuditItemsUsersVo">
        select id, pid, bill_no, act_id, user_id, audit_status from audit_items_users
    </sql>

    <select id="selectAuditItemsUsersList" parameterType="AuditItemsUsers" resultMap="AuditItemsUsersResult">
        <include refid="selectAuditItemsUsersVo"/>
        <where>
            <if test="pid != null ">and pid = #{pid}</if>
            <if test="billNo != null  and billNo != ''">and bill_no = #{billNo}</if>
            <if test="actId != null ">and act_id = #{actId}</if>
            <if test="userId != null ">and user_id = #{userId}</if>
            <if test="auditStatus != null  and auditStatus != ''">and audit_status = #{auditStatus}</if>
        </where>
    </select>

    <select id="selectAuditItemsUsersById" parameterType="Long" resultMap="AuditItemsUsersResult">
        <include refid="selectAuditItemsUsersVo"/>
        where id = #{id}
    </select>

    <insert id="insertAuditItemsUsers" parameterType="AuditItemsUsers" useGeneratedKeys="true" keyProperty="id">
        insert into audit_items_users
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pid != null">pid,</if>
            <if test="billNo != null">bill_no,</if>
            <if test="actId != null">act_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="auditStatus != null">audit_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pid != null">#{pid},</if>
            <if test="billNo != null">#{billNo},</if>
            <if test="actId != null">#{actId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="auditStatus != null">#{auditStatus},</if>
        </trim>
    </insert>

    <update id="updateAuditItemsUsers" parameterType="AuditItemsUsers">
        update audit_items_users
        <trim prefix="SET" suffixOverrides=",">
            <if test="pid != null">pid = #{pid},</if>
            <if test="billNo != null">bill_no = #{billNo},</if>
            <if test="actId != null">act_id = #{actId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="auditStatus != null">audit_status = #{auditStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAuditItemsUsersById" parameterType="Long">
        delete from audit_items_users where id = #{id}
    </delete>

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

</mapper>