package com.itsol.quantrivanphong.manager.reportdetail.bussiness;


import com.itsol.quantrivanphong.manager.reportdetail.dto.request.ReportDTO;
import com.itsol.quantrivanphong.manager.reportdetail.repository.ProjectReportRepository;
import com.itsol.quantrivanphong.manager.project.project.repository.ProjectRRepository;
import com.itsol.quantrivanphong.model.Project;
import com.itsol.quantrivanphong.model.ProjectReport;
import com.itsol.quantrivanphong.repository.EmployeeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportProjectBussiness {
    @Autowired
    private ProjectRRepository projectRepository;

    @Autowired
    private EmployeeRepository employeeRepository;

    @Autowired
    private ProjectReportRepository projectReportRepository;


    public List<Project> listProjectWorking(){

        List<Project> projectList = projectRepository.listProjectWorking();
        if(projectList.isEmpty()){
            return null;
        }else
            return projectList;
    }

    public List<ProjectReport> allProjectReport(ReportDTO reportDTO){

        List<ProjectReport> projectReportList = projectReportRepository.allProjectReport(reportDTO.getProjectId());
        if (projectReportList.isEmpty()){
            return  null;
        }else
        return projectReportList;
    }

    public ProjectReport latestReport(ReportDTO reportDTO){

        return projectReportRepository.latestReport(reportDTO.getProjectId());
    }
}
