<?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.community.room.mapper.RoomMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="roomResultMap" type="org.springblade.community.room.entity.Room">
        <result column="id" property="id"/>
        <result column="building_id" property="buildingId"/>
        <result column="building_name" property="buildingName"/>
        <result column="floor_id" property="floorId"/>
        <result column="floor_name" property="floorName"/>
        <result column="status" property="status"/>
        <result column="name" property="name"/>
        <result column="old_id" property="oldId"/>
        <result column="house_number" property="houseNumber"/>
        <result column="unit_id" property="unitId"/>
        <result column="unit_name" property="unitName"/>
        <result column="agency_id" property="agencyId"/>
        <result column="agency_name" property="agencyName"/>
        <result column="org_position" property="orgPosition"/>
        <result column="estate_position" property="estatePosition"/>
        <result column="area" property="area"/>
        <result column="house_type" property="houseType"/>
        <result column="floor" property="floor"/>
        <result column="ornament" property="ornament"/>
        <result column="orientation" property="orientation"/>
        <result column="user_number" property="userNumber"/>
        <result column="serial" property="serial"/>
        <result column="remark" property="remark"/>
        <result column="residential_id" property="residentialId"/>
        <result column="residential_name" property="residentialName"/>
        <result column="root_org_id" property="rootOrgId"/>
        <result column="create_account_id" property="createAccountId"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="inhabitant_id" property="inhabitantId"/>
    </resultMap>


    <select id="selectRoomPage" resultMap="roomResultMap">
        select * from estate_room where is_deleted = 0
    </select>

    <select id="getRoomsByPersonId" resultMap="roomResultMap">
        SELECT room.* FROM `estate_room` room, estate_houseuser houseuser
        WHERE houseuser.room_id = room.id
        and  houseuser.id = #{personId}
    </select>

</mapper>
