package com.jiayue.ipfcst.console.service;


import com.jiayue.ipfcst.common.data.entity.NwpOne;
import com.jiayue.ipfcst.common.data.repository.NwpOneRepository;
import com.jiayue.ipfcst.common.data.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Slf4j
public class NwpOneService extends BaseService {

    @Autowired
    NwpOneRepository nwpOneRepository;

    /**
     * 根据时间段删除数据
     *
     * @param startTime
     * @param endTime
     * @param listNwp
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public void deleteBetweenAndPreTime(Long startTime, Long endTime, List<NwpOne> listNwp) {
      nwpOneRepository.deleteByPreTimeBetween(startTime, endTime);
      nwpOneRepository.saveAll(listNwp);
    }

}
