From 7291b753815026c8345e61796c7225de7aa0ae62 Mon Sep 17 00:00:00 2001 From: CYY1007 Date: Tue, 15 Jul 2025 17:48:24 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/places/business/PlacesMapper.java | 4 +++ .../api/places/business/PlacesService.java | 26 ++++++++++++++++ .../implementation/PlacesCommandAdapter.java | 9 ++++++ .../implementation/PlacesQueryAdapter.java | 9 ++++++ .../api/places/presentation/PlacesApi.java | 30 +++++++++++++++++++ .../places/presentation/dto/PlacesDto.java | 28 +++++++++++++++++ .../api/user/business/UserService.java | 13 ++++++++ .../feign/client/GoogleNearByFeignClient.java | 12 ++++++++ .../config/GoggleFeignConfiguration.java | 18 +++++++++++ src/main/resources/application.yml | 7 +++++ 10 files changed, 156 insertions(+) create mode 100644 src/main/java/rootbox/rootboxApp/api/places/business/PlacesMapper.java create mode 100644 src/main/java/rootbox/rootboxApp/api/places/business/PlacesService.java create mode 100644 src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesCommandAdapter.java create mode 100644 src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesQueryAdapter.java create mode 100644 src/main/java/rootbox/rootboxApp/api/places/presentation/PlacesApi.java create mode 100644 src/main/java/rootbox/rootboxApp/api/places/presentation/dto/PlacesDto.java create mode 100644 src/main/java/rootbox/rootboxApp/global/feign/client/GoogleNearByFeignClient.java create mode 100644 src/main/java/rootbox/rootboxApp/global/feign/config/GoggleFeignConfiguration.java diff --git a/src/main/java/rootbox/rootboxApp/api/places/business/PlacesMapper.java b/src/main/java/rootbox/rootboxApp/api/places/business/PlacesMapper.java new file mode 100644 index 0000000..42a730c --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/api/places/business/PlacesMapper.java @@ -0,0 +1,4 @@ +package rootbox.rootboxApp.api.places.business; + +public class PlacesMapper { +} diff --git a/src/main/java/rootbox/rootboxApp/api/places/business/PlacesService.java b/src/main/java/rootbox/rootboxApp/api/places/business/PlacesService.java new file mode 100644 index 0000000..5d3a0d3 --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/api/places/business/PlacesService.java @@ -0,0 +1,26 @@ +package rootbox.rootboxApp.api.places.business; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import rootbox.rootboxApp.api.places.implementation.PlacesCommandAdapter; +import rootbox.rootboxApp.api.places.implementation.PlacesQueryAdapter; +import rootbox.rootboxApp.api.places.presentation.dto.PlacesDto; + +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +public class PlacesService { + + private final PlacesQueryAdapter placesQueryAdapter; + + private final PlacesCommandAdapter placesCommandAdapter; + + public List getNearByPlaces(double latitude, double longitude + ,String category, Integer radius, Integer size, String nextPageToken) { + + return null; + } +} diff --git a/src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesCommandAdapter.java b/src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesCommandAdapter.java new file mode 100644 index 0000000..c11a791 --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesCommandAdapter.java @@ -0,0 +1,9 @@ +package rootbox.rootboxApp.api.places.implementation; + +import lombok.extern.slf4j.Slf4j; +import rootbox.rootboxApp.global.annotations.Adapter; + +@Slf4j +@Adapter +public class PlacesCommandAdapter { +} diff --git a/src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesQueryAdapter.java b/src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesQueryAdapter.java new file mode 100644 index 0000000..ac4238d --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/api/places/implementation/PlacesQueryAdapter.java @@ -0,0 +1,9 @@ +package rootbox.rootboxApp.api.places.implementation; + +import lombok.extern.slf4j.Slf4j; +import rootbox.rootboxApp.global.annotations.Adapter; + +@Slf4j +@Adapter +public class PlacesQueryAdapter { +} diff --git a/src/main/java/rootbox/rootboxApp/api/places/presentation/PlacesApi.java b/src/main/java/rootbox/rootboxApp/api/places/presentation/PlacesApi.java new file mode 100644 index 0000000..7908ee9 --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/api/places/presentation/PlacesApi.java @@ -0,0 +1,30 @@ +package rootbox.rootboxApp.api.places.presentation; + +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import rootbox.rootboxApp.api.places.business.PlacesService; +import rootbox.rootboxApp.api.places.presentation.dto.PlacesDto; +import rootbox.rootboxApp.global.common.CommonResponse; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/places") +public class PlacesApi { + + private final PlacesService placesService; + + @GetMapping("/") + public CommonResponse> getNearByPlaces(@RequestParam(required = false) Integer radius + , @RequestParam(required = false) Integer size, @RequestParam(required = false) String nextPageToken + , @RequestParam(required = true) String category + , @RequestParam(required = true) double lat + , @RequestParam(required = true) double lng) { + return CommonResponse.onSuccess(placesService.getNearByPlaces(lat,lng,category,radius,size,nextPageToken)); + } + +} diff --git a/src/main/java/rootbox/rootboxApp/api/places/presentation/dto/PlacesDto.java b/src/main/java/rootbox/rootboxApp/api/places/presentation/dto/PlacesDto.java new file mode 100644 index 0000000..5f4d318 --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/api/places/presentation/dto/PlacesDto.java @@ -0,0 +1,28 @@ +package rootbox.rootboxApp.api.places.presentation.dto; + +import lombok.*; + +import java.util.List; + +public class PlacesDto { + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + @Builder + public static class NearByPlaceDto { + + private String placeName; + + private Float latitude; + + private Float longitude; + + private String openTime; + + private Boolean isOpen; + + private List photoList; + } +} diff --git a/src/main/java/rootbox/rootboxApp/api/user/business/UserService.java b/src/main/java/rootbox/rootboxApp/api/user/business/UserService.java index cfba60b..add1e49 100644 --- a/src/main/java/rootbox/rootboxApp/api/user/business/UserService.java +++ b/src/main/java/rootbox/rootboxApp/api/user/business/UserService.java @@ -52,6 +52,19 @@ public SocialLoginDto.KakaoSocialLoginResponseDto socialLogin(SocialLoginDto.Kak // 로그인 처리 if (userBySocialId.isPresent()) { + User user = userBySocialId.get(); + if (user.getNickname() ==null){ + String accessToken = tokenProvider.createAccessToken(user, List.of(new SimpleGrantedAuthority(UserRole.USER.name()))); + return SocialLoginDto.KakaoSocialLoginResponseDto + .builder() + .loginType(SocialType.KAKAO.name()) + .isNew(true) + .accessToken(accessToken) + .refreshToken(userCommandAdapter.saveRefreshToken(tokenProvider.createRefreshToken(), + user.getSocialLoginUid()).getRefreshToken()) + .userSocialId(user.getSocialLoginUid()) + .build(); + } Optional refreshTokenByUserId = userQueryAdapter.findRefreshTokenByUserId(kakaoUserInfo.getId()); String accessToken = tokenProvider.createAccessToken(userBySocialId.get(), List.of(new SimpleGrantedAuthority(UserRole.USER.name()))); diff --git a/src/main/java/rootbox/rootboxApp/global/feign/client/GoogleNearByFeignClient.java b/src/main/java/rootbox/rootboxApp/global/feign/client/GoogleNearByFeignClient.java new file mode 100644 index 0000000..41a5d71 --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/global/feign/client/GoogleNearByFeignClient.java @@ -0,0 +1,12 @@ +package rootbox.rootboxApp.global.feign.client; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import rootbox.rootboxApp.global.feign.config.KakaoFeignConfiguration; + +@FeignClient(name = "GoogleNearByFeignClient", url = "${oauth.google.baseUrl}", configuration = GoogleNearByFeignClient.class) +@Component +public interface GoogleNearByFeignClient { + + +} diff --git a/src/main/java/rootbox/rootboxApp/global/feign/config/GoggleFeignConfiguration.java b/src/main/java/rootbox/rootboxApp/global/feign/config/GoggleFeignConfiguration.java new file mode 100644 index 0000000..c87ff83 --- /dev/null +++ b/src/main/java/rootbox/rootboxApp/global/feign/config/GoggleFeignConfiguration.java @@ -0,0 +1,18 @@ +package rootbox.rootboxApp.global.feign.config; + +import feign.Logger; +import feign.codec.ErrorDecoder; +import org.springframework.context.annotation.Bean; +import rootbox.rootboxApp.global.feign.exception.FeignClientExceptionErrorDecoder; + +public class GoggleFeignConfiguration { + @Bean + public ErrorDecoder errorDecoder() { + return new FeignClientExceptionErrorDecoder(); + } + + @Bean + Logger.Level feignLoggerLevel() { + return Logger.Level.FULL; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 30d2a7e..df8f73e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -83,6 +83,10 @@ oauth: clientId: ${KAKAO_CLIENT_ID} redirectUrl : ${KAKAO_REDIRECT_URL} secretKeyREST: ${KAKAO_SECRET_REST} + google: + baseUrl : ${GOOGLE_BASE_URL} + apiKey : ${GOOGLE_API_KEY} + #cloud: # aws: @@ -150,6 +154,9 @@ oauth: clientId: ${KAKAO_REST_KEY} redirectUrl : ${KAKAO_REDIRECT_URL} secretKeyREST: ${KAKAO_SECRET_REST} + google: + baseUrl : ${GOOGLE_BASE_URL} + apiKey : ${GOOGLE_API_KEY} #firebase: # admin-sdk: ${FCM_KEY}