<?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.AuditItemsDoMapper">

    <resultMap type="AuditItemsDo" id="AuditItemsResult">
        <result property="fId"    column="f_id"    />
        <result property="fPid"    column="f_pid"    />
        <result property="actId"    column="act_id"    />
        <result property="billId"    column="bill_id"    />
        <result property="fBsno"    column="f_bsno"    />
    </resultMap>

    <insert id="insert" parameterType="AuditItemsDo" useGeneratedKeys="true" keyProperty="fId">
        insert into audit_items_do
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fPid != null and fPid != ''">f_pid,</if>
            <if test="actId != null and fPid != ''">act_id,</if>
            <if test="billId != null and fPid != ''">bill_id,</if>
            <if test="fBsno != null">f_bsno,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fPid != null and fPid != ''">#{fPid},</if>
            <if test="actId != null and fPid != ''">#{actId},</if>
            <if test="billId != null and fPid != ''">#{billId},</if>
            <if test="fBsno != null">#{fBsno},</if>
        </trim>
    </insert>

    <update id="updateById" parameterType="com.ruoyi.approvalFlow.domain.AuditItemsDo">
        UPDATE
            audit_items_do
        <trim prefix="SET" suffixOverrides=",">
            <if test="fPid != null and fPid != ''">f_pid = #{fPid},</if>
            <if test="actId != null and fPid != ''">act_id = #{actId},</if>
            <if test="billId != null and fPid != ''">bill_id = #{billId},</if>
            <if test="fBsno != null">f_bsno = #{fBsno},</if>
        </trim>
        WHERE
            f_id = #{fId}
    </update>

    <delete id="deleteById" parameterType="com.ruoyi.approvalFlow.domain.AuditItemsDo">
        delete from audit_items_do where f_id = #{id}
    </delete>

    <delete id="deleteByFPid" parameterType="com.ruoyi.approvalFlow.domain.AuditItemsDo">
        delete from audit_items_do where f_pid = #{fPid}
    </delete>

    <select id="selectById" parameterType="AuditItemsDo" resultMap="AuditItemsResult">
        SELECT
            f_id,
            f_pid,
            act_id,
            bill_id,
            f_bsno
        FROM
            audit_items_do
        WHERE f_id = #{fId}
    </select>

    <select id="selectByFPid" parameterType="com.ruoyi.approvalFlow.domain.AuditItemsDo" resultType="Map">
        SELECT
        f_id as fId,
        f_pid as fPid,
        act_id as actId,
        bill_id as billId,
        f_bsno as fBsno
        FROM
        audit_items_do
        WHERE f_pid = #{fPid}
    </select>

    <select id="selectByActIdAndBillId" parameterType="com.ruoyi.approvalFlow.domain.AuditItemsDo" resultType="Map">
        SELECT
            f_id as fId,
            f_pid as fPid,
            act_id as actId,
            bill_id as billId,
            f_bsno as fBsno
        FROM
            audit_items_do
        WHERE act_id = #{actId} AND bill_id = #{billId}
    </select>
</mapper>
