<?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.ReceptionPersonnelMapper">
    
    <resultMap type="ReceptionPersonnel" id="ReceptionPersonnelResult">
        <result property="receptionId"    column="reception_id"    />
        <result property="receptionName"    column="reception_name"    />
        <result property="phonenumber"    column="phonenumber"    />
        <result property="introduction"    column="introduction"    />
        <result property="avatar"    column="avatar"    />
        <result property="status"    column="status"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectReceptionPersonnelVo">
        select reception_id, reception_name, phonenumber, introduction, avatar, status, create_by, create_time, update_by, update_time, remark from reception_personnel
    </sql>

    <select id="selectReceptionPersonnelList" parameterType="ReceptionPersonnel" resultMap="ReceptionPersonnelResult">
        <include refid="selectReceptionPersonnelVo"/>
        <where>  
            <if test="receptionName != null  and receptionName != ''"> and reception_name like concat('%', #{receptionName}, '%')</if>
            <if test="phonenumber != null  and phonenumber != ''"> and phonenumber = #{phonenumber}</if>
            <if test="introduction != null  and introduction != ''"> and introduction = #{introduction}</if>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
        order by create_time DESC
    </select>
    
    <select id="selectReceptionPersonnelByReceptionId" parameterType="Long" resultMap="ReceptionPersonnelResult">
        <include refid="selectReceptionPersonnelVo"/>
        where reception_id = #{receptionId}
    </select>
        
    <insert id="insertReceptionPersonnel" parameterType="ReceptionPersonnel" useGeneratedKeys="true" keyProperty="receptionId">
        insert into reception_personnel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="receptionName != null and receptionName != ''">reception_name,</if>
            <if test="phonenumber != null">phonenumber,</if>
            <if test="introduction != null">introduction,</if>
            <if test="avatar != null">avatar,</if>
            <if test="status != null">status,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="receptionName != null and receptionName != ''">#{receptionName},</if>
            <if test="phonenumber != null">#{phonenumber},</if>
            <if test="introduction != null">#{introduction},</if>
            <if test="avatar != null">#{avatar},</if>
            <if test="status != null">#{status},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateReceptionPersonnel" parameterType="ReceptionPersonnel">
        update reception_personnel
        <trim prefix="SET" suffixOverrides=",">
            <if test="receptionName != null and receptionName != ''">reception_name = #{receptionName},</if>
            <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
            <if test="introduction != null">introduction = #{introduction},</if>
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="status != null">status = #{status},</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="remark != null">remark = #{remark},</if>
        </trim>
        where reception_id = #{receptionId}
    </update>

    <delete id="deleteReceptionPersonnelByReceptionId" parameterType="Long">
        delete from reception_personnel where reception_id = #{receptionId}
    </delete>

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