package com.zksy.environment.service.impl;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.environment.domain.ERealTimeData;
import com.zksy.environment.service.ERealTimeDataService;
import com.zksy.environment.mapper.ERealTimeDataMapper;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【e_real_time_data(环境实时数据)】的数据库操作Service实现
* @createDate 2025-08-27 10:30:48
*/
@Service
public class ERealTimeDataServiceImpl extends ServiceImpl<ERealTimeDataMapper, ERealTimeData>
    implements ERealTimeDataService{
    @Override
    public Page<ERealTimeData> findByPage(long pageNum, long pageSize, Integer deviceId, DateTime startTime, DateTime endTime) {
        Page<ERealTimeData> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<ERealTimeData> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ERealTimeData::getDeviceId,deviceId)
                .ge(ERealTimeData::getCreateTime,startTime)
                .le(ERealTimeData::getCreateTime,endTime);
        queryWrapper.orderByDesc(ERealTimeData::getCreateTime);
        return this.page(page,queryWrapper);
    }
}




