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

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

import java.util.List;


public interface ProjectReportRepository extends JpaRepository<ProjectReport, Integer> {

    @Query(value = "SELECT * FROM project_report pr WHERE pr.project_id = ?1 ORDER BY pr.created_at DESC limit 1", nativeQuery = true)
    ProjectReport latestReport(int projectId);

    @Query(value = "SELECT * FROM project_report pr WHERE pr.project_id = ?1 ORDER BY pr.created_at DESC", nativeQuery = true)
    List<ProjectReport> allProjectReport(int projectId);


}
