Skip to content

Commit

Permalink
Merge pull request #107 from PawWithU/feat/106-get-application-my-info
Browse files Browse the repository at this point in the history
[Feature] 이동봉사 신청 시 기본 정보 불러오기 API 구현
  • Loading branch information
kyeong-hyeok authored Nov 19, 2023
2 parents 6d51929 + 0e6a454 commit 7bcb38b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,16 @@ public ResponseEntity<ApplicationIntermediaryGetOneResponse> 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<ApplicationVolunteerInfoResponse> getMyInfo(@AuthenticationPrincipal UserDetails loginUser) {
ApplicationVolunteerInfoResponse response = applicationService.getMyInfo(loginUser.getUsername());
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}

0 comments on commit 7bcb38b

Please sign in to comment.