From 866bae36c0d1d351ba45f5d7f91a7077ef55dc7f Mon Sep 17 00:00:00 2001 From: yso8296 <66588512+yso8296@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:50:52 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 8 ++++---- .../nullnullteam/member/service/MemberService.java | 14 +++++++------- .../com/hackathon/nullnullteam/ocr/OcrService.java | 6 ++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/hackathon/nullnullteam/member/controller/MemberController.java b/src/main/java/com/hackathon/nullnullteam/member/controller/MemberController.java index c2eead7..438e8a2 100644 --- a/src/main/java/com/hackathon/nullnullteam/member/controller/MemberController.java +++ b/src/main/java/com/hackathon/nullnullteam/member/controller/MemberController.java @@ -21,20 +21,20 @@ public class MemberController { private final MemberService memberService; - @GetMapping("/login") + /*@GetMapping("/login") public ResponseEntity login() { String loginUrl = memberService.getCodeUrl(); return ResponseEntity.status(HttpStatus.SEE_OTHER) .header("location", loginUrl) .build(); - } + }*/ @GetMapping("/callback") public ResponseEntity registerMember( - @RequestParam("code") String code + @RequestParam("token") String token ) { - MemberModel.Login memberInfo = memberService.register(code); + MemberModel.Login memberInfo = memberService.register(token); return ResponseEntity.status(HttpStatus.CREATED) diff --git a/src/main/java/com/hackathon/nullnullteam/member/service/MemberService.java b/src/main/java/com/hackathon/nullnullteam/member/service/MemberService.java index d2c3be6..cb36033 100644 --- a/src/main/java/com/hackathon/nullnullteam/member/service/MemberService.java +++ b/src/main/java/com/hackathon/nullnullteam/member/service/MemberService.java @@ -26,12 +26,12 @@ public String getCodeUrl() { } @Transactional - public MemberModel.Login register(String code) { + public MemberModel.Login register(String token) { // 토큰 발급 - TokenInfoResponse tokenResponse = memberApiCaller.getAccessToken(code); - String accessToken = tokenResponse.accessToken(); + String kakaoToken = token; + // 카카오 사용자 정보 요청 - UserInfoResponse userInfoResponse = memberApiCaller.extractUserInfo(accessToken); + UserInfoResponse userInfoResponse = memberApiCaller.extractUserInfo(kakaoToken); KakaoAccount kakaoAccount = userInfoResponse.kakaoAccount(); // Users 저장 및 중복 체크 @@ -41,10 +41,10 @@ public MemberModel.Login register(String code) { return newMember; }); - String token = jwtProvider.createToken(member.getId(), member.getEmail()); - System.out.println(token); + String accessToken = jwtProvider.createToken(member.getId(), member.getEmail()); + System.out.println(accessToken); - return MemberModel.Login.from(token); + return MemberModel.Login.from(accessToken); } public MemberModel.Info getMemberInfo(Long memberId) { diff --git a/src/main/java/com/hackathon/nullnullteam/ocr/OcrService.java b/src/main/java/com/hackathon/nullnullteam/ocr/OcrService.java index 409cf22..1afff42 100644 --- a/src/main/java/com/hackathon/nullnullteam/ocr/OcrService.java +++ b/src/main/java/com/hackathon/nullnullteam/ocr/OcrService.java @@ -72,6 +72,12 @@ public List extractTextFromImage(MultipartFile file) { ResponseEntity response = restTemplate.exchange(ocrUrl, HttpMethod.POST, requestEntity, String.class); JSONObject object = new JSONObject(response.getBody()); List text = extractInferText(object); + + StringBuilder sb = new StringBuilder(); + for (String t : text) { + sb.append(t + " "); + } + System.out.println(sb.toString()); return text; }