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

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

import java.util.List;

public interface TimeSheetRepository extends JpaRepository<TimeSheet, Integer> {
//    TimeSheet findTimeSheetById(int id);

//    @Query("select ts from TimeSheet ts order by ts.createdAt desc")
//    List<TimeSheet> getAllTimeSheet();

    @Modifying
    @Query("update TimeSheet ts set ts.title = ?1, ts.content = ?2, ts.note = ?3 where ts.id = ?4")
    int updateTimeSheet(String title, String content, String note, int timesheet_Id);

//    @Modifying
//    @Query("update TimeSheet ts set ts.status = ?1 where ts.id = ?2")
//    int updateTimeSheetStatus(boolean status, int id);

    @Query("select ts from TimeSheet ts where ts.eproject = ?1")
    List<TimeSheet> showTimeSheetByEproject(Eproject eproject);

    TimeSheet findTimeSheetByEprojectAndId(Eproject eproject, int timeSheet_Id);
}
