<?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.TProjectContactsMapper">
    
    <resultMap type="TProjectContacts" id="TProjectContactsResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="position"    column="position"    />
        <result property="contact"    column="contact"    />
        <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="selectTProjectContactsVo">
        select id, name, position, contact, remark, del_flag, create_by, create_time, update_by, update_time from t_project_contacts
    </sql>

    <select id="selectTProjectContactsList" parameterType="TProjectContacts" resultMap="TProjectContactsResult">
        <include refid="selectTProjectContactsVo"/>
        <where>
            del_flag = 0
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="position != null  and position != ''"> and position like concat('%', #{position}, '%')</if>
            <if test="contact != null  and contact != ''"> and contact like concat('%', #{contact}, '%')</if>
        </where>
    </select>
    
    <select id="selectTProjectContactsById" parameterType="String" resultMap="TProjectContactsResult">
        <include refid="selectTProjectContactsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTProjectContacts" parameterType="TProjectContacts">
        insert into t_project_contacts
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="position != null">position,</if>
            <if test="contact != null">contact,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="position != null">#{position},</if>
            <if test="contact != null">#{contact},</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>
         </trim>
    </insert>

    <update id="updateTProjectContacts" parameterType="TProjectContacts">
        update t_project_contacts
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="position != null">position = #{position},</if>
            <if test="contact != null">contact = #{contact},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTProjectContactsById" parameterType="String">
        delete from t_project_contacts where id = #{id}
    </delete>

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

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


</mapper>