|
@@ -1,5 +1,13 @@
|
|
|
package com.chuanghai.ihotel.service.impl;
|
|
package com.chuanghai.ihotel.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.chuanghai.ihotel.common.exception.BizCodeEnume;
|
|
|
|
|
+import com.chuanghai.ihotel.common.exception.RRException;
|
|
|
|
|
+import com.chuanghai.ihotel.controller.request.RoomQueryRequest;
|
|
|
|
|
+import com.chuanghai.ihotel.entity.RoomTypeEntity;
|
|
|
|
|
+import com.chuanghai.ihotel.service.RoomTypeService;
|
|
|
|
|
+import com.chuanghai.ihotel.vo.RoomGroupVO;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -11,19 +19,68 @@ import com.chuanghai.ihotel.common.utils.PageParam;
|
|
|
import com.chuanghai.ihotel.dao.RoomDao;
|
|
import com.chuanghai.ihotel.dao.RoomDao;
|
|
|
import com.chuanghai.ihotel.entity.RoomEntity;
|
|
import com.chuanghai.ihotel.entity.RoomEntity;
|
|
|
import com.chuanghai.ihotel.service.RoomService;
|
|
import com.chuanghai.ihotel.service.RoomService;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service("roomService")
|
|
@Service("roomService")
|
|
|
public class RoomServiceImpl extends ServiceImpl<RoomDao, RoomEntity> implements RoomService {
|
|
public class RoomServiceImpl extends ServiceImpl<RoomDao, RoomEntity> implements RoomService {
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RoomTypeService roomTypeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Cacheable(value = {"room"}, key = "#root.method.name " +
|
|
|
|
|
+ "+ '-' + #pageParam.curPage " +
|
|
|
|
|
+ "+ '-' + #pageParam.pageSize " +
|
|
|
|
|
+ "+ '-' + #pageParam.orderField " +
|
|
|
|
|
+ "+ '-' + #pageParam.order " +
|
|
|
|
|
+ "+ '-' + #request.roomNo " +
|
|
|
|
|
+ "+ '-' + #request.build " +
|
|
|
|
|
+ "+ '-' + #request.floor " +
|
|
|
|
|
+ "+ '-' + #request.roomTypeId")
|
|
|
@Override
|
|
@Override
|
|
|
- public PageUtils queryPage(PageParam pageParam) {
|
|
|
|
|
|
|
+ public PageUtils queryPage(PageParam pageParam, RoomQueryRequest request) {
|
|
|
|
|
+ QueryWrapper<RoomEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(StringUtils.hasText(request.getRoomNo()), "room_no", request.getRoomNo());
|
|
|
|
|
+ queryWrapper.eq(StringUtils.hasText(request.getBuild()), "build", request.getBuild());
|
|
|
|
|
+ queryWrapper.eq(StringUtils.hasText(request.getFloor()), "floor", request.getFloor());
|
|
|
|
|
+ queryWrapper.eq(request.getRoomTypeId() != null, "room_type_id", request.getRoomTypeId());
|
|
|
|
|
+
|
|
|
IPage<RoomEntity> page = this.page(
|
|
IPage<RoomEntity> page = this.page(
|
|
|
new MyQuery<RoomEntity>().getPage(pageParam),
|
|
new MyQuery<RoomEntity>().getPage(pageParam),
|
|
|
- new QueryWrapper<RoomEntity>()
|
|
|
|
|
|
|
+ queryWrapper
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
return new PageUtils(page);
|
|
return new PageUtils(page);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Cacheable(value = {"room"},
|
|
|
|
|
+ key = "#root.method.name " +
|
|
|
|
|
+ "+ '-' + #pageParam.curPage " +
|
|
|
|
|
+ "+ '-' + #pageParam.pageSize " +
|
|
|
|
|
+ "+ '-' + #pageParam.orderField " +
|
|
|
|
|
+ "+ '-' + #pageParam.order " +
|
|
|
|
|
+ "+ '-' + #request.roomNo " +
|
|
|
|
|
+ "+ '-' + #request.build " +
|
|
|
|
|
+ "+ '-' + #request.floor " +
|
|
|
|
|
+ "+ '-' + #request.roomTypeId")
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public PageUtils queryPageGroup(PageParam pageParam, RoomQueryRequest request) {
|
|
|
|
|
+ IPage<RoomGroupVO> page =this.getBaseMapper().queryPageGroup(new MyQuery<RoomEntity>().getPage(pageParam), request);
|
|
|
|
|
+ return new PageUtils<>(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void mySave(RoomEntity room) {
|
|
|
|
|
+ // 检测房型是否存在
|
|
|
|
|
+ RoomTypeEntity roomType = roomTypeService.getById(room.getRoomTypeId());
|
|
|
|
|
+ if (roomType == null) {
|
|
|
|
|
+ throw new RRException(BizCodeEnume.PARAMETER_ERROR, "无效的roomTypeId");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ room.setRoomTypeName(roomType.getTypeName());
|
|
|
|
|
+
|
|
|
|
|
+ this.save(room);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|