<?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.system.mapper.project.BmConstructionPayInfoMapper">
    
    <resultMap type="BmConstructionPayInfo" id="BmConstructionPayInfoResult">
        <result property="id"    column="id"    />
        <result property="bmProjectId"    column="bm_project_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="statisticsDate"    column="statistics_date"    />
        <result property="statisticsPhoto"    column="statistics_photo"    />
    </resultMap>

    <sql id="selectBmConstructionPayInfoVo">
        select id, bm_project_id, create_by, create_time, update_by, update_time, is_del, statistics_date, statistics_photo from bm_construction_payinfo
    </sql>

    <select id="selectBmConstructionPayInfoList" parameterType="BmConstructionPayInfo" resultMap="BmConstructionPayInfoResult">
        <include refid="selectBmConstructionPayInfoVo"/>
        <where>
            is_del = '0'
            <if test="bmProjectId != null "> and bm_project_id = #{bmProjectId}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="statisticsDate != null "> and statistics_date = #{statisticsDate}</if>
            <if test="statisticsPhoto != null  and statisticsPhoto != ''"> and statistics_photo = #{statisticsPhoto}</if>
        </where>
        order by create_time DESC
    </select>
    
    <select id="selectBmConstructionPayInfoById" parameterType="Long" resultMap="BmConstructionPayInfoResult">
        <include refid="selectBmConstructionPayInfoVo"/>
        where bm_project_id = #{id} and is_del = '0' limit 1
    </select>
        
    <insert id="insertBmConstructionPayInfo" parameterType="BmConstructionPayInfo" useGeneratedKeys="true" keyProperty="id">
        insert into bm_construction_payinfo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bmProjectId != null">bm_project_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="statisticsDate != null">statistics_date,</if>
            <if test="statisticsPhoto != null">statistics_photo,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bmProjectId != null">#{bmProjectId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="statisticsDate != null">#{statisticsDate},</if>
            <if test="statisticsPhoto != null">#{statisticsPhoto},</if>
         </trim>
    </insert>

    <update id="updateBmConstructionPayInfo" parameterType="BmConstructionPayInfo">
        update bm_construction_payinfo
        <trim prefix="SET" suffixOverrides=",">
            <if test="bmProjectId != null">bm_project_id = #{bmProjectId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="statisticsDate != null">statistics_date = #{statisticsDate},</if>
            <if test="statisticsPhoto != null">statistics_photo = #{statisticsPhoto},</if>
        </trim>
        where id = #{id}
    </update>

<!--    <delete id="deleteBmConstructionPayInfoById" parameterType="Long">
        delete from bm_construction_payinfo where id = #{id}
    </delete>-->

    <update id="deleteBmConstructionPayInfoById" parameterType="Long">
        update  bm_construction_payinfo set is_del = '1' where id = #{id}
    </update>

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

    <update id="deleteBmConstructionPayInfoByIds" parameterType="String">
        update  bm_construction_payinfo set is_del = '1'
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
</mapper>