<?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.invest.mapper.TProjectCompanyMapper">
    
    <resultMap type="TProjectCompany" id="TProjectCompanyResult">
        <result property="id"    column="id"    />
        <result property="companyName"    column="company_name"    />
        <result property="projectPoolId"    column="project_pool_id"    />
        <result property="companyCode"    column="company_code"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="registeredCapital"    column="registered_capital"    />
        <result property="registeredAddress"    column="registered_address"    />
        <result property="paidCapital"    column="paid_capital"    />
        <result property="businessAddress"    column="business_address"    />
        <result property="actualBod"    column="actual_bod"    />
        <result property="phone"    column="phone"    />
        <result property="filingTime"    column="filing_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTProjectCompanyVo">
        select id, company_name, project_pool_id, company_code, start_time, end_time, registered_capital, registered_address, paid_capital, business_address, actual_bod, phone, type,filing_time, del_flag, create_by, create_time, update_by, update_time from t_project_company
    </sql>

    <select id="selectTProjectCompanyList" parameterType="TProjectCompany" resultMap="TProjectCompanyResult">
        <include refid="selectTProjectCompanyVo"/>
        <where>
            del_flag = 0
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="actualBod != null  and actualBod != ''"> and actual_bod = #{actualBod}</if>
        </where>
    </select>
    
    <select id="selectTProjectCompanyById" parameterType="String" resultMap="TProjectCompanyResult">
        <include refid="selectTProjectCompanyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectCompany" parameterType="TProjectCompany">
        insert into t_project_company
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="companyName != null">company_name,</if>
            <if test="projectPoolId != null">project_pool_id,</if>
            <if test="companyCode != null">company_code,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="registeredCapital != null">registered_capital,</if>
            <if test="registeredAddress != null">registered_address,</if>
            <if test="paidCapital != null">paid_capital,</if>
            <if test="businessAddress != null">business_address,</if>
            <if test="actualBod != null">actual_bod,</if>
            <if test="phone != null">phone,</if>
            <if test="type != null">type,</if>
            <if test="filingTime != null">filing_time,</if>
            <if test="delFlag != null">del_flag,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="companyName != null">#{companyName},</if>
            <if test="projectPoolId != null">#{projectPoolId},</if>
            <if test="companyCode != null">#{companyCode},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="registeredCapital != null">#{registeredCapital},</if>
            <if test="registeredAddress != null">#{registeredAddress},</if>
            <if test="paidCapital != null">#{paidCapital},</if>
            <if test="businessAddress != null">#{businessAddress},</if>
            <if test="actualBod != null">#{actualBod},</if>
            <if test="phone != null">#{phone},</if>
            <if test="type != null">#{type},</if>
            <if test="filingTime != null">#{filingTime},</if>
            <if test="delFlag != null">#{delFlag},</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>
         </trim>
    </insert>

    <update id="updateTProjectCompany" parameterType="TProjectCompany">
        update t_project_company
        <trim prefix="SET" suffixOverrides=",">
            <if test="companyName != null">company_name = #{companyName},</if>
            <if test="projectPoolId != null">project_pool_id = #{projectPoolId},</if>
            <if test="companyCode != null">company_code = #{companyCode},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="registeredCapital != null">registered_capital = #{registeredCapital},</if>
            <if test="registeredAddress != null">registered_address = #{registeredAddress},</if>
            <if test="paidCapital != null">paid_capital = #{paidCapital},</if>
            <if test="businessAddress != null">business_address = #{businessAddress},</if>
            <if test="actualBod != null">actual_bod = #{actualBod},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="type != null">type = #{type},</if>
            <if test="filingTime != null"> filing_time = #{filingTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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>
        </trim>
        where project_pool_id = #{projectPoolId}
    </update>

    <delete id="deleteTProjectCompanyById" parameterType="String">
        delete from t_project_company where id = #{id}
    </delete>

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

    <update id="updateTProjectCompanyByIds" parameterType="String">
        update t_project_company
        set del_flag = 1
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <select id="selectTProjectCompanyByProjectPoolId" parameterType="String" resultMap="TProjectCompanyResult">
        <include refid="selectTProjectCompanyVo"/>
        where project_pool_id = #{projectPoolId}
    </select>


</mapper>