HotelMapper.xml
9.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?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>