HotelMapper.xml 9.0 KB
<?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.sibu.orderHelper.integral.web.dao.IMWebHotelDao">
    <resultMap id="hotelResponse" type="com.sibu.orderHelper.hotel.model.HotelBean">
		<result property="hotelId" column="hotel_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelName" column="hotel_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="openTime" column="open_time" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
		<result property="hotelStar" column="hotel_star" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelAddress" column="hotel_address" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelTelphone" column="hotel_telphone" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="checkInTime" column="check_in_time" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="checkOutTime" column="check_out_time" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="intro" column="intro" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="roomEquipment" column="room_equipment" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelService" column="hotel_service" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="thumbUrl" column="thumb_url" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="sortIndex" column="sort_index" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="shortName" column="short_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="isDelete" column="is_delete" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
		<result property="isShow" column="is_show" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
	</resultMap>
	
	<!-- 返回hotel明细带图片 -->
	<resultMap id="hotelDetailResponse" type="com.sibu.orderHelper.integral.reponse.HotelDetailResponse">
		<id property="hotelId" column="hotel_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelName" column="hotel_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="openTime" column="open_time" />
		<result property="hotelStar" column="hotel_star" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelAddress" column="hotel_address" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelTelphone" column="hotel_telphone" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="checkInTime" column="check_in_time" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="checkOutTime" column="check_out_time" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="intro" column="intro" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="roomEquipment" column="room_equipment" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="hotelService" column="hotel_service" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="thumbUrl" column="thumb_url" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="sortIndex" column="sort_index" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="shortName" column="short_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="isDelete" column="is_delete" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
		<result property="isShow" column="is_show" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<collection property="hotelImgs" ofType="com.sibu.orderHelper.hotel.model.HotelImageBean" column="hotel_id">
			<result property="imageUrl"  column="image_url"/>
			<result property="imageId" column="image_id"></result>
			<result property="hotelId" column="hotel_id"></result>
		</collection>
	</resultMap>
	<!-- 缓存api酒店列表 -->
	<select id="listHotel" resultMap="listHotelResponse"  parameterType="map">
    	SELECT
			ho.hotel_id,ho.hotel_name,ho.short_name,ho.thumb_url,ho.sort_index 
		FROM
			hotel ho
		WHERE
			ho.is_show = 1 and ho.is_delete = 1
		ORDER BY 
			ho.sort_index asc
		LIMIT 0,30
    </select>
    <resultMap type="com.sibu.orderHelper.hotel.response.HotelListResponse" id="listHotelResponse">
        <id column="hotel_id" property="hotelId" />
        <result column="hotel_name" property="hotelName" />
        <result column="short_name" property="shortName" />
        <result column="thumb_url" property="thumbUrl" />
        <result column="sort_index" property="sortIndex" />
    </resultMap>
    
    <!-- api酒店详情 -->
    <select id="getHotelDetail" resultMap="hotelApiDetailResponse" parameterType="map">
    	SELECT
			ho.* 
		FROM
			hotel ho
		WHERE ho.hotel_id = #{hotelId}
    </select>
    <resultMap type="com.sibu.orderHelper.hotel.response.HotelDetailResponse" id="hotelApiDetailResponse">
        <id column="hotel_id" property="hotelId" />
        <result column="hotel_name" property="hotelName" />
        <result column="open_time" property="openTime" />
        <result column="hotel_star" property="hotelStar" />
        <result column="hotel_address" property="hotelAddress" />
        <result column="hotel_telphone" property="hotelTelphone" />
        <result column="check_in_time" property="checkInTime" />
        <result column="check_out_time" property="checkOutTime" />
        <result column="intro" property="intro" />
        <result column="room_equipment" property="roomEquipment" />
        <result column="hotel_service" property="hotelService" />
        <result column="short_name" property="shortName" />
    </resultMap>
    
	<!-- 查询全hotel列表 -->
	
	<select id="queryHotelAll" resultMap="hotelResponse"  parameterType="map">
    	SELECT
			ho.hotel_id,ho.hotel_name,ho.short_name,ho.thumb_url,ho.open_time,ho.hotel_star,ho.hotel_service,
			ho.check_in_time,ho.check_out_time,ho.intro,ho.room_equipment,ho.hotel_address,ho.hotel_telphone
		FROM
			hotel ho
		WHERE
			ho.is_show = 1 and ho.is_delete = 1
			<if test="hotelId!=null and hotelId!=''">
				and ho.hotel_id=#{hotelId}
			</if>
		ORDER BY 
			ho.sort_index asc
    </select>
    
    

    <!-- 保存一 -->
	<insert id="saveHotel" parameterType="com.sibu.orderHelper.hotel.model.HotelBean">
		INSERT INTO hotel (
			hotel_id,hotel_name,open_time,hotel_star,hotel_address,hotel_telphone,check_in_time,check_out_time,intro,room_equipment,hotel_service,thumb_url,sort_index,short_name,create_date
		) VALUES (
			#{hotelId},#{hotelName},#{openTime},#{hotelStar},#{hotelAddress},#{hotelTelphone},#{checkInTime},#{checkOutTime},#{intro},#{roomEquipment},#{hotelService},#{thumbUrl},
			#{sortIndex},#{shortName},now()
		)
	</insert>
	<!-- 修改对象属性-->
	<update id="updateHotel" parameterType="java.util.Map">
		UPDATE hotel
		<trim prefix="SET" suffixOverrides=",">
			<if test="null != hotelName">
				hotel_name=#{hotelName},
			</if>
			<if test="null != openTime">
				open_time=#{openTime},
			</if>
			<if test="null != hotelStar">
				hotel_star=#{hotelStar},
			</if>
			<if test="null != hotelAddress">
				hotel_address=#{hotelAddress},
			</if>
			<if test="null != hotelTelphone">
				hotel_telphone=#{hotelTelphone},
			</if>
			<if test="null != checkInTime">
				check_in_time=#{checkInTime},
			</if>
			<if test="null != checkOutTime">
				check_out_time=#{checkOutTime},
			</if>
			<if test="null != intro">
				intro=#{intro},
			</if>
			<if test="null != roomEquipment">
				room_equipment=#{roomEquipment},
			</if>
			<if test="null != hotelService">
				hotel_service=#{hotelService},
			</if>
			<if test="null != thumbUrl">
				thumb_url=#{thumbUrl},
			</if>
			<if test="null != sortIndex">
				sort_index=#{sortIndex},
			</if>
			<if test="null != shortName">
				short_name=#{shortName},
			</if>
			<if test="null != isDelete">
				is_delete=#{isDelete},
			</if>
			<if test="null != isShow">
				is_show=#{isShow},
			</if>
		</trim>
		WHERE hotel_id = #{hotelId}
	</update>
	<!-- 查询单个明细 -->
	<select id="queryHotel" resultMap="hotelDetailResponse" parameterType="java.lang.String">
	  SELECT ho.hotel_id,ho.hotel_name,ho.short_name,ho.thumb_url,ho.open_time,ho.hotel_star,ho.hotel_service,
	   ho.check_in_time,ho.check_out_time,ho.intro,ho.room_equipment,ho.hotel_address,ho.hotel_telphone ,image.image_url,image.image_id,image.hotel_id
	   FROM hotel ho left join hotel_image image
	   on ho.hotel_id =image.hotel_id
	   where  ho.hotel_id = #{hotelId}
	</select>
	<!-- 删除或者隐藏hotel -->
	<update id="delOrHideHotel" parameterType="java.util.Map">
		UPDATE hotel
		<trim prefix="SET" suffixOverrides=",">
			<if test="null != isDelete">
				is_delete=#{isDelete},
			</if>
			<if test="null != isShow ">
				is_show=#{isShow},
			</if>
		</trim>
		WHERE hotel_id = #{hotelId}
	</update>
	</mapper>