-
Notifications
You must be signed in to change notification settings - Fork 1
fix: 지도 기반 마커 조회 API 요청 시 NPE 오류 해결 #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
src/main/java/kr/kro/photoliner/domain/album/dto/AlbumPhotoItem.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package kr.kro.photoliner.domain.album.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.Objects; | ||
| import org.locationtech.jts.geom.Point; | ||
|
|
||
| public record AlbumPhotoItem( | ||
| Long id, | ||
| Long photoId, | ||
| String fileName, | ||
| String filePath, | ||
| String thumbnailPath, | ||
| LocalDateTime capturedDt, | ||
| Point location | ||
| ) { | ||
|
|
||
| public Double getLatitude() { | ||
| if (Objects.isNull(location)) { | ||
| return null; | ||
| } | ||
| return location.getY(); | ||
| } | ||
|
|
||
| public Double getLongitude() { | ||
| if (Objects.isNull(location)) { | ||
| return null; | ||
| } | ||
| return location.getX(); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
src/main/java/kr/kro/photoliner/domain/album/dto/AlbumPhotoItems.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package kr.kro.photoliner.domain.album.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record AlbumPhotoItems( | ||
| List<AlbumPhotoItem> photoItems | ||
| ) { | ||
|
|
||
| public int count() { | ||
| return photoItems.size(); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
src/main/java/kr/kro/photoliner/domain/album/dto/request/AlbumPhotoMarkersRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package kr.kro.photoliner.domain.album.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.Min; | ||
| import org.locationtech.jts.geom.Coordinate; | ||
|
|
||
| public record AlbumPhotoMarkersRequest( | ||
| @Min(0) @Max(90) | ||
| double swLat, | ||
|
|
||
| @Min(0) @Max(180) | ||
| double swLng, | ||
|
|
||
| @Min(0) @Max(90) | ||
| double neLat, | ||
|
|
||
| @Min(0) @Max(180) | ||
| double neLng | ||
| ) { | ||
| public Coordinate getSouthWestCoordinate() { | ||
| return new Coordinate(swLng, swLat); | ||
| } | ||
|
|
||
| public Coordinate getNorthEastCoordinate() { | ||
| return new Coordinate(neLng, neLat); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
src/main/java/kr/kro/photoliner/domain/album/dto/response/AlbumPhotoMarkersResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package kr.kro.photoliner.domain.album.dto.response; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
| import kr.kro.photoliner.domain.album.dto.AlbumPhotoItem; | ||
| import kr.kro.photoliner.domain.album.dto.AlbumPhotoItems; | ||
|
|
||
| public record AlbumPhotoMarkersResponse( | ||
| Integer count, | ||
| List<InnerAlbumPhotoMarker> albumPhotoMarkers | ||
| ) { | ||
|
|
||
| public static AlbumPhotoMarkersResponse from(AlbumPhotoItems albumPhotoItems) { | ||
| return new AlbumPhotoMarkersResponse( | ||
| albumPhotoItems.count(), | ||
| albumPhotoItems.photoItems().stream() | ||
| .map(InnerAlbumPhotoMarker::from) | ||
| .toList() | ||
| ); | ||
| } | ||
|
|
||
| public record InnerAlbumPhotoMarker( | ||
| Long id, | ||
| Long photoId, | ||
| String filePath, | ||
| String thumbnailPath, | ||
| LocalDateTime capturedDt, | ||
| Double lat, | ||
| Double lng | ||
| ) { | ||
|
|
||
| public static InnerAlbumPhotoMarker from(AlbumPhotoItem albumPhotoItem) { | ||
| return new InnerAlbumPhotoMarker( | ||
| albumPhotoItem.id(), | ||
| albumPhotoItem.photoId(), | ||
| albumPhotoItem.filePath(), | ||
| albumPhotoItem.thumbnailPath(), | ||
| albumPhotoItem.capturedDt(), | ||
| albumPhotoItem.getLatitude(), | ||
| albumPhotoItem.getLongitude() | ||
| ); | ||
| } | ||
| } | ||
| } |
59 changes: 0 additions & 59 deletions
src/main/java/kr/kro/photoliner/domain/album/model/view/AlbumPhotoView.java
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
src/main/java/kr/kro/photoliner/domain/album/model/view/AlbumPhotoViews.java
Oops, something went wrong.
52 changes: 38 additions & 14 deletions
src/main/java/kr/kro/photoliner/domain/album/repository/AlbumPhotoRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,54 @@ | ||
| package kr.kro.photoliner.domain.album.repository; | ||
|
|
||
| import java.util.List; | ||
| import kr.kro.photoliner.domain.album.model.view.AlbumPhotoView; | ||
| import kr.kro.photoliner.domain.album.model.view.AlbumPhotoViews; | ||
| import kr.kro.photoliner.domain.album.dto.AlbumPhotoItem; | ||
| 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; | ||
|
|
||
| public interface AlbumPhotoRepository extends JpaRepository<AlbumPhotoView, Long> { | ||
| Page<AlbumPhotoView> findByAlbumId(Long albumId, Pageable pageable); | ||
| public interface AlbumPhotoRepository extends JpaRepository<PhotoItem, Long> { | ||
| @Query(""" | ||
| select new kr.kro.photoliner.domain.album.dto.AlbumPhotoItem( | ||
| pi.id, | ||
| pi.photoId, | ||
| p.fileName, | ||
| p.filePath, | ||
| p.thumbnailPath, | ||
| p.capturedDt, | ||
| p.location | ||
| ) | ||
| from PhotoItem pi | ||
| inner join Photo p on p.id = pi.photoId | ||
| where pi.album.id = :albumId | ||
| """) | ||
| Page<AlbumPhotoItem> findByAlbumId(Long albumId, Pageable pageable); | ||
|
|
||
| @Query(""" | ||
| select apv | ||
| from AlbumPhotoView apv | ||
| where apv.userId = :userId | ||
| and function('st_x', apv.location) between function('st_x', :sw) and function('st_x', :ne) | ||
| and function('st_y', apv.location) between function('st_y', :sw) and function('st_y', :ne) | ||
| order by apv.capturedDt desc | ||
| select new kr.kro.photoliner.domain.album.dto.AlbumPhotoItem( | ||
| pi.id, | ||
| pi.photoId, | ||
| p.fileName, | ||
| p.filePath, | ||
| p.thumbnailPath, | ||
| p.capturedDt, | ||
| p.location | ||
| ) | ||
| from PhotoItem pi | ||
| inner join Photo p on p.id = pi.photoId | ||
| where pi.album.id = :albumId | ||
| and function('st_x', p.location) between function('st_x', :sw) and function('st_x', :ne) | ||
| and function('st_y', p.location) between function('st_y', :sw) and function('st_y', :ne) | ||
| order by p.capturedDt | ||
| """) | ||
| List<AlbumPhotoView> findByUserIdInBox(Long userId, Point sw, Point ne); | ||
| List<AlbumPhotoItem> findByAlbumIdInBox(Long albumId, Point sw, Point ne); | ||
|
|
||
| default AlbumPhotoViews getByUserIdInBox(Long userId, Point sw, Point ne) { | ||
| return new AlbumPhotoViews( | ||
| findByUserIdInBox(userId, sw, ne) | ||
| default AlbumPhotoItems getByAlbumIdInBox(Long albumId, Point sw, Point ne) { | ||
| return new AlbumPhotoItems( | ||
| findByAlbumIdInBox(albumId, sw, ne) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.