Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ public MentorDetailResponse getDetailBy(Long mentorId) {
Mentor mentor = mentorRepository.findById(mentorId)
.orElseThrow(() -> new CustomRuntimeException(MentorErrorCode.MENTOR_PROFILE_NOT_FOUND));

Member member = memberRepository.findById(mentor.getMemberId())
.orElseThrow(() -> new CustomRuntimeException(MemberErrorCode.MEMBER_NOT_FOUND));

return MentorDetailResponse.from(
member,
mentor,
mentoringRepository.findMentoringCountBy(mentorId)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package es.princip.ringus.application.mentor.service;

import es.princip.ringus.domain.exception.MemberErrorCode;
import es.princip.ringus.domain.exception.MentorErrorCode;
import es.princip.ringus.domain.member.Member;
import es.princip.ringus.domain.member.MemberRepository;
import es.princip.ringus.domain.mentor.Mentor;
import es.princip.ringus.domain.mentor.MentorRepository;
import es.princip.ringus.domain.mentoring.MentoringRepository;
Expand All @@ -15,11 +18,16 @@
@Transactional(readOnly = true)
public class MyMentorService {
private final MentorRepository mentorRepository;
private final MemberRepository memberRepository;
private final MentoringRepository mentoringRepository;

public MyMentorResponse getDetailBy(Long memberId) {
Mentor mentor = mentorRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomRuntimeException(MentorErrorCode.MENTOR_PROFILE_NOT_FOUND));
return MyMentorResponse.from(mentor, mentoringRepository.findMentoringCountBy(mentor.getId()));

Member member = memberRepository.findById(mentor.getMemberId())
.orElseThrow(() -> new CustomRuntimeException(MemberErrorCode.MEMBER_NOT_FOUND));

return MyMentorResponse.from(member, mentor, mentoringRepository.findMentoringCountBy(mentor.getId()));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package es.princip.ringus.presentation.mentor.dto;

import es.princip.ringus.domain.member.Member;
import es.princip.ringus.domain.mentor.Mentor;
import es.princip.ringus.domain.mentor.vo.Hashtag;
import es.princip.ringus.domain.mentor.vo.MentoringField;
Expand All @@ -9,7 +8,6 @@
import java.util.List;

public record MentorDetailResponse(
String email,
String nickname,
EducationResponse education,
OrganizationResponse organization,
Expand All @@ -22,12 +20,10 @@ public record MentorDetailResponse(
Long mentoringCount
) {
public static MentorDetailResponse from(
final Member member,
final Mentor mentor,
Long mentoringCount
) {
return new MentorDetailResponse(
member.getEmail(),
mentor.getNickname(),
EducationResponse.from(mentor.getEducation()),
OrganizationResponse.from(mentor.getOrganization()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package es.princip.ringus.presentation.mentor.dto;

import es.princip.ringus.domain.member.Member;
import es.princip.ringus.domain.mentor.Mentor;
import es.princip.ringus.domain.mentor.vo.Hashtag;
import es.princip.ringus.domain.mentor.vo.MentoringField;
Expand All @@ -8,6 +9,7 @@
import java.util.List;

public record MyMentorResponse(
String email,
String nickname,
EducationResponse education,
OrganizationResponse organization,
Expand All @@ -19,8 +21,9 @@ public record MyMentorResponse(
PortfolioResponse portfolio,
Long mentoringCount
) {
public static MyMentorResponse from(final Mentor mentor, Long mentoringCount) {
public static MyMentorResponse from(final Member member, final Mentor mentor, Long mentoringCount) {
return new MyMentorResponse(
member.getEmail(),
mentor.getNickname(),
EducationResponse.from(mentor.getEducation()),
OrganizationResponse.from(mentor.getOrganization()),
Expand Down