diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java b/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java index 4dac2636..abddbbdb 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/controller/SignUpController.java @@ -1,10 +1,7 @@ package com.pawwithu.connectdog.domain.auth.controller; import com.pawwithu.connectdog.domain.auth.dto.request.*; -import com.pawwithu.connectdog.domain.auth.dto.response.EmailResponse; -import com.pawwithu.connectdog.domain.auth.dto.response.IntermediaryNameResponse; -import com.pawwithu.connectdog.domain.auth.dto.response.IntermediaryPhoneResponse; -import com.pawwithu.connectdog.domain.auth.dto.response.VolunteerPhoneResponse; +import com.pawwithu.connectdog.domain.auth.dto.response.*; import com.pawwithu.connectdog.domain.auth.service.AuthService; import com.pawwithu.connectdog.domain.auth.service.EmailService; import com.pawwithu.connectdog.error.dto.ErrorResponse; @@ -122,4 +119,16 @@ public ResponseEntity isIntermediaryNameDuplicated(@Re IntermediaryNameResponse response = authService.isIntermediaryNameDuplicated(request); return ResponseEntity.ok(response); } + + @Operation(summary = "이메일 찾기 - 봉사자 휴대폰 번호로 이메일 찾기", description = "봉사자 휴대폰 번호로 이메일을 찾습니다.", + responses = {@ApiResponse(responseCode = "200", description = "봉사자 휴대폰 번호로 이메일 찾기 성공") + , @ApiResponse(responseCode = "400" + , description = "V1, 휴대폰 번호는 필수 입력 값입니다. \t\n M2, 해당 이동봉사 중개를 찾을 수 없습니다." + , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @PostMapping("/volunteers/search/email") + public ResponseEntity findVolunteerEmail(@RequestBody @Valid VolunteerPhoneRequest request) { + VolunteerEmailResponse response = authService.findVolunteerEmail(request); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/dto/response/VolunteerEmailResponse.java b/src/main/java/com/pawwithu/connectdog/domain/auth/dto/response/VolunteerEmailResponse.java new file mode 100644 index 00000000..eecd27a6 --- /dev/null +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/dto/response/VolunteerEmailResponse.java @@ -0,0 +1,7 @@ +package com.pawwithu.connectdog.domain.auth.dto.response; + +public record VolunteerEmailResponse(String email) { + public static VolunteerEmailResponse of(String email){ + return new VolunteerEmailResponse(email); + } +} \ No newline at end of file diff --git a/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java b/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java index 39edd726..fdba2afc 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java +++ b/src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java @@ -6,6 +6,7 @@ import com.pawwithu.connectdog.domain.auth.dto.request.*; import com.pawwithu.connectdog.domain.auth.dto.response.IntermediaryNameResponse; import com.pawwithu.connectdog.domain.auth.dto.response.IntermediaryPhoneResponse; +import com.pawwithu.connectdog.domain.auth.dto.response.VolunteerEmailResponse; import com.pawwithu.connectdog.domain.auth.dto.response.VolunteerPhoneResponse; import com.pawwithu.connectdog.domain.badge.repository.VolunteerBadgeRepository; import com.pawwithu.connectdog.domain.bookmark.repository.BookmarkRepository; @@ -203,4 +204,11 @@ public IntermediaryNameResponse isIntermediaryNameDuplicated(IntermediaryNameReq IntermediaryNameResponse response = IntermediaryNameResponse.of(isDuplicated); return response; } + + @Transactional(readOnly = true) + public VolunteerEmailResponse findVolunteerEmail(VolunteerPhoneRequest request) { + Volunteer volunteer = volunteerRepository.findByPhone(request.phone()).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND)); + VolunteerEmailResponse response = VolunteerEmailResponse.of(volunteer.getEmail()); + return response; + } }