<?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.fastbee.iot.mapper.DeviceAlertUserMapper">

    <resultMap type="DeviceAlertUser" id="DeviceAlertUserResult">
        <result property="deviceId"    column="device_id"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <resultMap type="com.fastbee.iot.model.vo.DeviceAlertUserVO" id="DeviceAlertUserVOResult">
        <result property="deviceId"    column="device_id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName" column="user_name"/>
        <result property="phoneNumber" column="phonenumber"/>
    </resultMap>

    <sql id="selectDeviceAlertUserVo">
        select device_id, user_id from iot_device_alert_user
    </sql>

    <select id="selectDeviceAlertUserList" parameterType="DeviceAlertUser" resultMap="DeviceAlertUserVOResult">
        select du.device_id, du.user_id , u.user_name, u.phonenumber
            from iot_device_alert_user du
            left join sys_user u on du.user_id = u.user_id
        where du.device_id = #{deviceAlertUser.deviceId}
    </select>

</mapper>
