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 @@ -6,7 +6,9 @@
import es.princip.ringus.domain.member.Member;
import es.princip.ringus.domain.member.MemberRepository;
import es.princip.ringus.domain.member.MemberType;
import es.princip.ringus.domain.mentee.Mentee;
import es.princip.ringus.domain.mentee.MenteeRepository;
import es.princip.ringus.domain.mentor.Mentor;
import es.princip.ringus.domain.mentor.MentorRepository;
import es.princip.ringus.domain.mentor.vo.Organization;
import es.princip.ringus.domain.serviceTerm.ServiceTermAgreement;
Expand All @@ -15,6 +17,8 @@
import es.princip.ringus.infra.storage.domain.ProfileImage;
import es.princip.ringus.presentation.auth.dto.request.SignUpRequest;
import es.princip.ringus.presentation.member.dto.MemberResponse;
import es.princip.ringus.presentation.member.dto.MenteeProfileResponse;
import es.princip.ringus.presentation.member.dto.MentorProfileResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -56,15 +60,18 @@ public MemberResponse getMember(Long memberId) {
.orElseThrow(() -> new CustomRuntimeException(MemberErrorCode.MEMBER_NOT_FOUND));

if (member.isProfileRegistered()) {
if (member.getMemberType().equals(MemberType.ROLE_MENTEE)) {
ProfileImage img = menteeRepository.findProfileByMemberId(member.getId());
Education education = menteeRepository.findEducationByMemberId(member.getId());
if (member.isMentee()) {
Mentee mentee = menteeRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomRuntimeException(MemberErrorCode.MEMBER_NOT_FOUND));
MenteeProfileResponse profile = MenteeProfileResponse.from(mentee);
//null check 필요
return MemberResponse.of(member, img.getFilePath(), education);
} else if (member.getMemberType().equals(MemberType.ROLE_MENTOR)) {
ProfileImage img = mentorRepository.findProfileByMemberId(member.getId());
Organization organization = mentorRepository.findOrganizationByMemberId(member.getId());
return MemberResponse.of(member, img.getFilePath(), organization);
return MemberResponse.of(member, profile);
} else if (member.isMentor()) {
Mentor mentor = mentorRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomRuntimeException(MemberErrorCode.MEMBER_NOT_FOUND));

MentorProfileResponse profile = MentorProfileResponse.from(mentor);
return MemberResponse.of(member, profile);
}
}
return MemberResponse.of(member);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/es/princip/ringus/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,12 @@ public boolean isNotMentor() {
public boolean isNotMentee() {
return this.memberType != MemberType.ROLE_MENTEE;
}

public boolean isMentor() {
return this.memberType == MemberType.ROLE_MENTOR;
}

public boolean isMentee() {
return this.memberType == MemberType.ROLE_MENTEE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,40 @@ public record MemberResponse(
boolean isFileVerified,
boolean isProfileRegisterd,
boolean isUniversityVerified,
@JsonInclude(NON_NULL) String imgUrl,
@JsonInclude(NON_NULL) EducationResponse education,
@JsonInclude(NON_NULL) OrganizationResponse organization
@JsonInclude(NON_NULL) MenteeProfileResponse menteeProfile,
@JsonInclude(NON_NULL) MentorProfileResponse mentorProfile
) {
public static MemberResponse of(Member member) {
public static MemberResponse of(final Member member) {
return new MemberResponse(
member.getId(),
member.getMemberType(),
member.isProfileRegistered(),
member.isProfileRegistered(),
member.isUniversityVerified(),
null,
null,
null
);
}
public static MemberResponse of(Member member, String imgUrl, Education education) {
public static MemberResponse of(final Member member, final MenteeProfileResponse profile) {
return new MemberResponse(
member.getId(),
member.getMemberType(),
member.isProfileRegistered(),
member.isProfileRegistered(),
member.isUniversityVerified(),
imgUrl,
EducationResponse.from(education),
profile,
null
);
}
public static MemberResponse of(Member member, String imgUrl, Organization organization) {
public static MemberResponse of(final Member member, final MentorProfileResponse profile) {
return new MemberResponse(
member.getId(),
member.getMemberType(),
member.isProfileRegistered(),
member.isProfileRegistered(),
member.isUniversityVerified(),
imgUrl,
null,
OrganizationResponse.from(organization)
profile
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package es.princip.ringus.presentation.member.dto;

import es.princip.ringus.domain.mentee.Mentee;
import es.princip.ringus.presentation.common.dto.EducationResponse;

public record MenteeProfileResponse(
String nickname,
String imgUrl,
EducationResponse education
) {
public static MenteeProfileResponse from(final Mentee mentee) {
return new MenteeProfileResponse(mentee.getNickname(), mentee.getProfileImage().getFilePath(), EducationResponse.from(mentee.getEducation()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package es.princip.ringus.presentation.member.dto;

import es.princip.ringus.domain.mentor.Mentor;
import es.princip.ringus.presentation.common.dto.OrganizationResponse;

public record MentorProfileResponse(
String nickname,
String imgUrl,
OrganizationResponse organization
) {
public static MentorProfileResponse from(final Mentor mentor){
return new MentorProfileResponse(mentor.getNickname(), mentor.getProfileImage().getFilePath(), OrganizationResponse.from(mentor.getOrganization()));
}
}