From dd452c67f9b9a54a98a37af716eabb0212b24614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=9D=B8=ED=99=94?= Date: Sun, 23 Nov 2025 18:40:42 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=82=AC=EC=A7=84=20=ED=95=84=ED=84=B0?= =?UTF-8?q?=EB=A7=81=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/photo/controller/PhotoController.java | 4 +++- .../domain/photo/repository/PhotoRepository.java | 11 ++++++++++- .../photoliner/domain/photo/service/PhotoService.java | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/kr/kro/photoliner/domain/photo/controller/PhotoController.java b/src/main/java/kr/kro/photoliner/domain/photo/controller/PhotoController.java index 8727e31..59f8c8c 100644 --- a/src/main/java/kr/kro/photoliner/domain/photo/controller/PhotoController.java +++ b/src/main/java/kr/kro/photoliner/domain/photo/controller/PhotoController.java @@ -40,9 +40,11 @@ public class PhotoController { @GetMapping public ResponseEntity getPhotos( @RequestParam Long userId, + @RequestParam(required = false) Boolean hasLocation, + @RequestParam(required = false) Boolean hasCapturedDate, @PageableDefault(sort = "capturedDt", direction = Sort.Direction.DESC) Pageable pageable ) { - return ResponseEntity.ok(photoService.getPhotosByIds(userId, pageable)); + return ResponseEntity.ok(photoService.getPhotosByIds(userId, hasLocation, hasCapturedDate, pageable)); } @GetMapping("/markers") diff --git a/src/main/java/kr/kro/photoliner/domain/photo/repository/PhotoRepository.java b/src/main/java/kr/kro/photoliner/domain/photo/repository/PhotoRepository.java index 7b82616..67a519d 100644 --- a/src/main/java/kr/kro/photoliner/domain/photo/repository/PhotoRepository.java +++ b/src/main/java/kr/kro/photoliner/domain/photo/repository/PhotoRepository.java @@ -12,8 +12,17 @@ public interface PhotoRepository extends JpaRepository { - Page findByUserId( + @Query(""" + select p + from Photo p + where p.userId = :userId + and (:hasLocation is null or (:hasLocation = true and p.location is not null) or (:hasLocation = false and p.location is null)) + and (:hasCapturedDate is null or (:hasCapturedDate = true and p.capturedDt is not null) or (:hasCapturedDate = false and p.capturedDt is null)) + """) + Page findByUserIdWithFilters( Long userId, + Boolean hasLocation, + Boolean hasCapturedDate, Pageable pageable ); diff --git a/src/main/java/kr/kro/photoliner/domain/photo/service/PhotoService.java b/src/main/java/kr/kro/photoliner/domain/photo/service/PhotoService.java index 9414be8..fbc520a 100644 --- a/src/main/java/kr/kro/photoliner/domain/photo/service/PhotoService.java +++ b/src/main/java/kr/kro/photoliner/domain/photo/service/PhotoService.java @@ -38,8 +38,9 @@ public class PhotoService { private static final String THUMBNAIL_BASE_PATH = "/images/thumb/"; @Transactional(readOnly = true) - public PhotosResponse getPhotosByIds(Long userId, Pageable pageable) { - return PhotosResponse.from(photoRepository.findByUserId(userId, pageable)); + public PhotosResponse getPhotosByIds(Long userId, Boolean hasLocation, Boolean hasCapturedDate, Pageable pageable) { + return PhotosResponse.from( + photoRepository.findByUserIdWithFilters(userId, hasLocation, hasCapturedDate, pageable)); } @Transactional(readOnly = true)