Skip to content

Commit

Permalink
Merge pull request #188 from PawWithU/feat/187-intermediary-info-api
Browse files Browse the repository at this point in the history
[Feature] 이동봉사자 모집자 프로필 - 기본 정보 조회 API 수정
  • Loading branch information
hojeong2747 authored May 11, 2024
2 parents ae2cfa3 + 087c000 commit 36cbfab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import com.pawwithu.connectdog.domain.intermediary.entity.Intermediary;

public record IntermediaryGetInfoResponse(String profileImage, Long completedPostCount, String name, String intro,
String url, String contact, String guide,
Long reviewCount, Long dogStatusCount) {
public static IntermediaryGetInfoResponse from(Intermediary intermediary, Long completedPostCount, Long reviewCount, Long dogStatusCount) {
return new IntermediaryGetInfoResponse(intermediary.getProfileImage(), completedPostCount, intermediary.getName(), intermediary.getIntro(),
intermediary.getUrl(), intermediary.getContact(), intermediary.getGuide(), reviewCount, dogStatusCount);
public record IntermediaryGetInfoResponse(String profileImage, String name, String intro,
String url, String contact, String guide) {
public static IntermediaryGetInfoResponse from(Intermediary intermediary) {
return new IntermediaryGetInfoResponse(intermediary.getProfileImage(), intermediary.getName(), intermediary.getIntro(),
intermediary.getUrl(), intermediary.getContact(), intermediary.getGuide());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,7 @@ public List<IntermediaryGetPostsResponse> volunteerGetIntermediaryPosts(Long int
@Transactional(readOnly = true)
public IntermediaryGetInfoResponse getIntermediaryInfo(Long intermediaryId) {
Intermediary intermediary = intermediaryRepository.findById(intermediaryId).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
// 봉사 완료 건수
Long completedPostCount = customPostRepository.getCountOfCompletedPosts(intermediaryId);

// 받은 후기 총 건수
Long reviewCount = customReviewRepository.getIntermediaryCountOfReviews(intermediaryId);

// 남긴 근황 총 건수
Long dogStatusCount = customDogStatusRepository.getIntermediaryCountOfDogStatuses(intermediaryId);

IntermediaryGetInfoResponse intermediaryInfo = IntermediaryGetInfoResponse.from(intermediary, completedPostCount, reviewCount, dogStatusCount);
IntermediaryGetInfoResponse intermediaryInfo = IntermediaryGetInfoResponse.from(intermediary);
return intermediaryInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ void setUp() {
void 이동봉사_중개_프로필_기본_정보_조회() throws Exception {
// given
Long intermediaryId = 1L;
IntermediaryGetInfoResponse response = new IntermediaryGetInfoResponse("profileImage", 3L,
"이동봉사 중개 이름", "안녕하세요. 한 줄 소개 입니다.", "https://connectdog.site", "인스타그램: @hoxjeong", "안내 사항입니다.", 25L, 20L);
IntermediaryGetInfoResponse response = new IntermediaryGetInfoResponse("profileImage",
"이동봉사 중개 이름", "안녕하세요. 한 줄 소개 입니다.", "https://connectdog.site", "인스타그램: @hoxjeong", "안내 사항입니다.");

// when
given(intermediaryService.getIntermediaryInfo(anyLong())).willReturn(response);
Expand Down

0 comments on commit 36cbfab

Please sign in to comment.