package com.jiayue.ipfcst.console.service;


import com.jiayue.ipfcst.common.data.entity.NwpTwo;
import com.jiayue.ipfcst.common.data.repository.NwpTwoRepository;
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 NwpTwoService extends BaseService {

    @Autowired
    NwpTwoRepository nwpTwoRepository;


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

}
