<?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.TProjectCirculationMapper">
    
    <resultMap type="TProjectCirculation" id="TProjectCirculationResult">
        <result property="id"    column="id"    />
        <result property="stageName"    column="stage_name"    />
        <result property="projectPoolId"    column="project_pool_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTProjectCirculationVo">
        select id, stage_name, project_pool_id, create_by, create_time from t_project_circulation
    </sql>

    <select id="selectTProjectCirculationList" parameterType="TProjectCirculation" resultMap="TProjectCirculationResult">
        <include refid="selectTProjectCirculationVo"/>
        <where>  
            <if test="stageName != null  and stageName != ''"> and stage_name like concat('%', #{stageName}, '%')</if>
            <if test="projectPoolId != null  and projectPoolId != ''"> and project_pool_id = #{projectPoolId}</if>
        </where>
    </select>
    
    <select id="selectTProjectCirculationById" parameterType="String" resultMap="TProjectCirculationResult">
        <include refid="selectTProjectCirculationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectCirculation" parameterType="TProjectCirculation">
        insert into t_project_circulation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="stageName != null">stage_name,</if>
            <if test="projectPoolId != null">project_pool_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="stageName != null">#{stageName},</if>
            <if test="projectPoolId != null">#{projectPoolId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTProjectCirculation" parameterType="TProjectCirculation">
        update t_project_circulation
        <trim prefix="SET" suffixOverrides=",">
            <if test="stageName != null">stage_name = #{stageName},</if>
            <if test="projectPoolId != null">project_pool_id = #{projectPoolId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTProjectCirculationById" parameterType="String">
        delete from t_project_circulation where id = #{id}
    </delete>

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

    <select id="listProjectPoolId" parameterType="String" resultMap="TProjectCirculationResult">
        <include refid="selectTProjectCirculationVo"/>
        where project_pool_id = #{projectPoolId}
        order by create_time
    </select>

</mapper>