Skip to content

Commit

Permalink
Merge branch 'feature/#28/get-photoList-api' of https://github.com/Na…
Browse files Browse the repository at this point in the history
…-o-man/Na-o-man_server into feature/#28/get-photoList-api
  • Loading branch information
jjeongdong committed Jul 31, 2024
2 parents fd03043 + ae42682 commit 544915b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ResultResponse<PhotoResponse.PhotoUploadInfo> uploadPhotoList(@Valid @Req
}

@GetMapping("/all")
public ResultResponse<PhotoResponse.PhotoListInfo> getAllPhotoListByShareGroup(@RequestParam Long shareGroupId,
public ResultResponse<PhotoResponse.PagedPhotoInfo> getAllPhotoListByShareGroup(@RequestParam Long shareGroupId,
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable) {
Page<Photo> allPhotoListByShareGroup = photoService.getAllPhotoList(shareGroupId, pageable);
return ResultResponse.of(RETRIEVE_PHOTO, photoConverter.toPhotoListInfo(allPhotoListByShareGroup));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,16 @@ public Photo toEntity(String photoUrl, String photoName, ShareGroup shareGroup)
.build();
}

public PhotoResponse.PhotoListInfo toPhotoListInfo(Page<Photo> photoList) {
public PhotoResponse.PagedPhotoInfo toPhotoListInfo(Page<Photo> photoList) {
List<PhotoResponse.PhotoInfo> photoInfoList = photoList.stream()
.map(this::toPhotoInfo)
.collect(Collectors.toList());

return PhotoResponse.PhotoListInfo.builder()
return PhotoResponse.PagedPhotoInfo.builder()
.isLast(photoList.isLast())
.isFirst(photoList.isFirst())
.totalPage(photoList.getTotalPages())
.totalElements(photoList.getTotalElements())
.listSize(photoInfoList.size())
.photoInfoList(photoInfoList)
.build();
}
Expand All @@ -62,7 +61,7 @@ public PhotoResponse.PhotoInfo toPhotoInfo(Photo photo) {
.photoUrl(photo.getUrl())
.photoName(photo.getName())
.resizedPhotoName(convertExtension(photo.getName()))
.uploadTime(photo.getCreatedAt())
.createdAt(photo.getCreatedAt())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ public static class PhotoUploadInfo {
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class PhotoListInfo {
public static class PagedPhotoInfo {
private List<PhotoInfo> photoInfoList;
Integer listSize;
Integer totalPage;
Long totalElements;
Boolean isFirst;
Expand All @@ -58,6 +57,6 @@ public static class PhotoInfo {
private String photoUrl;
private String photoName;
private String resizedPhotoName;
private LocalDateTime uploadTime;
private LocalDateTime createdAt;
}
}

0 comments on commit 544915b

Please sign in to comment.