From 6fb0d3dc84f65766b5e4a417d4cc08c6efe903ed Mon Sep 17 00:00:00 2001 From: wuseong Date: Sun, 4 Feb 2024 21:53:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=97=85=EB=AC=B4=EB=B6=84=EC=95=BC=20?= =?UTF-8?q?enum=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onnoff/auth/controller/LoginController.java | 4 ++-- .../onnoff/domain/user/converter/UserConverter.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/onnoff/onnoff/auth/controller/LoginController.java b/src/main/java/com/onnoff/onnoff/auth/controller/LoginController.java index a25c0b4..e9f76f8 100644 --- a/src/main/java/com/onnoff/onnoff/auth/controller/LoginController.java +++ b/src/main/java/com/onnoff/onnoff/auth/controller/LoginController.java @@ -80,7 +80,7 @@ public ResponseEntity getAccessToken(@RequestParam(name = "code") String @Operation(summary = "소셜 토큰 검증 API",description = "토큰을 검증 하고 이에 대한 결과를 응답합니다. 추가 정보 입력 여부도 같이 응답 합니다.") @ResponseBody @PostMapping("/oauth2/kakao/token/validate") - public ApiResponse validateKakoToken(HttpServletResponse response, @RequestBody LoginRequestDTO.KakaoTokenValidateDTO requestDTO) { + public ApiResponse validateKakoToken(@RequestBody LoginRequestDTO.KakaoTokenValidateDTO requestDTO) { // identity 토큰 검증 kakaoLoginService.validate(requestDTO.getIdentityToken()); // ok -> 유저 정보 가져오기 @@ -108,7 +108,7 @@ public ApiResponse validateKakoToken(HttpServletRespon @ResponseBody @PostMapping("/oauth2/apple/token/validate") - public ApiResponse validateAppleToken(HttpServletResponse response, @RequestBody LoginRequestDTO.AppleTokenValidateDTO requestDTO) { + public ApiResponse validateAppleToken(@RequestBody LoginRequestDTO.AppleTokenValidateDTO requestDTO) { // 검증하기 appleLoginService.validate(requestDTO.getIdentityToken()); // 검증 성공 시 리프레시 토큰 발급받아 저장(기한 무제한, 회원탈퇴 시 필요) diff --git a/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java b/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java index 955c80c..ae14370 100644 --- a/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java +++ b/src/main/java/com/onnoff/onnoff/domain/user/converter/UserConverter.java @@ -1,5 +1,7 @@ package com.onnoff.onnoff.domain.user.converter; +import com.onnoff.onnoff.apiPayload.code.status.ErrorStatus; +import com.onnoff.onnoff.apiPayload.exception.GeneralException; import com.onnoff.onnoff.auth.dto.LoginRequestDTO; import com.onnoff.onnoff.auth.feignClient.dto.kakao.KakaoOauth2DTO; import com.onnoff.onnoff.domain.user.User; @@ -8,8 +10,18 @@ import com.onnoff.onnoff.domain.user.enums.FieldOfWork; import com.onnoff.onnoff.domain.user.enums.SocialType; +import java.util.EnumSet; + public class UserConverter { public static User toUser(KakaoOauth2DTO.UserInfoResponseDTO response, LoginRequestDTO.AdditionalInfo additionalInfo){ + String fieldOfWork = additionalInfo.getFieldOfWork(); + try{ + FieldOfWork.valueOf(fieldOfWork); + } + catch (IllegalArgumentException e){ + throw new GeneralException(ErrorStatus.INVALID_ENUM_VALUE); + } + ExperienceYear experienceYear = ExperienceYear.fromValue(additionalInfo.getExperienceYear()); return User.builder() .oauthId(response.getSub())