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

    <!-- 通用查询映射结果 -->
    <resultMap id="roomResultMap" type="org.springblade.community.entity.Room">
        <result column="id" property="id"/>
        <result column="status" property="status"/>
        <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="is_deleted" property="isDeleted"/>
        <result column="name" property="name"/>
        <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="building_id" property="buildingId"/>
        <result column="building_name" property="buildingName"/>
        <result column="unit_id" property="unitId"/>
        <result column="unit_name" property="unitName"/>
        <result column="floor_id" property="floorId"/>
        <result column="floor_name" property="floorName"/>
        <result column="area" property="area"/>
        <result column="house_type" property="houseType"/>
        <result column="orientation" property="orientation"/>
        <result column="user_count" property="userCount"/>
        <result column="remark" property="remark"/>
        <result column="old_id" property="oldId"/>
        <result column="org_position" property="orgPosition"/>
        <result column="tenant_id" property="tenantId"/>
    </resultMap>


    <select id="selectRoomPage" resultMap="roomResultMap">
        select * from community_room where is_deleted = 0
        <if test="room != null">
            <if test="room.floorId != null">
                AND floor_id = #{room.floorId}
            </if>
            <if test="room.id != null">
                AND id = #{room.id}
            </if>
        </if>

    </select>

    <delete id="delete" parameterType="org.springblade.community.dto.AgencyMngDelDTO">
        delete from community_room
        where 1=1
        <if test="roomId != null and roomId!=''">
            and id = #{roomId}
        </if>
        <if test="floorId != null and floorId!=''">
            and floor_id = #{floorId}
        </if>
        <if test="unitId != null and unitId!=''">
            and unit_id = #{unitId}
        </if>
        <if test="buildingId != null and buildingId!=''">
            and building_id = #{buildingId}
        </if>
        <if test="residentialId != null and residentialId!=''">
            and residential_id = #{residentialId}
        </if>
    </delete>

</mapper>
