| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.YwBuildingMapper; |
| | | import com.doumee.dao.business.YwRoomMapper; |
| | | import com.doumee.dao.business.model.YwBuilding; |
| | | import com.doumee.dao.business.model.YwProject; |
| | | import com.doumee.dao.business.model.YwRoom; |
| | | import com.doumee.service.business.YwRoomService; |
| | |
| | | |
| | | @Autowired |
| | | private YwRoomMapper ywRoomMapper; |
| | | @Autowired |
| | | private YwBuildingMapper ywBuildingMapper; |
| | | |
| | | @Override |
| | | public Integer create(YwRoom model) { |
| | | if(model.getBuildingId()==null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的楼宇信息!"); |
| | | } |
| | | YwBuilding ywBuilding = ywBuildingMapper.selectById(model.getBuildingId()); |
| | | if(ywBuilding ==null ||Constants.equalsInteger(ywBuilding.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的楼宇信息!"); |
| | | } |
| | | model.setProjectId(ywBuilding.getProjectId()); |
| | | model.setCreator(model.getLoginUserInfo().getId()); |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setCreateDate(new Date()); |
| | |
| | | |
| | | @Override |
| | | public void updateById(YwRoom model) { |
| | | if(model.getBuildingId()==null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的楼宇信息!"); |
| | | } |
| | | YwBuilding ywBuilding = ywBuildingMapper.selectById(model.getBuildingId()); |
| | | if(ywBuilding ==null ||Constants.equalsInteger(ywBuilding.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的楼宇信息!"); |
| | | } |
| | | model.setProjectId(ywBuilding.getProjectId()); |
| | | model.setEditDate(new Date()); |
| | | model.setEditor(model.getLoginUserInfo().getId()); |
| | | ywRoomMapper.updateById(model); |
| | |
| | | |
| | | @Override |
| | | public List<YwRoom> findList(YwRoom ywRoom) { |
| | | QueryWrapper<YwRoom> wrapper = new QueryWrapper<>(ywRoom); |
| | | ywRoom.setIsdeleted(Constants.ZERO); |
| | | QueryWrapper<YwRoom> wrapper = new QueryWrapper< >(ywRoom); |
| | | return ywRoomMapper.selectList(wrapper); |
| | | } |
| | | |
| | |
| | | public PageData<YwRoom> findPage(PageWrap<YwRoom> pageWrap) { |
| | | IPage<YwRoom> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<YwRoom> queryWrapper = new QueryWrapper<>(); |
| | | pageWrap.getModel().setIsdeleted(Constants.ZERO); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(YwRoom::getId, pageWrap.getModel().getId()); |
| | |
| | | if (pageWrap.getModel().getBuildingId() != null) { |
| | | queryWrapper.lambda().eq(YwRoom::getBuildingId, pageWrap.getModel().getBuildingId()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | queryWrapper.lambda().orderByAsc(YwRoom::getRoomNum); |
| | | return PageData.from(ywRoomMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |