Skip to content

Commit

Permalink
[refactoring]: Changed the getUsersPhotos method
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Kolovorotnyi committed Jul 14, 2023
1 parent a4801b2 commit 660cb01
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ public PhotoJson addPhoto(PhotoJson photoJson) {
}

public List<PhotoJson> getAllUserPhotos(String username) {
List<PhotoJson> usersPhoto = new ArrayList<>();
List<PhotoServiceJson> photos = photoService.getPhotosForUser(username);
if (!photos.isEmpty()) {
for (PhotoServiceJson photo : photos) {
CountryJson country = countryService.findById(photo.getCountryId());
usersPhoto.add(PhotoServiceJson.fromPhotoServiceJson(photo, country));
}
if (photos.isEmpty()) {
return new ArrayList<>();
}
return usersPhoto;

return photos.stream()
.map(photo -> {
CountryJson country = countryService.findById(photo.getCountryId());
return PhotoServiceJson.fromPhotoServiceJson(photo, country);
})
.toList();
}

public PhotoJson editPhoto(PhotoJson photoJson, UUID id) {
Expand Down

0 comments on commit 660cb01

Please sign in to comment.