package com.jiayue.insu.incloud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiayue.insu.incloud.entity.ForecastData;
import com.jiayue.insu.incloud.mapper.ForecastDataMapper;
import com.jiayue.insu.incloud.service.ForecastDataService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ForecastDataServiceImpl extends ServiceImpl<ForecastDataMapper, ForecastData> implements ForecastDataService {


    @Override
    public boolean removeBetweenTimeByStation(String station, Long startTime, Long endTime) {
        LambdaQueryWrapper<ForecastData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.between(ForecastData::getForecastTime,startTime, endTime);
        lambdaQueryWrapper.eq(ForecastData::getStationCode,station);
        this.remove(lambdaQueryWrapper);
        return Boolean.TRUE;
    }

    @Override
    public List<ForecastData> findTimeByStation(String station, Long startTime, Long endTime) {
        LambdaQueryWrapper<ForecastData> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.between(ForecastData::getForecastTime,startTime, endTime);
        lambdaQueryWrapper.eq(ForecastData::getStationCode,station);
        return this.list(lambdaQueryWrapper);
    }
}
