<?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.usky.meeting.mapper.MeetingDevicePersonBindMapper">

    <resultMap id="BaseResultMap" type="com.usky.meeting.domain.MeetingDevicePersonBind">
        <result column="device_uuid" property="deviceUuid"/>
        <result column="person_id" property="personId"/>
        <result column="is_login_notify" property="isLoginNotify"/>
    </resultMap>

    <delete id="deleteByDeviceUuid">
        delete from meeting_device_person_bind
        where device_uuid = #{deviceUuid}
    </delete>

    <select id="selectByDeviceUuids" resultMap="BaseResultMap">
        select device_uuid, person_id, is_login_notify
        from meeting_device_person_bind
        <where>
            <if test="deviceUuids != null and deviceUuids.size() > 0">
                and device_uuid in
                <foreach collection="deviceUuids" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>

    <insert id="insert" parameterType="com.usky.meeting.domain.MeetingDevicePersonBind">
        insert into meeting_device_person_bind (device_uuid, person_id, is_login_notify)
        values (#{deviceUuid}, #{personId}, #{isLoginNotify})
    </insert>

</mapper>
