| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.chuanghai.ihotel.common.utils.PageUtils;
- import com.chuanghai.ihotel.common.utils.MyQuery;
- import com.chuanghai.ihotel.common.utils.PageParam;
- import com.chuanghai.ihotel.dao.RoomDao;
- import com.chuanghai.ihotel.entity.RoomEntity;
- import com.chuanghai.ihotel.service.RoomService;
- import org.springframework.util.StringUtils;
- import java.util.Map;
- @Service("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
- 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(
- new MyQuery<RoomEntity>().getPage(pageParam),
- queryWrapper
- );
- 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);
- }
- }
|