From 687e53b9edb2948431bfb621fb21cff359512e4b Mon Sep 17 00:00:00 2001 From: ksj000625 Date: Sun, 8 Dec 2024 22:21:26 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=ED=9A=8C=EC=9B=90=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20API=EC=97=90=20=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/users/dto/response/LocationResponse.java | 16 ++++++++++++++++ .../api/users/dto/response/ProfileResponse.java | 2 ++ .../api/users/service/UserServiceImpl.java | 11 ++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/main/java/site/billbill/apiserver/api/users/dto/response/LocationResponse.java diff --git a/src/main/java/site/billbill/apiserver/api/users/dto/response/LocationResponse.java b/src/main/java/site/billbill/apiserver/api/users/dto/response/LocationResponse.java new file mode 100644 index 0000000..5aff2a6 --- /dev/null +++ b/src/main/java/site/billbill/apiserver/api/users/dto/response/LocationResponse.java @@ -0,0 +1,16 @@ +package site.billbill.apiserver.api.users.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class LocationResponse { + @Schema(description = "주소", example = "서울특별시 강남구") + private String address; + @Schema(description = "위도", example = "127.423084873712") + private double latitude; + @Schema(description = "경도", example = "37.0789561558879") + private double longitude; +} diff --git a/src/main/java/site/billbill/apiserver/api/users/dto/response/ProfileResponse.java b/src/main/java/site/billbill/apiserver/api/users/dto/response/ProfileResponse.java index 453ffea..d4e8336 100644 --- a/src/main/java/site/billbill/apiserver/api/users/dto/response/ProfileResponse.java +++ b/src/main/java/site/billbill/apiserver/api/users/dto/response/ProfileResponse.java @@ -21,4 +21,6 @@ public class ProfileResponse { @Enumerated(EnumType.STRING) @Schema(description = "소셜 로그인 제공사", example = "KAKAO") private Provider provider; + @Schema(description = "유저 위치 정보") + private LocationResponse location; } diff --git a/src/main/java/site/billbill/apiserver/api/users/service/UserServiceImpl.java b/src/main/java/site/billbill/apiserver/api/users/service/UserServiceImpl.java index 974c199..36f0fef 100644 --- a/src/main/java/site/billbill/apiserver/api/users/service/UserServiceImpl.java +++ b/src/main/java/site/billbill/apiserver/api/users/service/UserServiceImpl.java @@ -15,9 +15,11 @@ import site.billbill.apiserver.model.user.UserBlacklistJpaEntity; import site.billbill.apiserver.model.user.UserIdentityJpaEntity; import site.billbill.apiserver.model.user.UserJpaEntity; +import site.billbill.apiserver.model.user.UserLocationJpaEntity; import site.billbill.apiserver.repository.borrowPosts.ItemsRepository; import site.billbill.apiserver.repository.user.UserBlacklistRepository; import site.billbill.apiserver.repository.user.UserIdentityRepository; +import site.billbill.apiserver.repository.user.UserLocationReposity; import site.billbill.apiserver.repository.user.UserRepository; import java.util.List; @@ -32,6 +34,7 @@ public class UserServiceImpl implements UserService { private final UserBlacklistRepository userBlacklistRepository; private final ItemsRepository itemsRepository; private final JWTUtil jWTUtil; + private final UserLocationReposity userLocationReposity; @Override public ProfileResponse getProfileInfo() { @@ -44,8 +47,9 @@ public ProfileResponse getProfileInfo() { public ProfileResponse getProfileInfo(String userId) { Optional user = userRepository.findById(userId); Optional userIdentity = userIdentityRepository.findById(userId); + Optional userLocation = userLocationReposity.findById(userId); - if (user.isEmpty() || userIdentity.isEmpty()) { + if (user.isEmpty() || userIdentity.isEmpty() || userLocation.isEmpty()) { throw new CustomException(ErrorCode.NotFound, "회원을 찾을 수 없습니다.", HttpStatus.NOT_FOUND); } @@ -55,6 +59,11 @@ public ProfileResponse getProfileInfo(String userId) { .nickname(user.get().getNickname()) .phoneNumber(userIdentity.get().getPhoneNumber()) .provider(user.get().getProvider()) + .location(LocationResponse.builder() + .address(userLocation.get().getAddress()) + .longitude(userLocation.get().getLongitude()) + .latitude(userLocation.get().getLatitude()) + .build()) .build(); }