mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
update PetRestController getPets() method
This commit is contained in:
parent
ea3057f7af
commit
2f96792cb3
1 changed files with 5 additions and 1 deletions
|
@ -60,7 +60,11 @@ public class PetRestController {
|
|||
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
public ResponseEntity<Collection<Pet>> getPets(){
|
||||
return new ResponseEntity<Collection<Pet>>(this.clinicService.findAllPets(), HttpStatus.OK);
|
||||
Collection<Pet> pets = this.clinicService.findAllPets();
|
||||
if(pets.isEmpty()){
|
||||
return new ResponseEntity<Collection<Pet>>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return new ResponseEntity<Collection<Pet>>(pets, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pettypes}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||
|
|
Loading…
Reference in a new issue