<?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.project.business.mapper.TcProjectEquipmentHistoryMapper">
    
    <resultMap type="TcProjectEquipmentHistory" id="TcProjectEquipmentHistoryResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="standard"    column="standard"    />
        <result property="equipmentQuantity"    column="equipment_quantity"    />
        <result property="elevatorModel"    column="elevator_model"    />
        <result property="equipmentType"    column="equipment_type"    />
        <result property="amount"    column="amount"    />
        <result property="totalPrice"    column="total_price"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTcProjectEquipmentHistoryVo">
        select id, project_id, standard, equipment_quantity, elevator_model, equipment_type, amount, total_price, del_flag, create_time, create_by, update_time, update_by, remark from tc_project_equipment_history
    </sql>

    <select id="selectTcProjectEquipmentHistoryList" parameterType="TcProjectEquipmentHistory" resultMap="TcProjectEquipmentHistoryResult">
        <include refid="selectTcProjectEquipmentHistoryVo"/>
        <where>  
            <if test="projectId != null "> and project_id = #{projectId}</if>
            <if test="standard != null  and standard != ''"> and standard = #{standard}</if>
            <if test="equipmentQuantity != null "> and equipment_quantity = #{equipmentQuantity}</if>
            <if test="elevatorModel != null  and elevatorModel != ''"> and elevator_model = #{elevatorModel}</if>
            <if test="equipmentType != null  and equipmentType != ''"> and equipment_type = #{equipmentType}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="totalPrice != null "> and total_price = #{totalPrice}</if>
        </where>
    </select>
    
    <select id="selectTcProjectEquipmentHistoryById" parameterType="Long" resultMap="TcProjectEquipmentHistoryResult">
        <include refid="selectTcProjectEquipmentHistoryVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcProjectEquipmentHistory" parameterType="TcProjectEquipmentHistory" useGeneratedKeys="true" keyProperty="id">
        insert into tc_project_equipment_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="standard != null">standard,</if>
            <if test="equipmentQuantity != null">equipment_quantity,</if>
            <if test="elevatorModel != null">elevator_model,</if>
            <if test="equipmentType != null">equipment_type,</if>
            <if test="amount != null">amount,</if>
            <if test="totalPrice != null">total_price,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="standard != null">#{standard},</if>
            <if test="equipmentQuantity != null">#{equipmentQuantity},</if>
            <if test="elevatorModel != null">#{elevatorModel},</if>
            <if test="equipmentType != null">#{equipmentType},</if>
            <if test="amount != null">#{amount},</if>
            <if test="totalPrice != null">#{totalPrice},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTcProjectEquipmentHistory" parameterType="TcProjectEquipmentHistory">
        update tc_project_equipment_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="standard != null">standard = #{standard},</if>
            <if test="equipmentQuantity != null">equipment_quantity = #{equipmentQuantity},</if>
            <if test="elevatorModel != null">elevator_model = #{elevatorModel},</if>
            <if test="equipmentType != null">equipment_type = #{equipmentType},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="totalPrice != null">total_price = #{totalPrice},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcProjectEquipmentHistoryById" parameterType="Long">
        delete from tc_project_equipment_history where id = #{id}
    </delete>

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