[R6] Get patients method in patient controller

This commit is contained in:
Mirna Gama 2024-01-06 19:17:25 -03:00 committed by Mirna Gama
parent 3b7437f654
commit e7d682126c

View File

@ -3,6 +3,9 @@ package com.mirna.hospitalmanagementapi.application.controllers;
import java.net.URI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -14,6 +17,7 @@ import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import com.mirna.hospitalmanagementapi.domain.dtos.patient.PatientDTO;
import com.mirna.hospitalmanagementapi.domain.dtos.patient.PatientPublicDataDTO;
import com.mirna.hospitalmanagementapi.domain.entities.Patient;
import com.mirna.hospitalmanagementapi.domain.services.PatientService;
@ -71,4 +75,19 @@ public class PatientController {
return ResponseEntity.ok(patient);
}
/**
* Get method to receive a paginated sublist of objects containing data transfer objects with Patient public information
*
* @param pageable Pagination information, such as size and page number
*
* @return A response entity containing the paginated sublist of patients if successful
*/
@GetMapping
public ResponseEntity<Object> getPatients(@PageableDefault(size = 10, sort = {"name"}) Pageable pageable) {
Page<PatientPublicDataDTO> patients = patientService.findPatients(pageable);
return ResponseEntity.ok(patients);
}
}