diff --git a/src/main/java/com/goormdari/domain/team/application/TeamService.java b/src/main/java/com/goormdari/domain/team/application/TeamService.java index ec3c1f5..1dbda4d 100644 --- a/src/main/java/com/goormdari/domain/team/application/TeamService.java +++ b/src/main/java/com/goormdari/domain/team/application/TeamService.java @@ -93,17 +93,15 @@ public CreateTeamResponse createNewTeam(final String username, final CreateTeamR } - public Message sendCode(String username, Long guestId) { + public Message sendCode(String username, String email) { User hostUser = userRepository.findByUsername(username) .orElseThrow(() -> new NotFoundException("User not found")); - User guestUser = userRepository.findById(guestId) - .orElseThrow(() -> new NotFoundException("Guest not found")); String joinCode = userRepository.findJoinCodeByUserId(hostUser.getId()); - emailClient.sendOneEmail(hostUser.getNickname(), guestUser.getEmail(), joinCode); + emailClient.sendOneEmail(hostUser.getNickname(), email, joinCode); return Message.builder() .message("이메일 전송에 성공했습니다.") diff --git a/src/main/java/com/goormdari/domain/team/presentation/TeamController.java b/src/main/java/com/goormdari/domain/team/presentation/TeamController.java index 2d042e9..7891355 100644 --- a/src/main/java/com/goormdari/domain/team/presentation/TeamController.java +++ b/src/main/java/com/goormdari/domain/team/presentation/TeamController.java @@ -56,17 +56,17 @@ public ResponseCustom createTeam( @ApiResponse(responseCode = "200", description = "팀(방) 참여코드 전달 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = Message.class))}), @ApiResponse(responseCode = "400", description = "팀(방) 참여코드 전달 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}), }) - @PostMapping("/email/{guestId}") + @PostMapping("/email/{email}") public ResponseCustom sendJoinCode( @Parameter(description = "Accesstoken을 입력해주세요.", required = true) @RequestHeader("Authorization") String token, - @Parameter(description = "초대할 유저의 id를 입력해주세요.", required = true) @PathVariable Long guestId + @Parameter(description = "초대할 유저의 id를 입력해주세요.", required = true) @PathVariable String email ) { String jwt = token.startsWith("Bearer ") ? token.substring(7) : token; if (!jwtUtil.validateToken(jwt)) { throw new IllegalArgumentException("Invalid token"); } String username = jwtUtil.extractUsername(jwt); - return ResponseCustom.OK(teamService.sendCode(username, guestId)); + return ResponseCustom.OK(teamService.sendCode(username, email)); } @Operation(summary = "참여코드로 팀(방) 참여", description = "참여코드로 팀(방)에 참여합니다.")