package com.base.track.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.base.orbit.utils.DateUtils;
import com.base.track.mapper.OrbitNumMapper;
import com.base.track.model.entity.OrbitNum;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrbitNumService extends ServiceImpl<OrbitNumMapper, OrbitNum> {

    /**
     * 删除指定范围内指定星的数据
     *
     * @param satelliteIds 卫星id
     * @param startTime    开始时间
     * @param endTime      结束时间
     */
    public void deleteOrbitNumList(List<String> satelliteIds, String startTime, String endTime) {
        QueryWrapper<OrbitNum> queryWrapper = new QueryWrapper<>();
        if (!satelliteIds.isEmpty())
            queryWrapper.in("satellite_id", satelliteIds);
        queryWrapper.ge("start_time", DateUtils.string2LocalDateTime(startTime, DateUtils.YYYY_MM_DD_HH_MM_SS));
        queryWrapper.le("end_time", DateUtils.string2LocalDateTime(endTime, DateUtils.YYYY_MM_DD_HH_MM_SS));
        remove(queryWrapper);
    }
}
