|
Last change
on this file was 81cdf2d, checked in by Nikola Janev <nikolajanev57@…>, 9 days ago |
|
initial commit
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | package com.nikola.web3ednevnikbackend.controller;
|
|---|
| 2 |
|
|---|
| 3 | import com.nikola.web3ednevnikbackend.model.procedures.AttendanceReport;
|
|---|
| 4 | import com.nikola.web3ednevnikbackend.model.procedures.AttendanceReportResponse;
|
|---|
| 5 | import com.nikola.web3ednevnikbackend.repository.procedures.AttendanceReportRepository;
|
|---|
| 6 | import org.springframework.web.bind.annotation.GetMapping;
|
|---|
| 7 | import org.springframework.web.bind.annotation.RequestMapping;
|
|---|
| 8 | import org.springframework.web.bind.annotation.RestController;
|
|---|
| 9 |
|
|---|
| 10 | import java.time.LocalDate;
|
|---|
| 11 | import java.util.Collections;
|
|---|
| 12 | import java.util.List;
|
|---|
| 13 |
|
|---|
| 14 | @RestController
|
|---|
| 15 | @RequestMapping("/api/attendance-reports")
|
|---|
| 16 | public class AttendanceReportController {
|
|---|
| 17 |
|
|---|
| 18 | private final AttendanceReportRepository attendanceReportRepository;
|
|---|
| 19 |
|
|---|
| 20 | public AttendanceReportController(AttendanceReportRepository attendanceReportRepository) {
|
|---|
| 21 | this.attendanceReportRepository = attendanceReportRepository;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | @GetMapping
|
|---|
| 25 | public AttendanceReportResponse getReports() {
|
|---|
| 26 | List<AttendanceReport> reports = attendanceReportRepository.findAllReports();
|
|---|
| 27 | if(reports.isEmpty()){
|
|---|
| 28 | // throw new IllegalArgumentException("No reports found");
|
|---|
| 29 | return null;
|
|---|
| 30 | }
|
|---|
| 31 | LocalDate startDate = reports.get(0).startDate();
|
|---|
| 32 | LocalDate endDate = reports.get(0).endDate();
|
|---|
| 33 |
|
|---|
| 34 | return new AttendanceReportResponse(
|
|---|
| 35 | startDate,
|
|---|
| 36 | endDate,
|
|---|
| 37 | reports
|
|---|
| 38 | );
|
|---|
| 39 | }
|
|---|
| 40 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.