|
|
@@ -2,15 +2,19 @@ package com.example.hotel.blImpl.hotel;
|
|
|
|
|
|
import com.example.hotel.bl.hotel.HotelService;
|
|
|
import com.example.hotel.data.hotel.HotelMapper;
|
|
|
+import com.example.hotel.data.hotel.RoomMapper;
|
|
|
import com.example.hotel.data.user.AccountMapper;
|
|
|
import com.example.hotel.enums.BizRegion;
|
|
|
import com.example.hotel.enums.HotelStar;
|
|
|
import com.example.hotel.po.Hotel;
|
|
|
+import com.example.hotel.po.HotelRoom;
|
|
|
import com.example.hotel.vo.HotelVO;
|
|
|
+import com.example.hotel.vo.RoomVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class HotelServiceImpl implements HotelService {
|
|
|
@@ -19,8 +23,8 @@ public class HotelServiceImpl implements HotelService {
|
|
|
private AccountMapper accountMapper;
|
|
|
@Autowired
|
|
|
private HotelMapper hotelMapper;
|
|
|
-
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private RoomMapper roomMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -45,4 +49,27 @@ public class HotelServiceImpl implements HotelService {
|
|
|
|
|
|
return hotelMapper.selectAllHotel();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HotelVO retrieveHotelDetails(Integer hotelId) {
|
|
|
+ HotelVO hotelVO = hotelMapper.selectById(hotelId);
|
|
|
+ List<HotelRoom> rooms = roomMapper.selectRoomsByHotelId(hotelId);
|
|
|
+ List<RoomVO> roomVOS = rooms.stream().map(r -> {
|
|
|
+ RoomVO roomVO = new RoomVO();
|
|
|
+ roomVO.setId(r.getId());
|
|
|
+ roomVO.setPrice(r.getPrice());
|
|
|
+ roomVO.setRoomType(r.getRoomType().toString());
|
|
|
+ roomVO.setCurNum(r.getCurNum());
|
|
|
+ roomVO.setTotal(r.getTotal());
|
|
|
+ return roomVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ hotelVO.setRooms(roomVOS);
|
|
|
+
|
|
|
+ return hotelVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addHotelRoomInfo(HotelRoom hotelRoom) {
|
|
|
+ roomMapper.insertRoom(hotelRoom);
|
|
|
+ }
|
|
|
}
|