diff --git a/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberQueryService.java b/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberQueryService.java index 37fae32fa..5fc1a93a7 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberQueryService.java +++ b/backend/emm-sale/src/main/java/com/emmsale/member/application/MemberQueryService.java @@ -6,6 +6,7 @@ import com.emmsale.login.application.dto.MemberQueryResponse; import com.emmsale.member.application.dto.MemberProfileResponse; import com.emmsale.member.domain.Member; +import com.emmsale.member.domain.MemberActivityRepository; import com.emmsale.member.domain.MemberRepository; import com.emmsale.member.exception.MemberException; import lombok.RequiredArgsConstructor; @@ -18,6 +19,7 @@ public class MemberQueryService { private final MemberRepository memberRepository; + private final MemberActivityRepository memberActivityRepository; public Member findById(final Long memberId) { return memberRepository.findById(memberId) @@ -34,9 +36,8 @@ public MemberQueryResponse findOrCreateMember( return new MemberQueryResponse(member.getId(), member.isOnboarded()); } - public MemberProfileResponse findProfile(Long memberId) { - final Member member = memberRepository.findById(memberId) - .orElseThrow(() -> new MemberException(NOT_FOUND_MEMBER)); + public MemberProfileResponse findProfile(final Long memberId) { + final Member member = memberRepository.getByIdOrElseThrow(memberId); return MemberProfileResponse.from(member); } diff --git a/backend/emm-sale/src/main/java/com/emmsale/member/application/dto/MemberDetailResponse.java b/backend/emm-sale/src/main/java/com/emmsale/member/application/dto/MemberDetailResponse.java new file mode 100644 index 000000000..f5c9e82ae --- /dev/null +++ b/backend/emm-sale/src/main/java/com/emmsale/member/application/dto/MemberDetailResponse.java @@ -0,0 +1,41 @@ +package com.emmsale.member.application.dto; + +import static java.util.stream.Collectors.toUnmodifiableList; + +import com.emmsale.member.domain.Member; +import com.emmsale.member.domain.MemberActivity; +import java.util.List; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public class MemberDetailResponse { + + private static final String GITHUB_URL_PREFIX = "https://github.com/"; + + private final Long id; + private final String name; + private final String description; + private final String imageUrl; + private final String githubUrl; + private final List activities; + + public static MemberDetailResponse from( + final Member member, + final List activities + ) { + final List memberActivityResponses = activities.stream() + .map(MemberActivityResponse::from) + .collect(toUnmodifiableList()); + + return new MemberDetailResponse( + member.getId(), + member.getName(), + member.getDescription(), + member.getImageUrl(), + GITHUB_URL_PREFIX + member.getGithubUsername(), + memberActivityResponses + ); + } +}