Commit d223dcfd authored by Samuel Kulisek's avatar Samuel Kulisek Committed by Jiri Novotny
Browse files

Add get report by id endpoint

parent 09f3a473
......@@ -7,4 +7,5 @@ public interface ReportFacade {
Page<ReportDetailDto> getAllMissionReports(Long missionId, int page, int pageSize);
Page<ReportDetailDto> getAllAgentReports(Long agentId, int page, int pageSize);
Page<ReportDetailDto> getAllMissionAgentReports(Long missionId, Long agentId, int page, int pageSize);
ReportDetailDto getReportById(Long reportId);
}
......@@ -5,6 +5,7 @@ import cz.muni.fi.pa165.dto.ReportDetailDto;
import cz.muni.fi.pa165.facade.ReportFacade;
import cz.muni.fi.pa165.rest.ApiResponse;
import cz.muni.fi.pa165.rest.ApiUris;
import cz.muni.fi.pa165.service.ReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
......@@ -87,4 +88,17 @@ public class ReportController {
return ResponseEntity.notFound().build();
}
}
@Operation(description = "Retrieve a specified report")
@GetMapping("/reports/{reportId}")
public final ResponseEntity<ReportDetailDto> getReportById(@PathVariable long reportId) {
//TODO logged in user logic
try {
return ResponseEntity.ok().body(reportFacade.getReportById(reportId));
} catch (Exception e) {
LOGGER.error("Could not retrieve reports of specified agent", e);
return ResponseEntity.notFound().build();
}
}
}
......@@ -63,4 +63,9 @@ public class ReportFacadeImpl implements ReportFacade {
return reports.map(reportDetailMapper::map);
}
@Override
public ReportDetailDto getReportById(Long reportId) {
return reportDetailMapper.map(reportService.findById(reportId));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment