Skip to content

Commit 8565cae

Browse files
authored
Merge pull request #19 from Route-Box/issue14
사용자 닉네임 체크
2 parents 42b5f0e + 7291b75 commit 8565cae

10 files changed

Lines changed: 156 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package rootbox.rootboxApp.api.places.business;
2+
3+
public class PlacesMapper {
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package rootbox.rootboxApp.api.places.business;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import lombok.extern.slf4j.Slf4j;
5+
import org.springframework.stereotype.Service;
6+
import rootbox.rootboxApp.api.places.implementation.PlacesCommandAdapter;
7+
import rootbox.rootboxApp.api.places.implementation.PlacesQueryAdapter;
8+
import rootbox.rootboxApp.api.places.presentation.dto.PlacesDto;
9+
10+
import java.util.List;
11+
12+
@Slf4j
13+
@Service
14+
@RequiredArgsConstructor
15+
public class PlacesService {
16+
17+
private final PlacesQueryAdapter placesQueryAdapter;
18+
19+
private final PlacesCommandAdapter placesCommandAdapter;
20+
21+
public List<PlacesDto.NearByPlaceDto> getNearByPlaces(double latitude, double longitude
22+
,String category, Integer radius, Integer size, String nextPageToken) {
23+
24+
return null;
25+
}
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package rootbox.rootboxApp.api.places.implementation;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import rootbox.rootboxApp.global.annotations.Adapter;
5+
6+
@Slf4j
7+
@Adapter
8+
public class PlacesCommandAdapter {
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package rootbox.rootboxApp.api.places.implementation;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import rootbox.rootboxApp.global.annotations.Adapter;
5+
6+
@Slf4j
7+
@Adapter
8+
public class PlacesQueryAdapter {
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package rootbox.rootboxApp.api.places.presentation;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RequestParam;
7+
import org.springframework.web.bind.annotation.RestController;
8+
import rootbox.rootboxApp.api.places.business.PlacesService;
9+
import rootbox.rootboxApp.api.places.presentation.dto.PlacesDto;
10+
import rootbox.rootboxApp.global.common.CommonResponse;
11+
12+
import java.util.List;
13+
14+
@RestController
15+
@RequiredArgsConstructor
16+
@RequestMapping("/api/v1/places")
17+
public class PlacesApi {
18+
19+
private final PlacesService placesService;
20+
21+
@GetMapping("/")
22+
public CommonResponse<List<PlacesDto.NearByPlaceDto>> getNearByPlaces(@RequestParam(required = false) Integer radius
23+
, @RequestParam(required = false) Integer size, @RequestParam(required = false) String nextPageToken
24+
, @RequestParam(required = true) String category
25+
, @RequestParam(required = true) double lat
26+
, @RequestParam(required = true) double lng) {
27+
return CommonResponse.onSuccess(placesService.getNearByPlaces(lat,lng,category,radius,size,nextPageToken));
28+
}
29+
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package rootbox.rootboxApp.api.places.presentation.dto;
2+
3+
import lombok.*;
4+
5+
import java.util.List;
6+
7+
public class PlacesDto {
8+
9+
@Getter
10+
@Setter
11+
@NoArgsConstructor
12+
@AllArgsConstructor
13+
@Builder
14+
public static class NearByPlaceDto {
15+
16+
private String placeName;
17+
18+
private Float latitude;
19+
20+
private Float longitude;
21+
22+
private String openTime;
23+
24+
private Boolean isOpen;
25+
26+
private List<String> photoList;
27+
}
28+
}

src/main/java/rootbox/rootboxApp/api/user/business/UserService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ public SocialLoginDto.KakaoSocialLoginResponseDto socialLogin(SocialLoginDto.Kak
5555

5656
// 로그인 처리
5757
if (userBySocialId.isPresent()) {
58+
User user = userBySocialId.get();
59+
if (user.getNickname() ==null){
60+
String accessToken = tokenProvider.createAccessToken(user, List.of(new SimpleGrantedAuthority(UserRole.USER.name())));
61+
return SocialLoginDto.KakaoSocialLoginResponseDto
62+
.builder()
63+
.loginType(SocialType.KAKAO.name())
64+
.isNew(true)
65+
.accessToken(accessToken)
66+
.refreshToken(userCommandAdapter.saveRefreshToken(tokenProvider.createRefreshToken(),
67+
user.getSocialLoginUid()).getRefreshToken())
68+
.userSocialId(user.getSocialLoginUid())
69+
.build();
70+
}
5871
Optional<RefreshToken> refreshTokenByUserId = userQueryAdapter.findRefreshTokenByUserId(kakaoUserInfo.getId());
5972

6073
String accessToken = tokenProvider.createAccessToken(userBySocialId.get(), List.of(new SimpleGrantedAuthority(UserRole.USER.name())));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package rootbox.rootboxApp.global.feign.client;
2+
3+
import org.springframework.cloud.openfeign.FeignClient;
4+
import org.springframework.stereotype.Component;
5+
import rootbox.rootboxApp.global.feign.config.KakaoFeignConfiguration;
6+
7+
@FeignClient(name = "GoogleNearByFeignClient", url = "${oauth.google.baseUrl}", configuration = GoogleNearByFeignClient.class)
8+
@Component
9+
public interface GoogleNearByFeignClient {
10+
11+
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package rootbox.rootboxApp.global.feign.config;
2+
3+
import feign.Logger;
4+
import feign.codec.ErrorDecoder;
5+
import org.springframework.context.annotation.Bean;
6+
import rootbox.rootboxApp.global.feign.exception.FeignClientExceptionErrorDecoder;
7+
8+
public class GoggleFeignConfiguration {
9+
@Bean
10+
public ErrorDecoder errorDecoder() {
11+
return new FeignClientExceptionErrorDecoder();
12+
}
13+
14+
@Bean
15+
Logger.Level feignLoggerLevel() {
16+
return Logger.Level.FULL;
17+
}
18+
}

src/main/resources/application.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ oauth:
8383
clientId: ${KAKAO_CLIENT_ID}
8484
redirectUrl : ${KAKAO_REDIRECT_URL}
8585
secretKeyREST: ${KAKAO_SECRET_REST}
86+
google:
87+
baseUrl : ${GOOGLE_BASE_URL}
88+
apiKey : ${GOOGLE_API_KEY}
89+
8690

8791
#cloud:
8892
# aws:
@@ -150,6 +154,9 @@ oauth:
150154
clientId: ${KAKAO_REST_KEY}
151155
redirectUrl : ${KAKAO_REDIRECT_URL}
152156
secretKeyREST: ${KAKAO_SECRET_REST}
157+
google:
158+
baseUrl : ${GOOGLE_BASE_URL}
159+
apiKey : ${GOOGLE_API_KEY}
153160

154161
#firebase:
155162
# admin-sdk: ${FCM_KEY}

0 commit comments

Comments
 (0)