<?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.TProjectApprovalMapper">
    
    <resultMap type="TProjectApproval" id="TProjectApprovalResult">
        <result property="id"    column="id"    />
        <result property="procInstId" column="proc_inst_id"/>
        <result property="projectPoolId"    column="project_pool_id"    />
        <result property="projectOverview"    column="project_overview"    />
        <result property="projectSparkle"    column="project_sparkle"    />
        <result property="participantsId"    column="participants_id"    />
        <result property="participants"    column="participants"    />
        <result property="remark"    column="remark"    />
        <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="selectTProjectApprovalVo">
        select id, proc_inst_id,project_pool_id, project_overview, project_sparkle, participants_id, participants, remark, del_flag, create_by, create_time, update_by, update_time from t_project_approval
    </sql>

    <select id="selectTProjectApprovalList" parameterType="TProjectApproval" resultMap="TProjectApprovalResult">
        <include refid="selectTProjectApprovalVo"/>
        <where>  
            <if test="projectPoolId != null  and projectPoolId != ''"> and project_pool_id = #{projectPoolId}</if>
            <if test="projectOverview != null  and projectOverview != ''"> and project_overview = #{projectOverview}</if>
            <if test="projectSparkle != null  and projectSparkle != ''"> and project_sparkle = #{projectSparkle}</if>
        </where>
    </select>
    
    <select id="selectTProjectApprovalById" parameterType="String" resultMap="TProjectApprovalResult">
        <include refid="selectTProjectApprovalVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectApproval" parameterType="TProjectApproval">
        insert into t_project_approval
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="procInstId != null">proc_inst_id,</if>
            <if test="projectPoolId != null">project_pool_id,</if>
            <if test="projectOverview != null">project_overview,</if>
            <if test="projectSparkle != null">project_sparkle,</if>
            <if test="participantsId != null">participants_id,</if>
            <if test="participants != null">participants,</if>
            <if test="remark != null">remark,</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>
            <if test="needMeeting != null">need_meeting,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="procInstId != null">#{procInstId},</if>
            <if test="projectPoolId != null">#{projectPoolId},</if>
            <if test="projectOverview != null">#{projectOverview},</if>
            <if test="projectSparkle != null">#{projectSparkle},</if>
            <if test="participantsId != null">#{participantsId},</if>
            <if test="participants != null">#{participants},</if>
            <if test="remark != null">#{remark},</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>
            <if test="needMeeting != null">#{needMeeting},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateTProjectApproval" parameterType="TProjectApproval">
        update t_project_approval
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectPoolId != null">project_pool_id = #{projectPoolId},</if>
            <if test="projectOverview != null">project_overview = #{projectOverview},</if>
            <if test="projectSparkle != null">project_sparkle = #{projectSparkle},</if>
            <if test="participantsId != null">participants_id = #{participantsId},</if>
            <if test="participants != null">participants = #{participants},</if>
            <if test="remark != null">remark = #{remark},</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>
            <if test="needMeeting != null">need_meeting = #{needMeeting},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTProjectApprovalById" parameterType="String">
        delete from t_project_approval where id = #{id}
    </delete>

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

    <select id="listProjectPoolIdNew" parameterType="String" resultMap="TProjectApprovalResult">
        <include refid="selectTProjectApprovalVo"/>
        where project_pool_id = #{projectPoolId} and del_flag = 0
        ORDER BY create_time DESC LIMIT 1
    </select>


</mapper>