diff --git a/backend/src/main/java/com/srsystem/repository/ReportRepository.java b/backend/src/main/java/com/srsystem/repository/ReportRepository.java index 9dae1bd..2439a5e 100644 --- a/backend/src/main/java/com/srsystem/repository/ReportRepository.java +++ b/backend/src/main/java/com/srsystem/repository/ReportRepository.java @@ -17,7 +17,8 @@ public interface ReportRepository extends JpaRepository { Page findByStatus(ReportStatus status, Pageable pageable); List findByUser_EmpIdAndTargetDateBetween(Long empId, LocalDate start, LocalDate end); List findByDispatch_DispatchId(Long dispatchId); - Page findByUser_EmpIdAndStatusAndReportType(Long empId, ReportStatus status, ReportType reportType, LocalDate targetDate, Pageable pageable); + Page findByUser_EmpIdAndStatusAndReportTypeAndTargetDate(Long empId, ReportStatus status, ReportType reportType, LocalDate targetDate, Pageable pageable); + Page findByUser_EmpIdAndStatusAndReportType(Long empId, ReportStatus status, ReportType reportType, Pageable pageable); List findByTargetDateBetween(LocalDate start, LocalDate end); long countByStatus(ReportStatus status); } diff --git a/backend/src/main/java/com/srsystem/service/ReportService.java b/backend/src/main/java/com/srsystem/service/ReportService.java index 280074e..6d1b6ff 100644 --- a/backend/src/main/java/com/srsystem/service/ReportService.java +++ b/backend/src/main/java/com/srsystem/service/ReportService.java @@ -64,7 +64,12 @@ public class ReportService { public Page findByUserId(Long userId, ReportStatus status, String type, LocalDate targetDate, Pageable pageable) { ReportType reportType = type != null ? ReportType.valueOf(type) : null; - Page reports = reportRepository.findByUser_EmpIdAndStatusAndReportType(userId, status, reportType, targetDate, pageable); + Page reports; + if (targetDate != null) { + reports = reportRepository.findByUser_EmpIdAndStatusAndReportTypeAndTargetDate(userId, status, reportType, targetDate, pageable); + } else { + reports = reportRepository.findByUser_EmpIdAndStatusAndReportType(userId, status, reportType, pageable); + } return reports.map(this::toWorkReportResponse); }