<?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="org.springblade.smartapplication.vcdevice.mapper.VideoCloudDeviceMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="videoCloudDeviceResultMap" type="org.springblade.smartapplication.vcdevice.entity.VideoCloudDevice">
        <result column="id" property="id"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="update_user" property="updateUser"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="device_id" property="deviceId"/>
        <result column="device_name" property="deviceName"/>
        <result column="device_num" property="deviceNum"/>
        <result column="device_password" property="devicePassword"/>
        <result column="device_type" property="deviceType"/>
        <result column="model_sequence" property="modelSequence"/>
        <result column="protocol_type" property="protocolType"/>
        <result column="is_online" property="isOnline"/>
        <result column="is_support_cloud_storage" property="isSupportCloudStorage"/>
        <result column="is_support_local_storage" property="isSupportLocalStorage"/>
        <result column="is_support_ptz" property="isSupportPtz"/>
        <result column="is_support_motion_detection" property="isSupportMotionDetection"/>
        <result column="is_support_manual_alarm" property="isSupportManualAlarm"/>
        <result column="is_support_external_alarm_switch" property="isSupportExternalAlarmSwitch"/>
        <result column="is_have_inversion" property="isHaveInversion"/>
        <result column="cloud_storage_type" property="cloudStorageType"/>
        <result column="cloud_storage_conf_id" property="cloudStorageConfId"/>
        <result column="stream_type" property="streamType"/>
        <result column="address" property="address"/>
        <result column="is_owner" property="isOwner"/>
        <result column="parent_nvr_num" property="parentNvrNum"/>
        <result column="alarm_status" property="alarmStatus"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="maintainer" property="maintainer"/>
        <result column="block" property="block"/>
        <result column="block_time" property="blockTime"/>
        <result column="route_id" property="routeId"/>
        <result column="equip_type" property="equipType"/>
        <result column="update_state_time_string" property="updateStateTimeString"/>
        <result column="district_id" property="districtId"/>
        <result column="org_position" property="orgPosition"/>
        <result column="rtsp_url" property="rtspUrl"/>
        <result column="http_flv_url" property="httpFlvUrl"/>
        <result column="account_name" property="accountName"/>
        <result column="agency_id" property="agencyId"/>
        <result column="agency_name" property="agencyName"/>
        <result column="residential_id" property="residentialId"/>
        <result column="residential_name" property="residentialName"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="building_id" property="buildingId"/>
        <result column="building_name" property="buildingName"/>
        <result column="flv_url" property="flvUrl"/>
        <result column="m3u8_url" property="m3u8Url"/>
        <result column="mp4_url" property="mp4Url"/>
        <result column="type" property="type"/>
        <result column="inhabitant_id" property="inhabitantId"/>
        <result column="stream_id" property="streamId"/>
<!--        <result column=""-->
    </resultMap>


    <select id="selectVideoCloudDevicePage" resultMap="videoCloudDeviceResultMap">
        select * from yc_video_cloud_device where is_deleted = 0
        <if test="videoCloudDevice != null">
            <if test="videoCloudDevice.deviceName != null">
                and device_name like '${videoCloudDevice.deviceName}%'
            </if>
            <if test="videoCloudDevice.deviceType != null">
                and device_type = '${videoCloudDevice.deviceType}'
            </if>
            <if test="videoCloudDevice.isOnline != null">
                and is_online = '${videoCloudDevice.isOnline}'
            </if>
        </if>
    </select>

    <select id="likeByResidentialName" resultMap="videoCloudDeviceResultMap">
        select * from yc_video_cloud_device where is_deleted = 0
        <if test="residentialName">
            and device_name like '%${residentialName}%'
        </if>
        ORDER BY update_time desc
    </select>

    <select id="getAllVCDeviceAccountName" resultType="String">
       select DISTINCT(account_name) from yc_video_cloud_device where account_name is not null
    </select>

</mapper>
