|
|
@@ -1,14 +1,18 @@
|
|
|
package com.example.hotel.blImpl.hotel;
|
|
|
|
|
|
import com.example.hotel.bl.hotel.HotelService;
|
|
|
+import com.example.hotel.bl.hotel.RoomService;
|
|
|
+import com.example.hotel.bl.user.AccountService;
|
|
|
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.enums.UserType;
|
|
|
import com.example.hotel.po.Hotel;
|
|
|
import com.example.hotel.po.HotelRoom;
|
|
|
import com.example.hotel.po.User;
|
|
|
+import com.example.hotel.util.ServiceException;
|
|
|
import com.example.hotel.vo.HotelVO;
|
|
|
import com.example.hotel.vo.RoomVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -22,12 +26,18 @@ public class HotelServiceImpl implements HotelService {
|
|
|
|
|
|
@Autowired
|
|
|
private HotelMapper hotelMapper;
|
|
|
- @Autowired
|
|
|
- private RoomMapper roomMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AccountService accountService;
|
|
|
+ @Autowired
|
|
|
+ private RoomService roomService;
|
|
|
|
|
|
@Override
|
|
|
- public void addHotel(HotelVO hotelVO) {
|
|
|
+ public void addHotel(HotelVO hotelVO) throws ServiceException {
|
|
|
+ User manager = accountService.getUserInfo(hotelVO.getManagerId());
|
|
|
+ if(manager == null || !manager.getUserType().equals(UserType.HotelManager)){
|
|
|
+ throw new ServiceException("管理员不存在或者无权限!创建酒店失败!");
|
|
|
+ }
|
|
|
Hotel hotel = new Hotel();
|
|
|
hotel.setDescription(hotelVO.getDescription());
|
|
|
hotel.setAddress(hotelVO.getAddress());
|
|
|
@@ -38,12 +48,6 @@ public class HotelServiceImpl implements HotelService {
|
|
|
hotel.setBizRegion(BizRegion.valueOf(hotelVO.getBizRegion()));
|
|
|
hotel.setHotelStar(HotelStar.valueOf(hotelVO.getHotelStar()));
|
|
|
hotelMapper.insertHotel(hotel);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateRoomInfo(Integer hotelId, String roomType, Integer rooms) {
|
|
|
- roomMapper.updateRoomInfo(hotelId,roomType,rooms);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -55,7 +59,7 @@ public class HotelServiceImpl implements HotelService {
|
|
|
@Override
|
|
|
public HotelVO retrieveHotelDetails(Integer hotelId) {
|
|
|
HotelVO hotelVO = hotelMapper.selectById(hotelId);
|
|
|
- List<HotelRoom> rooms = roomMapper.selectRoomsByHotelId(hotelId);
|
|
|
+ List<HotelRoom> rooms = roomService.retrieveHotelRoomInfo(hotelId);
|
|
|
List<RoomVO> roomVOS = rooms.stream().map(r -> {
|
|
|
RoomVO roomVO = new RoomVO();
|
|
|
roomVO.setId(r.getId());
|
|
|
@@ -70,13 +74,4 @@ public class HotelServiceImpl implements HotelService {
|
|
|
return hotelVO;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void addHotelRoomInfo(HotelRoom hotelRoom) {
|
|
|
- roomMapper.insertRoom(hotelRoom);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getRoomCurNum(Integer hotelId, String roomType) {
|
|
|
- return roomMapper.getRoomCurNum(hotelId,roomType);
|
|
|
- }
|
|
|
}
|