<?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.facedevice.mapper.FaceDeviceMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="faceDeviceResultMap" type="org.springblade.smartapplication.facedevice.entity.FaceDevice">
        <id column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="address" property="address"/>
        <result column="camera_name" property="cameraName"/>
        <result column="city_code" property="cityCode"/>
        <result column="residential_id" property="residentialId"/>
        <result column="area_code" property="areaCode"/>
        <result column="camera_code" property="cameraCode"/>
        <result column="mac_address" property="macAddress"/>
        <result column="latitude" property="latitude"/>
        <result column="longitude" property="longitude"/>
        <result column="province_code" property="provinceCode"/>
        <result column="device_status" property="deviceStatus"/>
        <result column="old_id" property="oldId"/>
        <result column="org_position" property="orgPosition"/>
        <result column="device_factory" property="deviceFactory"/>
        <result column="agency_id" property="agencyId"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="inhabitant_id" property="inhabitantId"/>
    </resultMap>

    <resultMap id="faceDeviceVOResultMap" type="org.springblade.smartapplication.facedevice.vo.FaceDeviceVO" extends="faceDeviceResultMap">

    </resultMap>

    <select id="selectFaceDevicePage" resultMap="faceDeviceVOResultMap">
        select * from yc_face_device where is_deleted = 0
    </select>

    <select id="hasInstallResidentialCount" resultType="INT">
      select count(distinct(residential_id)) from yc_face_device  where is_deleted = 0
      <if test="faceDevice !=null">
          <if test="faceDevice.provinceCode!=null">
              and province_code = ${faceDevice.provinceCode}
          </if>
          <if test="faceDevice.cityCode!=null">
              and city_code = ${faceDevice.cityCode}
          </if>
          <if test="faceDevice.areaCode!=null">
              and area_code = ${faceDevice.areaCode}
          </if>



      </if>
    </select>
</mapper>
