package com.doumee.service.business.impl; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Utils; import com.doumee.dao.business.DeviceEventMapper; import com.doumee.dao.business.model.DeviceEvent; import com.doumee.service.business.DeviceEventService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; /** * 门禁事件推送记录表Service实现 * @author 江蹄蹄 * @date 2023/11/23 18:16 */ @Service public class DeviceEventServiceImpl implements DeviceEventService { @Autowired private DeviceEventMapper deviceEventMapper; @Override public Integer create(DeviceEvent deviceEvent) { deviceEventMapper.insert(deviceEvent); return deviceEvent.getId(); } @Override public void deleteById(Integer id) { deviceEventMapper.deleteById(id); } @Override public void delete(DeviceEvent deviceEvent) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(deviceEvent); deviceEventMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (CollectionUtils.isEmpty(ids)) { return; } deviceEventMapper.deleteBatchIds(ids); } @Override public void updateById(DeviceEvent deviceEvent) { deviceEventMapper.updateById(deviceEvent); } @Override public void updateByIdInBatch(List deviceEvents) { if (CollectionUtils.isEmpty(deviceEvents)) { return; } for (DeviceEvent deviceEvent: deviceEvents) { this.updateById(deviceEvent); } } @Override public DeviceEvent findById(Integer id) { return deviceEventMapper.selectById(id); } @Override public DeviceEvent findOne(DeviceEvent deviceEvent) { QueryWrapper wrapper = new QueryWrapper<>(deviceEvent); return deviceEventMapper.selectOne(wrapper); } @Override public List findList(DeviceEvent deviceEvent) { QueryWrapper wrapper = new QueryWrapper<>(deviceEvent); return deviceEventMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); QueryWrapper queryWrapper = new QueryWrapper<>(); Utils.MP.blankToNull(pageWrap.getModel()); if (pageWrap.getModel().getId() != null) { queryWrapper.lambda().eq(DeviceEvent::getId, pageWrap.getModel().getId()); } if (pageWrap.getModel().getCreator() != null) { queryWrapper.lambda().eq(DeviceEvent::getCreator, pageWrap.getModel().getCreator()); } if (pageWrap.getModel().getCreateDate() != null) { queryWrapper.lambda().ge(DeviceEvent::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); queryWrapper.lambda().le(DeviceEvent::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); } if (pageWrap.getModel().getEditor() != null) { queryWrapper.lambda().eq(DeviceEvent::getEditor, pageWrap.getModel().getEditor()); } if (pageWrap.getModel().getEditDate() != null) { queryWrapper.lambda().ge(DeviceEvent::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); queryWrapper.lambda().le(DeviceEvent::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); } if (pageWrap.getModel().getIsdeleted() != null) { queryWrapper.lambda().eq(DeviceEvent::getIsdeleted, pageWrap.getModel().getIsdeleted()); } if (pageWrap.getModel().getRemark() != null) { queryWrapper.lambda().eq(DeviceEvent::getRemark, pageWrap.getModel().getRemark()); } if (pageWrap.getModel().getCompanyId() != null) { queryWrapper.lambda().eq(DeviceEvent::getCompanyId, pageWrap.getModel().getCompanyId()); } if (pageWrap.getModel().getFaceImg() != null) { queryWrapper.lambda().eq(DeviceEvent::getFaceImg, pageWrap.getModel().getFaceImg()); } if (pageWrap.getModel().getImgurl() != null) { queryWrapper.lambda().eq(DeviceEvent::getImgurl, pageWrap.getModel().getImgurl()); } if (pageWrap.getModel().getType() != null) { queryWrapper.lambda().eq(DeviceEvent::getType, pageWrap.getModel().getType()); } if (pageWrap.getModel().getName() != null) { queryWrapper.lambda().eq(DeviceEvent::getName, pageWrap.getModel().getName()); } if (pageWrap.getModel().getBirthday() != null) { queryWrapper.lambda().ge(DeviceEvent::getBirthday, Utils.Date.getStart(pageWrap.getModel().getBirthday())); queryWrapper.lambda().le(DeviceEvent::getBirthday, Utils.Date.getEnd(pageWrap.getModel().getBirthday())); } if (pageWrap.getModel().getPhone() != null) { queryWrapper.lambda().eq(DeviceEvent::getPhone, pageWrap.getModel().getPhone()); } if (pageWrap.getModel().getIdcardNo() != null) { queryWrapper.lambda().eq(DeviceEvent::getIdcardNo, pageWrap.getModel().getIdcardNo()); } if (pageWrap.getModel().getIdcardDecode() != null) { queryWrapper.lambda().eq(DeviceEvent::getIdcardDecode, pageWrap.getModel().getIdcardDecode()); } if (pageWrap.getModel().getCode() != null) { queryWrapper.lambda().eq(DeviceEvent::getCode, pageWrap.getModel().getCode()); } if (pageWrap.getModel().getClasses() != null) { queryWrapper.lambda().eq(DeviceEvent::getClasses, pageWrap.getModel().getClasses()); } if (pageWrap.getModel().getEventDate() != null) { queryWrapper.lambda().ge(DeviceEvent::getEventDate, Utils.Date.getStart(pageWrap.getModel().getEventDate())); queryWrapper.lambda().le(DeviceEvent::getEventDate, Utils.Date.getEnd(pageWrap.getModel().getEventDate())); } if (pageWrap.getModel().getMemberId() != null) { queryWrapper.lambda().eq(DeviceEvent::getMemberId, pageWrap.getModel().getMemberId()); } if (pageWrap.getModel().getEventCode() != null) { queryWrapper.lambda().eq(DeviceEvent::getEventCode, pageWrap.getModel().getEventCode()); } if (pageWrap.getModel().getInoutType() != null) { queryWrapper.lambda().eq(DeviceEvent::getInoutType, pageWrap.getModel().getInoutType()); } for(PageWrap.SortData sortData: pageWrap.getSorts()) { if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { queryWrapper.orderByDesc(sortData.getProperty()); } else { queryWrapper.orderByAsc(sortData.getProperty()); } } return PageData.from(deviceEventMapper.selectPage(page, queryWrapper)); } @Override public long count(DeviceEvent deviceEvent) { QueryWrapper wrapper = new QueryWrapper<>(deviceEvent); return deviceEventMapper.selectCount(wrapper); } }