Skip to content

Commit

Permalink
Merge branch '1-create-table-for-medtype' of https://github.com/E-Hay…
Browse files Browse the repository at this point in the history
…van/e-hayvan-backend into 1-create-table-for-medtype
  • Loading branch information
FruTooTi committed Jan 1, 2024
2 parents 919c760 + d3a9f22 commit c4b1e91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ public ResponseEntity<List<PetDTO>> getAllPetsForPetOwner(@PathVariable Integer
}
}

@GetMapping("/all")
public ResponseEntity<List<PetDTO>> getAllPets() {
List<PetDTO> response = petService.getAllPets();

if (!response.isEmpty()) {
return new ResponseEntity<>(response, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

@PostMapping
public ResponseEntity<PetDTO> savePet(@RequestBody CreateOrUpdatePetDTO petDTO) {
PetDTO savedPet = petService.postPet(petDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public PetDTO getPetById(Integer id) {
return null;
}

public List<PetDTO> getAllPets() {
List<Pet> petList = petRepository.findAll();
List<PetDTO> petDtoList = new ArrayList<>();

for (Pet pet : petList) {
petDtoList.add(petMapper.convertToDto(pet));
}

return petDtoList;
}


public PetDTO postPet(CreateOrUpdatePetDTO newPetDto){
// Map the data transfer object data to real object.
Expand Down

0 comments on commit c4b1e91

Please sign in to comment.