Skip to content

Commit

Permalink
feat: 봉사자 이메일 찾기 구현 (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Jun 3, 2024
1 parent e89c105 commit c13c27e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -122,4 +119,16 @@ public ResponseEntity<IntermediaryNameResponse> 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<VolunteerEmailResponse> findVolunteerEmail(@RequestBody @Valid VolunteerPhoneRequest request) {
VolunteerEmailResponse response = authService.findVolunteerEmail(request);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit c13c27e

Please sign in to comment.