|
@@ -0,0 +1,105 @@
|
|
|
+package com.gis.cms.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.gis.cms.entity.dto.HotelDto;
|
|
|
+import com.gis.cms.entity.dto.HotelPageDto;
|
|
|
+import com.gis.cms.entity.dto.RoomDto;
|
|
|
+import com.gis.cms.entity.po.HotelEntity;
|
|
|
+import com.gis.cms.mapper.HotelMapper;
|
|
|
+import com.gis.cms.service.HotelService;
|
|
|
+import com.gis.common.base.exception.BaseRuntimeException;
|
|
|
+import com.gis.common.base.service.impl.IBaseService;
|
|
|
+import com.gis.common.constant.ErrorEnum;
|
|
|
+import com.gis.common.util.BaseUtil;
|
|
|
+import com.gis.common.util.Result;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by owen on 2020/3/11 0011 16:16
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class HotelServiceImpl extends ServiceImpl<HotelMapper, HotelEntity> implements HotelService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IBaseService iBaseService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result search(HotelPageDto param) {
|
|
|
+ BaseUtil.startPage(param);
|
|
|
+ IPage<HotelEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
+
|
|
|
+ LambdaQueryWrapper<HotelEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ Integer zone = param.getZone();
|
|
|
+ wrapper.eq(HotelEntity::getZone, zone);
|
|
|
+
|
|
|
+ Integer status = param.getStatus();
|
|
|
+ if (status != null){
|
|
|
+ wrapper.eq(HotelEntity::getStatus, status);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer display = param.getDisplay();
|
|
|
+ if (display != null){
|
|
|
+ wrapper.eq(HotelEntity::getDisplay, display);
|
|
|
+ }
|
|
|
+
|
|
|
+ String searchKey = param.getSearchKey();
|
|
|
+ if (StrUtil.isNotBlank(searchKey)){
|
|
|
+ wrapper.like(HotelEntity::getName, searchKey);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(HotelEntity::getCreateTime);
|
|
|
+
|
|
|
+ IPage<HotelEntity> result = this.page(page, wrapper);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setDisplay(Long id, Integer display) {
|
|
|
+ getBaseMapper().setDisplay(id, display);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<HotelEntity> roomEdit(RoomDto param) {
|
|
|
+ HotelEntity entity = this.getById(param.getId());
|
|
|
+ BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ this.updateById(entity);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result saveEntity(HotelDto param) {
|
|
|
+ Long id = param.getId();
|
|
|
+
|
|
|
+ HotelEntity entity;
|
|
|
+ if (id == null){
|
|
|
+ entity = new HotelEntity();
|
|
|
+ entity.setCreatorId(iBaseService.getUserId());
|
|
|
+ } else {
|
|
|
+ entity = this.getById(id);
|
|
|
+ BaseRuntimeException.isNull(entity, ErrorEnum.FAILURE_SYS_2001);
|
|
|
+ }
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ this.saveOrUpdate(entity);
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|