Skip to content

Commit

Permalink
[feat] 회원 프로필 API에 위치 정보 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ksj000625 committed Dec 8, 2024
1 parent 89e7600 commit 687e53b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public class ProfileResponse {
@Enumerated(EnumType.STRING)
@Schema(description = "소셜 로그인 제공사", example = "KAKAO")
private Provider provider;
@Schema(description = "유저 위치 정보")
private LocationResponse location;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -44,8 +47,9 @@ public ProfileResponse getProfileInfo() {
public ProfileResponse getProfileInfo(String userId) {
Optional<UserJpaEntity> user = userRepository.findById(userId);
Optional<UserIdentityJpaEntity> userIdentity = userIdentityRepository.findById(userId);
Optional<UserLocationJpaEntity> userLocation = userLocationReposity.findById(userId);

if (user.isEmpty() || userIdentity.isEmpty()) {
if (user.isEmpty() || userIdentity.isEmpty() || userLocation.isEmpty()) {
throw new CustomException(ErrorCode.NotFound, "회원을 찾을 수 없습니다.", HttpStatus.NOT_FOUND);
}

Expand All @@ -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();
}

Expand Down

0 comments on commit 687e53b

Please sign in to comment.