Skip to content

Commit

Permalink
#79 fix: Response 값 추가
Browse files Browse the repository at this point in the history
Animal Search시에 총 검색된 개수 반환
  • Loading branch information
fanta4715 committed Feb 25, 2024
1 parent eda4e51 commit ebddcf4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/gdsc/pikpet/dto/AnimalSearchDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public record AnimalSearchDto(
List<AnimalSimpleDto> animals,
Integer page,
int numberOfElements
int numberOfElements,
int totalElements
) {
}
3 changes: 2 additions & 1 deletion src/main/java/com/gdsc/pikpet/service/AnimalService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public AnimalSearchDto getAnimals(AnimalFilterCriteria animalFilterCriteria, Use
pageable
);
int numberOfElements = animals.getNumberOfElements();
int totalElements = (int) animals.getTotalElements();
UserAccount userAccount = userAccountService.getUserAccount(userSecurityDto);
List<AnimalSimpleDto> animalSimpleDtos = animals.getContent().stream()
.map(animal -> {
Expand All @@ -64,7 +65,7 @@ public AnimalSearchDto getAnimals(AnimalFilterCriteria animalFilterCriteria, Use
})
.toList();

AnimalSearchDto response = new AnimalSearchDto(animalSimpleDtos, animalFilterCriteria.page(), numberOfElements);
AnimalSearchDto response = new AnimalSearchDto(animalSimpleDtos, animalFilterCriteria.page(), numberOfElements, totalElements);
return response;
}

Expand Down

0 comments on commit ebddcf4

Please sign in to comment.