package com.jiayue.ipfcst.console.service;

import com.jiayue.ipfcst.common.data.entity.FileAnalysisRecord;
import com.jiayue.ipfcst.common.data.repository.FileAnalysisRecordRepository;
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 java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Service
@Slf4j
public class FileAnalysisRecordService extends BaseService {
    @Autowired
    FileAnalysisRecordRepository fileAnalysisRecordRepository;

    public void save(FileAnalysisRecord fileAnalysisRecord) {
        fileAnalysisRecordRepository.save(fileAnalysisRecord);
    }


    public List<FileAnalysisRecord> findByCreateTimeBetween(Date startTime, Date endTime){
      return fileAnalysisRecordRepository.findByCreateTimeBetween(startTime,endTime).stream().sorted(Comparator.comparing(FileAnalysisRecord::getCreateTime).reversed()).collect(Collectors.toList());

    }
}
