<?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.TProjectInvestigatePersonMapper">
    
    <resultMap type="TProjectInvestigatePerson" id="TProjectInvestigatePersonResult">
        <result property="id"    column="id"    />
        <result property="projectInvestigateId"    column="project_investigate_id"    />
        <result property="investigatePerson"    column="investigate_person"    />
        <result property="investigatePersonId"    column="investigate_person_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <result property="remark"    column="remark"    />
        <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="selectTProjectInvestigatePersonVo">
        select id, project_investigate_id, investigate_person, investigate_person_id, dept_id, dept_name, remark, create_by, create_time, update_by, update_time from t_project_investigate_person
    </sql>

    <select id="selectTProjectInvestigatePersonList" parameterType="TProjectInvestigatePerson" resultMap="TProjectInvestigatePersonResult">
        <include refid="selectTProjectInvestigatePersonVo"/>
        <where>  
            <if test="projectInvestigateId != null  and projectInvestigateId != ''"> and project_investigate_id = #{projectInvestigateId}</if>
            <if test="investigatePerson != null  and investigatePerson != ''"> and investigate_person = #{investigatePerson}</if>
            <if test="investigatePersonId != null  and investigatePersonId != ''"> and investigate_person_id = #{investigatePersonId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
        </where>
    </select>
    
    <select id="selectTProjectInvestigatePersonById" parameterType="String" resultMap="TProjectInvestigatePersonResult">
        <include refid="selectTProjectInvestigatePersonVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectInvestigatePerson" parameterType="TProjectInvestigatePerson">
        insert into t_project_investigate_person
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="projectInvestigateId != null">project_investigate_id,</if>
            <if test="investigatePerson != null">investigate_person,</if>
            <if test="investigatePersonId != null">investigate_person_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</if>
            <if test="remark != null">remark,</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="projectInvestigateId != null">#{projectInvestigateId},</if>
            <if test="investigatePerson != null">#{investigatePerson},</if>
            <if test="investigatePersonId != null">#{investigatePersonId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</if>
            <if test="remark != null">#{remark},</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="updateTProjectInvestigatePerson" parameterType="TProjectInvestigatePerson">
        update t_project_investigate_person
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectInvestigateId != null">project_investigate_id = #{projectInvestigateId},</if>
            <if test="investigatePerson != null">investigate_person = #{investigatePerson},</if>
            <if test="investigatePersonId != null">investigate_person_id = #{investigatePersonId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
            <if test="remark != null">remark = #{remark},</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 id = #{id}
    </update>

    <delete id="deleteTProjectInvestigatePersonById" parameterType="String">
        delete from t_project_investigate_person where id = #{id}
    </delete>

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

    <select id="selectByProjectInvestigateId" parameterType="TProjectInvestigatePerson" resultMap="TProjectInvestigatePersonResult">
        <include refid="selectTProjectInvestigatePersonVo"/>
        where project_investigate_id = #{projectInvestigateId} and investigate_person_id = #{userId}
    </select>

    <select id="selectProjectInvestigateIdList" parameterType="TProjectInvestigatePerson" resultMap="TProjectInvestigatePersonResult">
        <include refid="selectTProjectInvestigatePersonVo"/>
        where project_investigate_id = #{projectInvestigateId}
    </select>

</mapper>