<?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.TpHotelMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpHotel" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="hotel_tel" property="hotelTel" jdbcType="VARCHAR" />
    <result column="hotel_address" property="hotelAddress" jdbcType="VARCHAR" />
    <result column="hotel_longitude" property="hotelLongitude" jdbcType="VARCHAR" />
    <result column="hotel_latitude" property="hotelLatitude" 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" />
    <result column="hotel_name" property="hotelName" jdbcType="VARCHAR" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.community.huiju.model.TpHotel" extends="BaseResultMap" >
    <result column="hotel_introduction" property="hotelIntroduction" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id,hotel_name community_id, hotel_tel, hotel_address, hotel_longitude, hotel_latitude, create_date,
    create_user, update_date, update_user
  </sql>
  <sql id="Blob_Column_List" >
    hotel_introduction
  </sql>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from tp_hotel
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_hotel
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpHotel" >
    insert into tp_hotel (id, community_id, hotel_tel, 
      hotel_address, hotel_longitude, hotel_latitude, 
      create_date, create_user, update_date, 
      update_user, hotel_introduction)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{hotelTel,jdbcType=VARCHAR}, 
      #{hotelAddress,jdbcType=VARCHAR}, #{hotelLongitude,jdbcType=VARCHAR}, #{hotelLatitude,jdbcType=VARCHAR}, 
      #{createDate,jdbcType=TIMESTAMP}, #{createUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP}, 
      #{updateUser,jdbcType=INTEGER}, #{hotelIntroduction,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpHotel" >
    insert into tp_hotel
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="hotelTel != null" >
        hotel_tel,
      </if>
      <if test="hotelAddress != null" >
        hotel_address,
      </if>
      <if test="hotelLongitude != null" >
        hotel_longitude,
      </if>
      <if test="hotelLatitude != null" >
        hotel_latitude,
      </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>
      <if test="hotelIntroduction != null" >
        hotel_introduction,
      </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="hotelTel != null" >
        #{hotelTel,jdbcType=VARCHAR},
      </if>
      <if test="hotelAddress != null" >
        #{hotelAddress,jdbcType=VARCHAR},
      </if>
      <if test="hotelLongitude != null" >
        #{hotelLongitude,jdbcType=VARCHAR},
      </if>
      <if test="hotelLatitude != null" >
        #{hotelLatitude,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>
      <if test="hotelIntroduction != null" >
        #{hotelIntroduction,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpHotel" >
    update tp_hotel
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="hotelTel != null" >
        hotel_tel = #{hotelTel,jdbcType=VARCHAR},
      </if>
      <if test="hotelAddress != null" >
        hotel_address = #{hotelAddress,jdbcType=VARCHAR},
      </if>
      <if test="hotelLongitude != null" >
        hotel_longitude = #{hotelLongitude,jdbcType=VARCHAR},
      </if>
      <if test="hotelLatitude != null" >
        hotel_latitude = #{hotelLatitude,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>
      <if test="hotelIntroduction != null" >
        hotel_introduction = #{hotelIntroduction,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.community.huiju.model.TpHotel" >
    update tp_hotel
    set community_id = #{communityId,jdbcType=INTEGER},
      hotel_tel = #{hotelTel,jdbcType=VARCHAR},
      hotel_address = #{hotelAddress,jdbcType=VARCHAR},
      hotel_longitude = #{hotelLongitude,jdbcType=VARCHAR},
      hotel_latitude = #{hotelLatitude,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      create_user = #{createUser,jdbcType=INTEGER},
      update_date = #{updateDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER},
      hotel_introduction = #{hotelIntroduction,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpHotel" >
    update tp_hotel
    set community_id = #{communityId,jdbcType=INTEGER},
      hotel_tel = #{hotelTel,jdbcType=VARCHAR},
      hotel_address = #{hotelAddress,jdbcType=VARCHAR},
      hotel_longitude = #{hotelLongitude,jdbcType=VARCHAR},
      hotel_latitude = #{hotelLatitude,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="selectCommunityHotel" parameterType="integer" resultMap="ResultMapWithBLOBs">
    select
    id,hotel_name, community_id, hotel_tel, hotel_address, hotel_longitude, hotel_latitude, create_date,
    create_user, update_date, update_user,hotel_introduction
    from tp_hotel
    where community_id = #{communityId,jdbcType=INTEGER}
  </select>
  
  <select id="hotelSetting" resultType="string">
    select id from tp_hotel_setting where  community_id = #{communityId}
  </select>

</mapper>