Skip to content

Commit

Permalink
remove: 불필요한 삼항 연산자 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyu0218 committed Aug 2, 2024
1 parent 73a458e commit 8cd72c2
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ public List<MissionVerificationResponse> getVerifications(final MissionVerificat
.map(m -> {
MissionVerification v = verificationMap.get(m.getMember().getId());
return v != null
? toMissionVerificationResponse(true, m.getMember(), v)
: toMissionVerificationResponse(false, m.getMember(), null);
? MissionVerificationResponse.verified(m.getMember(), v)
: MissionVerificationResponse.notVerified(m.getMember());
})
.sorted(Comparator.comparing((MissionVerificationResponse r) -> r.nickname().equals(member.getNickname())).reversed()
.thenComparing(MissionVerificationResponse::isVerified).reversed()
.thenComparing(MissionVerificationResponse::verifiedAt, Comparator.nullsLast(Comparator.reverseOrder())))
.collect(Collectors.toList());
}
Expand All @@ -72,7 +71,7 @@ public MissionVerificationResponse getMyVerification(final MyMissionVerification
missionVerificationRepository.findByMemberIdAndMissionIdAndBoardNumber(command.memberId(), command.missionId(), command.number())
.orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_VERIFICATION));

return toMissionVerificationResponse(true, member, verification);
return MissionVerificationResponse.verified(member, verification);
}

@Transactional
Expand All @@ -94,15 +93,6 @@ public void createVerification(final CreateMissionVerificationCommand command) {
missionMember.verify();
}

private MissionVerificationResponse toMissionVerificationResponse(Boolean isVerified, Member member, MissionVerification verification) {
return new MissionVerificationResponse(
isVerified,
member.getNickname(),
isVerified ? verification.getImageUrl() : "",
isVerified ? verification.getCreatedAt() : null
);
}

private void checkVerificationValidation(final Long memberId, final Long missionId, final Mission mission, final MissionMember missionMember) {
if (isCompletedMission(mission, missionMember)) {
throw new BadRequestException(ErrorCode.ALREADY_COMPLETED_MISSION);
Expand Down

0 comments on commit 8cd72c2

Please sign in to comment.