fix: ReportRepository method name mismatch (targetDate)

This commit is contained in:
pray4skylark
2026-06-08 10:31:50 +09:00
parent 03d0d1e43d
commit 15b73e7bc0
2 changed files with 8 additions and 2 deletions
@@ -17,7 +17,8 @@ public interface ReportRepository extends JpaRepository<Report, Long> {
Page<Report> findByStatus(ReportStatus status, Pageable pageable); Page<Report> findByStatus(ReportStatus status, Pageable pageable);
List<Report> findByUser_EmpIdAndTargetDateBetween(Long empId, LocalDate start, LocalDate end); List<Report> findByUser_EmpIdAndTargetDateBetween(Long empId, LocalDate start, LocalDate end);
List<Report> findByDispatch_DispatchId(Long dispatchId); List<Report> findByDispatch_DispatchId(Long dispatchId);
Page<Report> findByUser_EmpIdAndStatusAndReportType(Long empId, ReportStatus status, ReportType reportType, LocalDate targetDate, Pageable pageable); Page<Report> findByUser_EmpIdAndStatusAndReportTypeAndTargetDate(Long empId, ReportStatus status, ReportType reportType, LocalDate targetDate, Pageable pageable);
Page<Report> findByUser_EmpIdAndStatusAndReportType(Long empId, ReportStatus status, ReportType reportType, Pageable pageable);
List<Report> findByTargetDateBetween(LocalDate start, LocalDate end); List<Report> findByTargetDateBetween(LocalDate start, LocalDate end);
long countByStatus(ReportStatus status); long countByStatus(ReportStatus status);
} }
@@ -64,7 +64,12 @@ public class ReportService {
public Page<WorkReportResponse> findByUserId(Long userId, ReportStatus status, String type, LocalDate targetDate, Pageable pageable) { public Page<WorkReportResponse> findByUserId(Long userId, ReportStatus status, String type, LocalDate targetDate, Pageable pageable) {
ReportType reportType = type != null ? ReportType.valueOf(type) : null; ReportType reportType = type != null ? ReportType.valueOf(type) : null;
Page<Report> reports = reportRepository.findByUser_EmpIdAndStatusAndReportType(userId, status, reportType, targetDate, pageable); Page<Report> 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); return reports.map(this::toWorkReportResponse);
} }