diff --git a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java index d3c64735..5d331418 100644 --- a/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java +++ b/src/main/java/com/genius/gitget/challenge/instance/service/InstanceDetailService.java @@ -46,7 +46,7 @@ public InstanceResponse getInstanceDetailInformation(User user, Long instanceId) FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); LikesInfo likesInfo = getLikesInfo(user.getId(), instance); - if (participantProvider.hasParticipant(user.getId(), instanceId)) { + if (participantProvider.hasJoinedParticipant(user.getId(), instanceId)) { return InstanceResponse.createByEntity(instance, likesInfo, JoinStatus.YES, fileResponse); } @@ -90,7 +90,7 @@ private void validateJoinDate(Instance instance, LocalDate todayDate) { } private void validateInstanceCondition(User user, Instance instance) { - boolean isParticipated = participantProvider.hasParticipant(user.getId(), instance.getId()); + boolean isParticipated = participantProvider.hasJoinedParticipant(user.getId(), instance.getId()); if ((instance.getProgress() == Progress.PREACTIVITY) && !isParticipated) { return; } diff --git a/src/main/java/com/genius/gitget/challenge/participant/service/ParticipantProvider.java b/src/main/java/com/genius/gitget/challenge/participant/service/ParticipantProvider.java index ef418e7a..97d963bf 100644 --- a/src/main/java/com/genius/gitget/challenge/participant/service/ParticipantProvider.java +++ b/src/main/java/com/genius/gitget/challenge/participant/service/ParticipantProvider.java @@ -8,7 +8,6 @@ import com.genius.gitget.challenge.participant.domain.Participant; import com.genius.gitget.challenge.participant.repository.ParticipantRepository; import com.genius.gitget.global.util.exception.BusinessException; -import java.time.LocalDate; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -65,12 +64,9 @@ public List findJoinedByProgress(Long userId, Progress progress) { return participantRepository.findAllJoinedByProgress(userId, progress); } - public boolean hasParticipant(Long userId, Long instanceId) { - return participantRepository.findByJoinInfo(userId, instanceId).isPresent(); - } - - public LocalDate getInstanceStartDate(Long participantId) { - return getInstanceById(participantId).getStartedDate().toLocalDate(); + public boolean hasJoinedParticipant(Long userId, Long instanceId) { + return participantRepository.findByJoinInfo(userId, instanceId) + .map(participant -> participant.getJoinStatus() != JoinStatus.NO) + .orElse(false); } - }