-
Notifications
You must be signed in to change notification settings - Fork 1
[feat] #110 매칭 상세조회 API 기능 구현 #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
30ee68f
[feat] #110 MatchingDetailInfo 생성
2hyunjinn 3aa2240
[feat] #110 매칭 상세 조회 API 기능 구현
2hyunjinn 89cb531
[test] #110 매칭과 페스티벌이 일치하지 않는 경우 테스트 코드 구현
2hyunjinn c00b2a0
[fix] #110 없는 매칭일 경우 에러 발생
2hyunjinn 366a97a
[fix] #110 Optional 로 변경
2hyunjinn 8ac5fb3
[test] #110 테스트코드 매칭 조회 시 Optional 로 변경
2hyunjinn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/org/festimate/team/api/matching/dto/MatchingDetailInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.festimate.team.api.matching.dto; | ||
|
|
||
| import org.festimate.team.domain.matching.entity.Matching; | ||
| import org.festimate.team.domain.participant.entity.Participant; | ||
| import org.festimate.team.domain.participant.entity.TypeResult; | ||
| import org.festimate.team.domain.user.entity.AppearanceType; | ||
| import org.festimate.team.domain.user.entity.Gender; | ||
| import org.festimate.team.domain.user.entity.Mbti; | ||
|
|
||
| public record MatchingDetailInfo( | ||
| String nickname, | ||
| Gender gender, | ||
| Integer birthYear, | ||
| Mbti mbti, | ||
| AppearanceType appearance, | ||
| String introduction, | ||
| String message, | ||
| TypeResult typeResult | ||
| ) { | ||
| public static MatchingDetailInfo from(Matching matching) { | ||
| Participant participant = matching.getTargetParticipant(); | ||
| return new MatchingDetailInfo( | ||
| participant.getUser().getNickname(), | ||
| participant.getUser().getGender(), | ||
| participant.getUser().getBirthYear(), | ||
| participant.getUser().getMbti(), | ||
| participant.getUser().getAppearanceType(), | ||
| participant.getIntroduction(), | ||
| participant.getMessage(), | ||
| participant.getTypeResult() | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add null check to prevent potential NullPointerException.
The
frommethod doesn't handle the case whenmatching.getTargetParticipant()is null, which could happen for PENDING matchings as seen in the test file where some matchings have null target participants.Consider adding a null check before accessing the participant's properties:
public static MatchingDetailInfo from(Matching matching) { Participant participant = matching.getTargetParticipant(); + if (participant == null) { + return new MatchingDetailInfo( + null, null, null, null, null, null, null, null + ); + } return new MatchingDetailInfo( participant.getUser().getNickname(), participant.getUser().getGender(), participant.getUser().getBirthYear(), participant.getUser().getMbti(), participant.getUser().getAppearanceType(), participant.getIntroduction(), participant.getMessage(), participant.getTypeResult() ); }Alternatively, you might want to create a separate DTO for pending matchings or throw an appropriate exception if this method should only be called for completed matchings.