diff --git a/src/main/java/com/pawwithu/connectdog/domain/application/controller/ApplicationController.java b/src/main/java/com/pawwithu/connectdog/domain/application/controller/ApplicationController.java index b6b4f4f3..3d96f21b 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/application/controller/ApplicationController.java +++ b/src/main/java/com/pawwithu/connectdog/domain/application/controller/ApplicationController.java @@ -186,4 +186,16 @@ public ResponseEntity getIntermediaryOneA ApplicationIntermediaryGetOneResponse response = applicationService.getIntermediaryOneApplication(loginUser.getUsername(), applicationId); return ResponseEntity.ok(response); } + + @Operation(summary = "신청 - 기본 정보 불러오기", description = "신청에서 기본 정보를 불러옵니다.", + responses = {@ApiResponse(responseCode = "200", description = "기본 정보 불러오기 성공") + , @ApiResponse(responseCode = "400" + , description = "M1, 해당 이동봉사자를 찾을 수 없습니다." + , content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping( "/volunteers/applications/my-info") + public ResponseEntity getMyInfo(@AuthenticationPrincipal UserDetails loginUser) { + ApplicationVolunteerInfoResponse response = applicationService.getMyInfo(loginUser.getUsername()); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/pawwithu/connectdog/domain/application/dto/response/ApplicationVolunteerInfoResponse.java b/src/main/java/com/pawwithu/connectdog/domain/application/dto/response/ApplicationVolunteerInfoResponse.java new file mode 100644 index 00000000..61e14325 --- /dev/null +++ b/src/main/java/com/pawwithu/connectdog/domain/application/dto/response/ApplicationVolunteerInfoResponse.java @@ -0,0 +1,8 @@ +package com.pawwithu.connectdog.domain.application.dto.response; + +public record ApplicationVolunteerInfoResponse(String name, String phone) { + + public static ApplicationVolunteerInfoResponse of (String name, String phone) { + return new ApplicationVolunteerInfoResponse(name, phone); + } +} diff --git a/src/main/java/com/pawwithu/connectdog/domain/application/service/ApplicationService.java b/src/main/java/com/pawwithu/connectdog/domain/application/service/ApplicationService.java index ad439e71..a4f9202c 100644 --- a/src/main/java/com/pawwithu/connectdog/domain/application/service/ApplicationService.java +++ b/src/main/java/com/pawwithu/connectdog/domain/application/service/ApplicationService.java @@ -161,4 +161,11 @@ public ApplicationIntermediaryGetOneResponse getIntermediaryOneApplication(Strin ApplicationIntermediaryGetOneResponse oneApplication = ApplicationIntermediaryGetOneResponse.from(application); return oneApplication; } + + public ApplicationVolunteerInfoResponse getMyInfo(String email) { + // 이동봉사자 + Volunteer volunteer = volunteerRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND)); + ApplicationVolunteerInfoResponse volunteerInfo = ApplicationVolunteerInfoResponse.of(volunteer.getName(), volunteer.getPhone()); + return volunteerInfo; + } } diff --git a/src/test/java/com/pawwithu/connectdog/domain/application/controller/ApplicationControllerTest.java b/src/test/java/com/pawwithu/connectdog/domain/application/controller/ApplicationControllerTest.java index 7e8f9077..53e73b46 100644 --- a/src/test/java/com/pawwithu/connectdog/domain/application/controller/ApplicationControllerTest.java +++ b/src/test/java/com/pawwithu/connectdog/domain/application/controller/ApplicationControllerTest.java @@ -288,5 +288,19 @@ void setUp() { verify(applicationService, times(1)).getIntermediaryOneApplication(anyString(), anyLong()); } + @Test + void 이동봉사_신청_기본_정보_불러오기() throws Exception { + //given + ApplicationVolunteerInfoResponse response = new ApplicationVolunteerInfoResponse("한호정", "01022223333"); + + //when + ResultActions result = mockMvc.perform( + get("/volunteers/applications/my-info") + ); + + //then + result.andExpect(status().isOk()); + verify(applicationService, times(1)).getMyInfo(anyString()); + } } \ No newline at end of file