From d6f929f7c57bc21bbc9e55459ba1f85c714e3162 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Wed, 16 Aug 2023 12:53:26 +0900 Subject: [PATCH] fix:json response error --- .../global/oauth/controller/AuthController.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/clutch/clutchserver/global/oauth/controller/AuthController.java b/src/main/java/clutch/clutchserver/global/oauth/controller/AuthController.java index fcece60..e2788dc 100644 --- a/src/main/java/clutch/clutchserver/global/oauth/controller/AuthController.java +++ b/src/main/java/clutch/clutchserver/global/oauth/controller/AuthController.java @@ -35,18 +35,26 @@ public class AuthController { @PostMapping("/api/login/apple") @Operation(summary = "Apple Login") @io.swagger.v3.oas.annotations.parameters.RequestBody(description ="{user:testuser,userId:sdjahkfhkjdhsjafhksd,phonenumber:010-1234-1234,email:email@email.com}") - public ResponseEntity getAppleToken(@RequestBody AppleUserDto appleUserDto) throws Exception{ + public ResponseEntity getAppleToken(@RequestBody AppleUserDto appleUserDto) throws Exception{ User appleInfo = oAuth2Service.getAppleInfo(appleUserDto); UserResponseDto.TokenInfo tokenDTO =securityService.appleLogin(appleInfo); - return ResponseEntity.ok(tokenDTO); + clutch.clutchserver.global.payload.ApiResponse apiResponse = clutch.clutchserver.global.payload.ApiResponse.builder() + .check(true) + .information(tokenDTO) + .build(); + return ResponseEntity.ok(apiResponse); } @PostMapping("/api/login/kakao") @Operation(summary = "Kakao Login") @io.swagger.v3.oas.annotations.parameters.RequestBody(description ="{user:testuser,userId:sdjahkfhkjdhsjafhksd,phonenumber:010-1234-1234,email:email@email.com}") - public ResponseEntity getKToken(@RequestBody KakaoUserDto kakaoUserDto) throws Exception{ + public ResponseEntity getKToken(@RequestBody KakaoUserDto kakaoUserDto) throws Exception{ User kInfo = oAuth2Service.getKInfo(kakaoUserDto); UserResponseDto.TokenInfo tokenDTO =securityService.kakaoLogin(kInfo); - return ResponseEntity.ok(tokenDTO); + clutch.clutchserver.global.payload.ApiResponse apiResponse = clutch.clutchserver.global.payload.ApiResponse.builder() + .check(true) + .information(tokenDTO) + .build(); + return ResponseEntity.ok(apiResponse); } @PostMapping(value = "/api/auth/token/kakao")