<?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.BmProjectReportMapper">
    
    <resultMap type="BmProjectReport" id="BmProjectReportResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="investmentQuota"    column="investment_quota"    />
        <result property="contactsName"    column="contacts_name"    />
        <result property="contactsPhone"    column="contacts_phone"    />
        <result property="projectIntroduction"    column="project_introduction"    />
        <result property="reportStatus"    column="report_status"    />
        <result property="url"    column="url"    />
        <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="sysDeptId"    column="sys_dept_id"    />
        <result property="ivestor"    column="ivestor"    />
        <result property="recommendCompany"    column="recommend_company"    />
        <result property="recommendPhone"    column="recommend_phone"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBmProjectReportVo">
        select id, project_name, investment_quota, contacts_name, contacts_phone, project_introduction, report_status, url, bm_project_id, create_by, create_time, update_by, update_time, is_del, sys_dept_id, ivestor, recommend_company,recommend_phone, remark from bm_project_report
    </sql>

    <select id="selectBmProjectReportList" parameterType="BmProjectReport" resultMap="BmProjectReportResult">
        <include refid="selectBmProjectReportVo"/>
        <where>
            is_del = '0'
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="investmentQuota != null  and investmentQuota != ''"> and investment_quota = #{investmentQuota}</if>
            <if test="contactsName != null  and contactsName != ''"> and contacts_name like concat('%', #{contactsName}, '%')</if>
            <if test="contactsPhone != null  and contactsPhone != ''"> and contacts_phone = #{contactsPhone}</if>
            <if test="projectIntroduction != null  and projectIntroduction != ''"> and project_introduction = #{projectIntroduction}</if>
            <if test="reportStatus != null  and reportStatus != ''"> and report_status = #{reportStatus}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="bmProjectId != null "> and bm_project_id = #{bmProjectId}</if>
            <if test="sysDeptId != null "> and sys_dept_id  like concat('%', #{sysDeptId}, '%')</if>
            <if test="ivestor != null and ivestor != ''"> and ivestor = #{ivestor}</if>
            <if test="recommendCompany != null and recommendCompany != '' "> and recommend_company = #{recommendCompany}</if>
            <if test="recommendPhone != null and recommendPhone != ''"> and recommend_phone = #{recommendPhone}</if>
        </where>
        order by  create_time DESC
    </select>
    
    <select id="selectBmProjectReportById" parameterType="Long" resultMap="BmProjectReportResult">
        <include refid="selectBmProjectReportVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBmProjectReport" parameterType="BmProjectReport" useGeneratedKeys="true" keyProperty="id">
        insert into bm_project_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null">project_name,</if>
            <if test="investmentQuota != null">investment_quota,</if>
            <if test="contactsName != null">contacts_name,</if>
            <if test="contactsPhone != null">contacts_phone,</if>
            <if test="projectIntroduction != null">project_introduction,</if>
            <if test="reportStatus != null">report_status,</if>
            <if test="url != null">url,</if>
            <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="sysDeptId != null">sys_dept_id,</if>
            <if test="ivestor != null">ivestor,</if>
            <if test="recommendCompany != null">recommend_company,</if>
            <if test="recommendPhone != null">recommend_phone,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectName != null">#{projectName},</if>
            <if test="investmentQuota != null">#{investmentQuota},</if>
            <if test="contactsName != null">#{contactsName},</if>
            <if test="contactsPhone != null">#{contactsPhone},</if>
            <if test="projectIntroduction != null">#{projectIntroduction},</if>
            <if test="reportStatus != null">#{reportStatus},</if>
            <if test="url != null">#{url},</if>
            <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="sysDeptId != null">#{sysDeptId},</if>
            <if test="ivestor != null">#{ivestor},</if>
            <if test="recommendCompany != null">#{recommendCompany},</if>
            <if test="recommendPhone != null">#{recommendPhone},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBmProjectReport" parameterType="BmProjectReport">
        update bm_project_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="investmentQuota != null">investment_quota = #{investmentQuota},</if>
            <if test="contactsName != null">contacts_name = #{contactsName},</if>
            <if test="contactsPhone != null">contacts_phone = #{contactsPhone},</if>
            <if test="projectIntroduction != null">project_introduction = #{projectIntroduction},</if>
            <if test="reportStatus != null">report_status = #{reportStatus},</if>
            <if test="url != null">url = #{url},</if>
            <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="sysDeptId != null">sys_dept_id = #{sysDeptId},</if>
            <if test="ivestor != null">ivestor = #{ivestor},</if>
            <if test="recommendCompany != null">recommend_company = #{recommendCompany},</if>
            <if test="recommendPhone != null">recommend_phone = #{recommendPhone},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBmProjectReportById" parameterType="Long">
        delete from bm_project_report where id = #{id}
    </delete>

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