<?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.system.mapper.TEmergentPeopleMapper">
    
    <resultMap type="TEmergentPeople" id="TEmergentPeopleResult">
        <result property="id"    column="id"    />
        <result property="profileId"    column="profile_id"    />
        <result property="name"    column="name"    />
        <result property="telno"    column="telno"    />
        <result property="relation"    column="relation"    />
        <result property="isConn"    column="is_conn"    />
    </resultMap>

    <sql id="selectTEmergentPeopleVo">
        select id, profile_id, name, telno, relation, is_conn from t_emergent_people
    </sql>

    <select id="selectTEmergentPeopleList" parameterType="TEmergentPeople" resultMap="TEmergentPeopleResult">
        <include refid="selectTEmergentPeopleVo"/>
        <where>  
            <if test="profileId != null "> and profile_id = #{profileId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="telno != null  and telno != ''"> and telno = #{telno}</if>
            <if test="relation != null "> and relation = #{relation}</if>
            <if test="isConn != null "> and is_conn = #{isConn}</if>
        </where>
    </select>
    
    <select id="selectTEmergentPeopleById" parameterType="Integer" resultMap="TEmergentPeopleResult">
        <include refid="selectTEmergentPeopleVo"/>
        where id = #{id}
    </select>
    <select id="selectTEmergentPeopleByProfileId" parameterType="Integer" resultMap="TEmergentPeopleResult">
        <include refid="selectTEmergentPeopleVo"/>
        where profile_id = #{profileId}
    </select>

    <insert id="insertTEmergentPeople" parameterType="TEmergentPeople" useGeneratedKeys="true" keyProperty="id">
        insert into t_emergent_people
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="profileId != null">profile_id,</if>
            <if test="name != null">name,</if>
            <if test="telno != null">telno,</if>
            <if test="relation != null">relation,</if>
            <if test="isConn != null">is_conn,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="profileId != null">#{profileId},</if>
            <if test="name != null">#{name},</if>
            <if test="telno != null">#{telno},</if>
            <if test="relation != null">#{relation},</if>
            <if test="isConn != null">#{isConn},</if>
         </trim>
    </insert>

    <update id="updateTEmergentPeople" parameterType="TEmergentPeople">
        update t_emergent_people
        <trim prefix="SET" suffixOverrides=",">
            <if test="profileId != null">profile_id = #{profileId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="telno != null">telno = #{telno},</if>
            <if test="relation != null">relation = #{relation},</if>
            <if test="isConn != null">is_conn = #{isConn},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTEmergentPeopleById" parameterType="Integer">
        delete from t_emergent_people where id = #{id}
    </delete>

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