package com.itsol.quantrivanphong.report.timesheet.repository;

import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.model.Eproject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface EProjectRepository extends JpaRepository<Eproject, Integer> {
//    Eproject findEprojectById(int id);
    Eproject findEprojectByEmployee(Employee employee);

    Eproject findEprojectByIdAndEmployee(int eProject_Id, Employee employee);






    //======================================================================================================
    // Hieunv

    @Query(value = "SELECT * FROM eproject ep JOIN project p on p.id = ep.project_id WHERE p.id = ?1 AND ep.employee_id NOT IN (SELECT e.id FROM employee e  JOIN eproject ep ON e.id = ep.employee_id JOIN project p on p.id = ep.project_id JOIN timesheet ts on ts.eproject_id = ep.id WHERE p.id = ?1 AND ts.created_at Like ?2%)", nativeQuery = true)
    List<Eproject> listEprojectLack(int projectId, String currentDate);
}
