From 9a279152eec4a3e78951b28434f2f0a37a47ebe2 Mon Sep 17 00:00:00 2001 From: shinhn Date: Fri, 24 Mar 2023 19:36:32 +0900 Subject: [PATCH] =?UTF-8?q?#9=20#23=20#108=20refactor=20:=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EB=B0=8F=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?sout=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/apns/controller/APNController.java | 17 -------- .../server/apns/service/APNServiceImpl.java | 41 ++----------------- .../applelogin/service/AppleServiceImpl.java | 7 +--- .../boarduser/BoardUserServiceImpl.java | 3 -- .../clipboard/ClipBoardServiceImpl.java | 35 +--------------- 5 files changed, 5 insertions(+), 98 deletions(-) diff --git a/server/src/main/java/com/yogit/server/apns/controller/APNController.java b/server/src/main/java/com/yogit/server/apns/controller/APNController.java index 5b811b5..8b7d2d0 100644 --- a/server/src/main/java/com/yogit/server/apns/controller/APNController.java +++ b/server/src/main/java/com/yogit/server/apns/controller/APNController.java @@ -37,21 +37,4 @@ public class APNController { public ApplicationResponse createAPN() throws ExecutionException, InterruptedException { return apnService.createApplePushNotification(); } - -// /** -// * apn 참여자 보드 참여 신청 호스트에게 푸쉬 알림 -// * @author 토마스 -// */ -// @ApiOperation(value = "apn 참여자 보드 참여 신청 호스트에게 푸쉬 알림", notes = "apn 푸쉬 알람 생성 요청.") -// @ApiResponses({ -// @ApiResponse(code= 201, message = "요청에 성공하였습니다."), -// @ApiResponse(code= 404, message = "존재하지 않는 유저입니다."), -// @ApiResponse(code= 404, message = "존재하지 않는 Board아이디입니다."), -// @ApiResponse(code= 404, message = "요청한 유저가 호스트가 아닙니다."), -// @ApiResponse(code = 4000 , message = "서버 오류입니다.") -// }) -// @PostMapping("/boarduser-join") -// public ApplicationResponse createBoardUserJoinAPN(@RequestBody @Validated CreateBoardUserJoinAPNReq dto) throws ExecutionException, InterruptedException { -// return apnService.createBoardUserJoinAPN(dto); -// } } diff --git a/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java b/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java index e361f0c..268e255 100644 --- a/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java +++ b/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java @@ -49,7 +49,7 @@ public ApplicationResponse createApplePushNotification() throws Executio // 메시지를 동기로 전송 val response = sendNotificationFuture.get(); - System.out.println("response는 ==="+ response); + // System.out.println("response는 ==="+ response); // 메시지를 비동기로 전송 // sendNotificationFuture.addListener { future -> @@ -63,12 +63,12 @@ public ApplicationResponse createApplePushNotification() throws Executio // 성공 응답시 null 반환 // 오류 응답시 BadDeviceToken 등의 오류 코드 문자열 반환 // println(response.rejectionReason); - System.out.println("getRejectionReason는 === :"+response.getRejectionReason()); + // System.out.println("getRejectionReason는 === :"+response.getRejectionReason()); // 응답에서 원본 메시지 획득 가능 // {"aps":{"alert":{"body":"test_body","title":"test_title"}},"test_data_3":"def","test_data_1":"abc"} // println(response.pushNotification.payload); - System.out.println("getPushNotification는 === :"+response.getPushNotification()); + // System.out.println("getPushNotification는 === :"+response.getPushNotification()); return ApplicationResponse.ok("애플 푸쉬 알람 성공"); } @@ -93,27 +93,11 @@ public ApplicationResponse createBoardUserJoinAPN(CreateBoardUserJoinAPN // 메시지를 동기로 전송 val response = sendNotificationFuture.get(); - System.out.println("response는 ==="+ response); // 메시지를 비동기로 전송 - // sendNotificationFuture.addListener { future -> - // val response = future.now - // println(response); - // } sendNotificationFuture.addListener(future -> System.out.println("getNow는 == "+future.getNow())); - - // 성공 응답시 null 반환 - // 오류 응답시 BadDeviceToken 등의 오류 코드 문자열 반환 - // println(response.rejectionReason); - System.out.println("getRejectionReason는 === :"+response.getRejectionReason()); - - // 응답에서 원본 메시지 획득 가능 - // {"aps":{"alert":{"body":"test_body","title":"test_title"}},"test_data_3":"def","test_data_1":"abc"} - // println(response.pushNotification.payload); - System.out.println("getPushNotification는 === :"+response.getPushNotification()); - return ApplicationResponse.ok("애플 푸쉬 알람 성공"); } @@ -138,10 +122,6 @@ public ApplicationResponse delBoardUserJoinAPN(DelBoardUserJoinAPNReq dt val response = sendNotificationFuture.get(); // 메시지를 비동기로 전송 - // sendNotificationFuture.addListener { future -> - // val response = future.now - // println(response); - // } sendNotificationFuture.addListener(future -> System.out.println("getNow는 == "+future.getNow())); @@ -167,26 +147,11 @@ public ApplicationResponse createClipBoardAPN(CreateClipBoardAPNReq dto) // 메시지를 동기로 전송 val response = sendNotificationFuture.get(); - System.out.println("response는 ==="+ response); // 메시지를 비동기로 전송 - // sendNotificationFuture.addListener { future -> - // val response = future.now - // println(response); - // } sendNotificationFuture.addListener(future -> System.out.println("getNow는 == "+future.getNow())); - // 성공 응답시 null 반환 - // 오류 응답시 BadDeviceToken 등의 오류 코드 문자열 반환 - // println(response.rejectionReason); - System.out.println("getRejectionReason는 === :"+response.getRejectionReason()); - - // 응답에서 원본 메시지 획득 가능 - // {"aps":{"alert":{"body":"test_body","title":"test_title"}},"test_data_3":"def","test_data_1":"abc"} - // println(response.pushNotification.payload); - System.out.println("getPushNotification는 === :"+response.getPushNotification()); - return ApplicationResponse.ok("애플 푸쉬 알람 성공"); } diff --git a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java index 39707dd..77c1150 100644 --- a/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java +++ b/server/src/main/java/com/yogit/server/applelogin/service/AppleServiceImpl.java @@ -74,12 +74,6 @@ public TokenResponse requestCodeValidations(ServicesResponse serviceResponse, St // 이메일 추출 String email = user.getAsString("email"); - // 이름 추출 -// Map name = (Map) user.get("name"); -// String lastName = name.get("lastName"); -// String firstName = name.get("firstName"); -// String fullName = lastName + firstName; - // 만약 처음 인증하는 유저여서 refresh 토큰 없으면 client_secret, authorization_code로 검증 if (client_secret != null && code != null && refresh_token == null) { tokenResponse = appleUtils.validateAuthorizationGrantCode(client_secret, code); @@ -88,6 +82,7 @@ public TokenResponse requestCodeValidations(ServicesResponse serviceResponse, St CreateUserAppleReq createUserAppleReq = new CreateUserAppleReq(email, tokenResponse.getRefresh_token(), null, UserType.APPLE, tokenResponse.getAccess_token(), tokenResponse.getExpires_in()); saveduser = userService.createUserApple(createUserAppleReq); } + // 이미 refresh 토큰 있는 유저면 client_secret, refresh_token로 검증 else if (client_secret != null && code == null && refresh_token != null) { tokenResponse = appleUtils.validateAnExistingRefreshToken(client_secret, refresh_token); diff --git a/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java index fafcd19..b4d80f3 100644 --- a/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java @@ -119,16 +119,13 @@ public ApplicationResponse approveBoardUser(CreateBoardUserReq dto boardUser.changeApplyStatus(); // 참여 승인으로 상태 업데이트 board.addCurrentMember();// 보드 현재 인원 +1 - //board.addBoardUser(boardUser); // 보드에 멤버 추가 List participants = board.getBoardUsers().stream() - //.filter(bu -> !bu.getUser().equals(board.getHost())) .filter(bu -> bu.getApplyStatus().equals(1)) // 참여 승인된 사람만 조회 .map(bu -> bu.getUser()) .collect(Collectors.toList()); List participantsImageUUIds = board.getBoardUsers().stream() - //.filter(bu -> !bu.getUser().equals(board.getHost())) .filter(bu -> bu.getApplyStatus().equals(1)) // 참여 승인된 사람만 조회 .map(bu -> bu.getUser().getProfileImg()) .collect(Collectors.toList()); diff --git a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java index c0453d9..ef83194 100644 --- a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java @@ -78,6 +78,7 @@ public ApplicationResponse createClipBoard(CreateClipBoardReq dto) List boardUsers = board.getBoardUsers().stream() .filter(boardUser -> boardUser.getUser().getStatus().equals(BaseStatus.ACTIVE)) .collect(Collectors.toList()); + if(boardUsers!=null){ for(BoardUser bu: boardUsers){ try { @@ -104,9 +105,6 @@ public ApplicationResponse findClipBoard(GetClipBoardReq dto){ User user = userRepository.findByUserId(dto.getUserId()) .orElseThrow(() -> new NotFoundUserException()); - Board board = boardRepository.findBoardById(dto.getBoardId()) - .orElseThrow(() -> new NotFoundBoardException()); - ClipBoard clipBoard = clipBoardRepository.findClipBoardById(dto.getClipBoardId()) .orElseThrow(() -> new NotFoundClipBoardException()); @@ -121,37 +119,6 @@ public ApplicationResponse findClipBoard(GetClipBoardReq dto){ return ApplicationResponse.ok(getClipBoardRes); } - -// @Transactional(readOnly = true) -// @Override -// public ApplicationResponse> findAllClipBoards(GetAllClipBoardsReq dto){ -// -// userService.validateRefreshToken(dto.getUserId(), dto.getRefreshToken()); -// -// User user = userRepository.findByUserId(dto.getUserId()) -// .orElseThrow(() -> new NotFoundUserException()); -// -// Board board = boardRepository.findBoardById(dto.getBoardId()) -// .orElseThrow(() -> new NotFoundBoardException()); -// -// List blockedUsers = blockRepository.findBlocksByBlockingUserId(dto.getUserId()).stream() -// .map(block -> block.getBlockedUser()) -// .collect(Collectors.toList()); -// -// // 클립보드 res안에 해당하는 코멘트 리스트까지 조회 및 포함 -// // 유저 profileImgUrl 또한 img uuid -> s3 url로 변환 -// List getClipBoardResList = clipBoardRepository.findAllByBoardId(dto.getBoardId()).stream() -// .filter(clipBoard -> !blockedUsers.contains(clipBoard.getUser())) // 차단당한 유저의 데이터 제외 -// .map(clipBoard -> GetClipBoardRes.toDto(clipBoard, commentRepository.findAllCommentsByClipBoardId(clipBoard.getId()).stream() -// .filter(comment -> !blockedUsers.contains(comment.getUser())) -// .map(comment -> CommentRes.toDto(comment)) -// .collect(Collectors.toList()), -// awsS3Service.makeUrlOfFilename(clipBoard.getUser().getProfileImg()))) -// .collect(Collectors.toList()); -// -// return ApplicationResponse.ok(getClipBoardResList); -// } - @Transactional(readOnly = true) @Override public ApplicationResponse findAllClipBoards(GetAllClipBoardsReq dto){