<?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.bofeng.dao.RoomMapper">
    <delete id="deleteByPlaceId">
        delete from tb_room where place_id = #{placeId}
    </delete>

    <select id="selectAll" resultType="com.bofeng.entity.Room">
--         select * from tb_room where be_active != 'D'
        select a.*, b.place_name as placeName from tb_room a left join tb_place b on (a.place_id = b.place_id)
        where b.be_active != 'D' and a.be_active != 'D'
    </select>

    <select id="checkRoomNameCount" resultType="java.lang.Integer">
select count(*) from tb_room r where r.room_id!=#{roomId} and r.place_id=#{placeId} and r.room_name=#{roomName}
    </select>

    <select id="selectByPlaceId" resultType="com.bofeng.entity.Room">
        select * from tb_room where place_id = #{placeId}
    </select>

    <update id="enableRoomById">
        update tb_room set
        be_use = 'N'
      where
        room_id=#{roomId}
    </update>

    <update id="useRoomById">
        update tb_room set
        be_use = 'U'
      where
        room_id=#{roomId}
    </update>

    <update id="reserveRoomById">
        update tb_room set
        be_use = 'Y'
      where
        room_id=#{roomId}
    </update>

</mapper>