<?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.community.huiju.dao.TpHotelRoomMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpHotelRoom" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="hotel_id" property="hotelId" jdbcType="INTEGER" />
    <result column="room_no" property="roomNo" jdbcType="VARCHAR" />
    <result column="room_name" property="roomName" jdbcType="VARCHAR" />
    <result column="sort" property="sort" jdbcType="INTEGER" />
    <result column="price" property="price" jdbcType="VARCHAR" />
    <result column="room_status" property="roomStatus" jdbcType="VARCHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, hotel_id, room_no, room_name, sort, price, room_status, remark, 
    create_date, create_user, update_date, update_user
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from tp_hotel_room
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_hotel_room
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpHotelRoom" >
    insert into tp_hotel_room (id, community_id, hotel_id, 
      room_no, room_name, sort, 
      price, room_status, remark, 
      create_date, create_user, update_date, 
      update_user)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{hotelId,jdbcType=INTEGER}, 
      #{roomNo,jdbcType=VARCHAR}, #{roomName,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, 
      #{price,jdbcType=VARCHAR}, #{roomStatus,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, 
      #{createDate,jdbcType=TIMESTAMP}, #{createUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP}, 
      #{updateUser,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpHotelRoom" >
    insert into tp_hotel_room
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="hotelId != null" >
        hotel_id,
      </if>
      <if test="roomNo != null" >
        room_no,
      </if>
      <if test="roomName != null" >
        room_name,
      </if>
      <if test="sort != null" >
        sort,
      </if>
      <if test="price != null" >
        price,
      </if>
      <if test="roomStatus != null" >
        room_status,
      </if>
      <if test="remark != null" >
        remark,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="updateDate != null" >
        update_date,
      </if>
      <if test="updateUser != null" >
        update_user,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="communityId != null" >
        #{communityId,jdbcType=INTEGER},
      </if>
      <if test="hotelId != null" >
        #{hotelId,jdbcType=INTEGER},
      </if>
      <if test="roomNo != null" >
        #{roomNo,jdbcType=VARCHAR},
      </if>
      <if test="roomName != null" >
        #{roomName,jdbcType=VARCHAR},
      </if>
      <if test="sort != null" >
        #{sort,jdbcType=INTEGER},
      </if>
      <if test="price != null" >
        #{price,jdbcType=VARCHAR},
      </if>
      <if test="roomStatus != null" >
        #{roomStatus,jdbcType=VARCHAR},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        #{updateUser,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpHotelRoom" >
    update tp_hotel_room
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="hotelId != null" >
        hotel_id = #{hotelId,jdbcType=INTEGER},
      </if>
      <if test="roomNo != null" >
        room_no = #{roomNo,jdbcType=VARCHAR},
      </if>
      <if test="roomName != null" >
        room_name = #{roomName,jdbcType=VARCHAR},
      </if>
      <if test="sort != null" >
        sort = #{sort,jdbcType=INTEGER},
      </if>
      <if test="price != null" >
        price = #{price,jdbcType=VARCHAR},
      </if>
      <if test="roomStatus != null" >
        room_status = #{roomStatus,jdbcType=VARCHAR},
      </if>
      <if test="remark != null" >
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpHotelRoom" >
    update tp_hotel_room
    set community_id = #{communityId,jdbcType=INTEGER},
      hotel_id = #{hotelId,jdbcType=INTEGER},
      room_no = #{roomNo,jdbcType=VARCHAR},
      room_name = #{roomName,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=INTEGER},
      price = #{price,jdbcType=VARCHAR},
      room_status = #{roomStatus,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      create_user = #{createUser,jdbcType=INTEGER},
      update_date = #{updateDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectHotelRoomList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from tp_hotel_room
    where  community_id = #{communityId,jdbcType=INTEGER}
    and hotel_id = #{hotelId,jdbcType=INTEGER}
    and room_status = 1
    ORDER BY sort desc ,update_date desc
  </select>
</mapper>