From a56825ec2f84912faddcc1ffc5e0e9a2645bf8ed Mon Sep 17 00:00:00 2001 From: hong seokho Date: Mon, 6 May 2024 10:39:47 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20?= =?UTF-8?q?=EB=A8=B8=EC=A7=80=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic_capsule/api/CapsuleApi.java | 81 +++++++++++++++++-- .../api/CapsuleApiController.java | 54 ++++++++++++- .../fixture/{ => domain}/GroupFixture.java | 2 +- .../{ => domain}/MemberGroupFixture.java | 2 +- .../GroupCapsuleQueryRepositoryTest.java | 4 +- 5 files changed, 129 insertions(+), 14 deletions(-) rename backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/{ => domain}/GroupFixture.java (88%) rename backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/{ => domain}/MemberGroupFixture.java (90%) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApi.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApi.java index 5e7553d6d..f8ea94237 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApi.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApi.java @@ -8,7 +8,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.hibernate.validator.constraints.Range; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import site.timecapsulearchive.core.domain.capsule.entity.CapsuleType; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.CapsuleOpenedResponse; import site.timecapsulearchive.core.domain.capsule.generic_capsule.data.response.ImagesPageResponse; @@ -17,6 +19,7 @@ import site.timecapsulearchive.core.global.common.response.ApiSpec; import site.timecapsulearchive.core.global.error.ErrorResponse; +@Validated public interface CapsuleApi { @Operation( @@ -55,14 +58,16 @@ ResponseEntity getImages( description = "잘못된 요청 파라미터에 의해 발생" ) }) - ResponseEntity> getNearbyARCapsules( + ResponseEntity> getARNearbyMyCapsules( Long memberId, @Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true) - double longitude, + @Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.") + double latitude, @Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true) - double latitude, + @Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.") + double longitude, @Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true) double distance, @@ -87,14 +92,16 @@ ResponseEntity> getNearbyARCapsules( description = "잘못된 요청 파라미터에 의해 발생" ) }) - ResponseEntity> getNearbyCapsules( + ResponseEntity> getMapNearbyMyCapsules( Long memberId, @Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true) - double longitude, + @Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.") + double latitude, @Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true) - double latitude, + @Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.") + double longitude, @Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true) double distance, @@ -103,6 +110,68 @@ ResponseEntity> getNearbyCapsules( CapsuleType capsuleType ); + @Operation( + summary = "현재 사용자 위치 기준으로 사용자의 친구들의 지도용 캡슐 목록 조회", + description = "지도에서 캡슐을 보기 위해 현재 사용자 위치를 바탕으로 반경 distance km만큼 친구들의 캡슐을 조회한다.", + security = {@SecurityRequirement(name = "user_token")}, + tags = {"capsule"} + ) + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "처리 완료" + ), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청 파라미터에 의해 발생" + ) + }) + ResponseEntity> getMapNearbyFriendsCapsules( + Long memberId, + + @Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true) + @Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.") + double latitude, + + @Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true) + @Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.") + double longitude, + + @Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true) + double distance + ); + + @Operation( + summary = "현재 사용자 위치 기준으로 사용자의 친구들의 AR용 캡슐 목록 조회", + description = "AR 카메라로 캡슐을 보기 위해 현재 사용자 위치를 바탕으로 반경 distance km만큼 친구들의 캡슐을 조회한다.", + security = {@SecurityRequirement(name = "user_token")}, + tags = {"capsule"} + ) + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "처리 완료" + ), + @ApiResponse( + responseCode = "400", + description = "잘못된 요청 파라미터에 의해 발생" + ) + }) + ResponseEntity> getARNearbyFriendsCapsules( + Long memberId, + + @Parameter(in = ParameterIn.QUERY, description = "위도(wsg84)", required = true) + @Range(min = -90, max = 90, message = "위도는 -90과 90 사이여야 합니다.") + double latitude, + + @Parameter(in = ParameterIn.QUERY, description = "경도(wsg84)", required = true) + @Range(min = -180, max = 180, message = "경도는 -180과 180 사이여야 합니다.") + double longitude, + + @Parameter(in = ParameterIn.QUERY, description = "조회 거리(km)", required = true) + double distance + ); + @Operation( summary = "캡슐 열람 상태로 변경", description = "캡슐을 열람 상태를 변경해준다.", diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApiController.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApiController.java index c7ed509e4..eef579899 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApiController.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/generic_capsule/api/CapsuleApiController.java @@ -41,9 +41,9 @@ public ResponseEntity getImages(final Long size, final Long return null; } - @GetMapping(value = "/nearby/ar", produces = {"application/json"}) + @GetMapping(value = "/my/ar/nearby", produces = {"application/json"}) @Override - public ResponseEntity> getNearbyARCapsules( + public ResponseEntity> getARNearbyMyCapsules( @AuthenticationPrincipal final Long memberId, @RequestParam(value = "latitude") final double latitude, @RequestParam(value = "longitude") final double longitude, @@ -68,9 +68,9 @@ public ResponseEntity> getNearbyARCapsules( ); } - @GetMapping(value = "/nearby", produces = {"application/json"}) + @GetMapping(value = "/my/map/nearby", produces = {"application/json"}) @Override - public ResponseEntity> getNearbyCapsules( + public ResponseEntity> getMapNearbyMyCapsules( @AuthenticationPrincipal final Long memberId, @RequestParam(value = "latitude") final double latitude, @RequestParam(value = "longitude") final double longitude, @@ -91,6 +91,52 @@ public ResponseEntity> getNearbyCapsules( ); } + @GetMapping(value = "/friends/map/nearby", produces = {"application/json"}) + @Override + public ResponseEntity> getMapNearbyFriendsCapsules( + @AuthenticationPrincipal final Long memberId, + @RequestParam(value = "latitude") final double latitude, + @RequestParam(value = "longitude") final double longitude, + @RequestParam(value = "distance") final double distance + ) { + final List capsules = capsuleService.findFriendsCapsulesByCurrentLocation( + memberId, + CoordinateRangeDto.from(latitude, longitude, distance) + ); + + return ResponseEntity.ok( + ApiSpec.success( + SuccessCode.SUCCESS, + NearbyCapsuleResponse.createOf(capsules, geoTransformManager::changePoint3857To4326) + ) + ); + } + + @GetMapping(value = "/friends/ar/nearby", produces = {"application/json"}) + @Override + public ResponseEntity> getARNearbyFriendsCapsules( + @AuthenticationPrincipal final Long memberId, + @RequestParam(value = "latitude") final double latitude, + @RequestParam(value = "longitude") final double longitude, + @RequestParam(value = "distance") final double distance + ) { + final List capsules = capsuleService.findFriendsARCapsulesByCurrentLocation( + memberId, + CoordinateRangeDto.from(latitude, longitude, distance) + ); + + return ResponseEntity.ok( + ApiSpec.success( + SuccessCode.SUCCESS, + NearbyARCapsuleResponse.createOf( + capsules, + geoTransformManager::changePoint3857To4326, + s3PreSignedUrlManager::getS3PreSignedUrlForGet + ) + ) + ); + } + @PatchMapping(value = "/{capsule_id}/opened", produces = {"application/json"}) @Override public ResponseEntity> updateCapsuleOpened( diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/GroupFixture.java b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupFixture.java similarity index 88% rename from backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/GroupFixture.java rename to backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupFixture.java index 200790db7..73d9fafb7 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/GroupFixture.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/GroupFixture.java @@ -1,4 +1,4 @@ -package site.timecapsulearchive.core.common.fixture; +package site.timecapsulearchive.core.common.fixture.domain; import site.timecapsulearchive.core.domain.group.entity.Group; diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/MemberGroupFixture.java b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberGroupFixture.java similarity index 90% rename from backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/MemberGroupFixture.java rename to backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberGroupFixture.java index 6c79050ae..a4fa04741 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/MemberGroupFixture.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/common/fixture/domain/MemberGroupFixture.java @@ -1,4 +1,4 @@ -package site.timecapsulearchive.core.common.fixture; +package site.timecapsulearchive.core.common.fixture.domain; import site.timecapsulearchive.core.domain.group.entity.Group; import site.timecapsulearchive.core.domain.group.entity.MemberGroup; diff --git a/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepositoryTest.java b/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepositoryTest.java index de850c081..46beb15b1 100644 --- a/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepositoryTest.java +++ b/backend/core/src/test/java/site/timecapsulearchive/core/domain/capsule/group_capsule/repository/GroupCapsuleQueryRepositoryTest.java @@ -14,8 +14,8 @@ import org.springframework.test.context.TestConstructor.AutowireMode; import org.springframework.transaction.annotation.Transactional; import site.timecapsulearchive.core.common.RepositoryTest; -import site.timecapsulearchive.core.common.fixture.GroupFixture; -import site.timecapsulearchive.core.common.fixture.MemberGroupFixture; +import site.timecapsulearchive.core.common.fixture.domain.GroupFixture; +import site.timecapsulearchive.core.common.fixture.domain.MemberGroupFixture; import site.timecapsulearchive.core.common.fixture.domain.CapsuleFixture; import site.timecapsulearchive.core.common.fixture.domain.CapsuleSkinFixture; import site.timecapsulearchive.core.common.fixture.domain.MemberFixture;