<?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.BmProjectShareholderMapper">
    
    <resultMap type="BmProjectShareholder" id="BmProjectShareholderResult">
        <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="companyName"    column="company_name"    />
        <result property="equityRatio"    column="equity_ratio"    />
        <result property="companyCode"    column="company_code"    />
        <result property="businessPhoto"    column="business_photo"    />
    </resultMap>

    <sql id="selectBmProjectShareholderVo">
        select id, bm_project_id, create_by, create_time, update_by, update_time, is_del, company_name, equity_ratio, company_code, business_photo from bm_project_shareholder
    </sql>

    <select id="selectBmProjectShareholderList" parameterType="BmProjectShareholder" resultMap="BmProjectShareholderResult">
        <include refid="selectBmProjectShareholderVo"/>
        <where>  
            <if test="bmProjectId != null "> and bm_project_id = #{bmProjectId}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="equityRatio != null  and equityRatio != ''"> and equity_ratio = #{equityRatio}</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="businessPhoto != null  and businessPhoto != ''"> and business_photo = #{businessPhoto}</if>
        </where>
    </select>
    
    <select id="selectBmProjectShareholderById" parameterType="Long" resultMap="BmProjectShareholderResult">
        <include refid="selectBmProjectShareholderVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBmProjectShareholder" parameterType="BmProjectShareholder" useGeneratedKeys="true" keyProperty="id">
        insert into bm_project_shareholder
        <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="companyName != null">company_name,</if>
            <if test="equityRatio != null">equity_ratio,</if>
            <if test="companyCode != null">company_code,</if>
            <if test="businessPhoto != null">business_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="companyName != null">#{companyName},</if>
            <if test="equityRatio != null">#{equityRatio},</if>
            <if test="companyCode != null">#{companyCode},</if>
            <if test="businessPhoto != null">#{businessPhoto},</if>
         </trim>
    </insert>

    <update id="updateBmProjectShareholder" parameterType="BmProjectShareholder">
        update bm_project_shareholder
        <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="companyName != null">company_name = #{companyName},</if>
            <if test="equityRatio != null">equity_ratio = #{equityRatio},</if>
            <if test="companyCode != null">company_code = #{companyCode},</if>
            <if test="businessPhoto != null">business_photo = #{businessPhoto},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBmProjectShareholderById" parameterType="Long">
        delete from bm_project_shareholder where id = #{id}
    </delete>

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