<?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.orderPlan.mapper.ProjectBillsHistoryMapper">

    <resultMap type="ProjectBillsHistory" id="ProjectBillsHistoryResult">
        <result property="id" column="id"/>
        <result property="actId" column="act_id"/>
        <result property="projectId" column="project_id"/>
        <result property="serialNumber" column="serial_number"/>
        <result property="modifyReason" column="modify_reason"/>
        <result property="historyUser" column="history_user"/>
        <result property="historyDate" column="history_date"/>
        <result property="historyBody1" column="history_body1"/>
        <result property="historyBody2" column="history_body2"/>
        <result property="historyBody3" column="history_body3"/>
        <result property="historyBody4" column="history_body4"/>
        <result property="historyBody5" column="history_body5"/>
    </resultMap>

    <sql id="selectProjectBillsHistoryVo">
        select id, act_id, project_id, serial_number, modify_reason, history_user, history_date, history_body1, history_body2, history_body3, history_body4, history_body5 from project_bills_history
    </sql>

    <select id="selectProjectBillsHistoryList" parameterType="ProjectBillsHistory"
            resultMap="ProjectBillsHistoryResult">
        <include refid="selectProjectBillsHistoryVo"/>
        <where>
            <if test="actId != null ">and act_id = #{actId}</if>
            <if test="projectId != null ">and project_id = #{projectId}</if>
            <if test="serialNumber != null  and serialNumber != ''">and serial_number = #{serialNumber}</if>
            <if test="modifyReason != null  and modifyReason != ''">and modify_reason = #{modifyReason}</if>
            <if test="historyUser != null ">and history_user = #{historyUser}</if>
            <if test="historyDate != null ">and history_date = #{historyDate}</if>
            <if test="historyBody1 != null  and historyBody1 != ''">and history_body1 = #{historyBody1}</if>
            <if test="historyBody2 != null  and historyBody2 != ''">and history_body2 = #{historyBody2}</if>
            <if test="historyBody3 != null  and historyBody3 != ''">and history_body3 = #{historyBody3}</if>
            <if test="historyBody4 != null  and historyBody4 != ''">and history_body4 = #{historyBody4}</if>
            <if test="historyBody5 != null  and historyBody5 != ''">and history_body5 = #{historyBody5}</if>
        </where>
    </select>

    <select id="selectProjectBillsHistoryById" parameterType="Long" resultMap="ProjectBillsHistoryResult">
        <include refid="selectProjectBillsHistoryVo"/>
        where id = #{id}
    </select>

    <insert id="insertProjectBillsHistory" parameterType="ProjectBillsHistory" useGeneratedKeys="true" keyProperty="id">
        insert into project_bills_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="actId != null">act_id,</if>
            <if test="projectId != null">project_id,</if>
            <if test="serialNumber != null">serial_number,</if>
            <if test="modifyReason != null">modify_reason,</if>
            <if test="historyUser != null">history_user,</if>
            <if test="historyDate != null">history_date,</if>
            <if test="historyBody1 != null">history_body1,</if>
            <if test="historyBody2 != null">history_body2,</if>
            <if test="historyBody3 != null">history_body3,</if>
            <if test="historyBody4 != null">history_body4,</if>
            <if test="historyBody5 != null">history_body5,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="actId != null">#{actId},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="serialNumber != null">#{serialNumber},</if>
            <if test="modifyReason != null">#{modifyReason},</if>
            <if test="historyUser != null">#{historyUser},</if>
            <if test="historyDate != null">#{historyDate},</if>
            <if test="historyBody1 != null">#{historyBody1},</if>
            <if test="historyBody2 != null">#{historyBody2},</if>
            <if test="historyBody3 != null">#{historyBody3},</if>
            <if test="historyBody4 != null">#{historyBody4},</if>
            <if test="historyBody5 != null">#{historyBody5},</if>
        </trim>
    </insert>

    <update id="updateProjectBillsHistory" parameterType="ProjectBillsHistory">
        update project_bills_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="actId != null">act_id = #{actId},</if>
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="serialNumber != null">serial_number = #{serialNumber},</if>
            <if test="modifyReason != null">modify_reason = #{modifyReason},</if>
            <if test="historyUser != null">history_user = #{historyUser},</if>
            <if test="historyDate != null">history_date = #{historyDate},</if>
            <if test="historyBody1 != null">history_body1 = #{historyBody1},</if>
            <if test="historyBody2 != null">history_body2 = #{historyBody2},</if>
            <if test="historyBody3 != null">history_body3 = #{historyBody3},</if>
            <if test="historyBody4 != null">history_body4 = #{historyBody4},</if>
            <if test="historyBody5 != null">history_body5 = #{historyBody5},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProjectBillsHistoryById" parameterType="Long">
        delete from project_bills_history where id = #{id}
    </delete>

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

</mapper>