Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ public ResponseEntity<Void> deletePhoto(

@GetMapping("/{albumId}/photos")
public ResponseEntity<AlbumPhotoItemsResponse> getAlbumItems(
@PathVariable Long albumId,
@PageableDefault Pageable pageable
@PathVariable Long albumId
) {
return ResponseEntity.ok(albumService.getAlbumPhotoItems(albumId, pageable));
return ResponseEntity.ok(albumService.getAlbumPhotoItems(albumId));
}

@PostMapping("/{albumId}/photos")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import java.time.LocalDateTime;
import java.util.List;
import kr.kro.photoliner.domain.album.dto.AlbumPhotoItem;
import org.springframework.data.domain.Page;

public record AlbumPhotoItemsResponse(
List<InnerAlbumPhotoItem> items
) {

public static AlbumPhotoItemsResponse from(Page<AlbumPhotoItem> albumPhotoViews) {
public static AlbumPhotoItemsResponse from(List<AlbumPhotoItem> albumPhotoItems) {
return new AlbumPhotoItemsResponse(
albumPhotoViews.stream()
albumPhotoItems.stream()
.map(InnerAlbumPhotoItem::from)
.toList()
);
Expand All @@ -23,7 +22,9 @@ public record InnerAlbumPhotoItem(
String fileName,
String filePath,
String thumbnailPath,
LocalDateTime capturedDt
LocalDateTime capturedDt,
Double latitude,
Double longitude
) {

public static InnerAlbumPhotoItem from(AlbumPhotoItem albumPhotoItem) {
Expand All @@ -33,7 +34,9 @@ public static InnerAlbumPhotoItem from(AlbumPhotoItem albumPhotoItem) {
albumPhotoItem.fileName(),
albumPhotoItem.filePath(),
albumPhotoItem.thumbnailPath(),
albumPhotoItem.capturedDt()
albumPhotoItem.capturedDt(),
albumPhotoItem.getLatitude(),
albumPhotoItem.getLongitude()
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import kr.kro.photoliner.domain.album.dto.AlbumPhotoItems;
import kr.kro.photoliner.domain.album.model.PhotoItem;
import org.locationtech.jts.geom.Point;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

Expand All @@ -25,7 +23,7 @@ public interface AlbumPhotoRepository extends JpaRepository<PhotoItem, Long> {
inner join Photo p on p.id = pi.photoId
where pi.album.id = :albumId
""")
Page<AlbumPhotoItem> findByAlbumId(Long albumId, Pageable pageable);
List<AlbumPhotoItem> findByAlbumId(Long albumId);

@Query("""
select new kr.kro.photoliner.domain.album.dto.AlbumPhotoItem(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.kro.photoliner.domain.album.service;

import java.util.List;
import kr.kro.photoliner.domain.album.dto.AlbumPhotoItem;
import kr.kro.photoliner.domain.album.dto.AlbumPhotoItems;
import kr.kro.photoliner.domain.album.dto.request.AlbumCreateRequest;
Expand Down Expand Up @@ -55,8 +56,8 @@ public AlbumsResponse getAlbums(Long userId, Pageable pageable) {
}

@Transactional(readOnly = true)
public AlbumPhotoItemsResponse getAlbumPhotoItems(Long albumId, Pageable pageable) {
Page<AlbumPhotoItem> albumPhotoItems = albumPhotoRepository.findByAlbumId(albumId, pageable);
public AlbumPhotoItemsResponse getAlbumPhotoItems(Long albumId) {
List<AlbumPhotoItem> albumPhotoItems = albumPhotoRepository.findByAlbumId(albumId);
return AlbumPhotoItemsResponse.from(albumPhotoItems);
}

Expand Down
Loading