diff --git a/src/main/java/com/togedong/member/controller/dto/ChallengeResponse.java b/src/main/java/com/togedong/member/controller/dto/ChallengeResponse.java index 4ca6a2f..335cf55 100644 --- a/src/main/java/com/togedong/member/controller/dto/ChallengeResponse.java +++ b/src/main/java/com/togedong/member/controller/dto/ChallengeResponse.java @@ -2,7 +2,7 @@ import com.togedong.participant.ParticipantStatus; -public record ChallengeResponse(String description, int participantCount, int progressPercent, +public record ChallengeResponse(String challengeId, String description, int participantCount, int progressPercent, ParticipantStatus isParticipating ) { diff --git a/src/main/java/com/togedong/member/service/DefaultMemberService.java b/src/main/java/com/togedong/member/service/DefaultMemberService.java index cdbfd7a..905abd9 100644 --- a/src/main/java/com/togedong/member/service/DefaultMemberService.java +++ b/src/main/java/com/togedong/member/service/DefaultMemberService.java @@ -33,6 +33,8 @@ @Slf4j public class DefaultMemberService implements MemberService { + private static final int NOT_PARTICIPANT_COUNT = 0; + private final MemberRepository userRepository; private final ParticipantService participantService; private final ChallengeService challengeService; @@ -97,13 +99,15 @@ private ChallengeResponse includeMemberInfo(final Challenge challenge, final Mem log.info("participant count : " + participantCount); if (!participantService.alreadyParticipate(member, challenge)) { - return new ChallengeResponse(description, participantCount, 0, + return new ChallengeResponse(challenge.getId(), description, participantCount, + NOT_PARTICIPANT_COUNT, NOT_PARTICIPANT); } int progressPercent = challenge.calculateProgressPercent( member.calculateRecordsSum(challenge.getExercise())); - return new ChallengeResponse(description, participantCount, progressPercent, PARTICIPANT); + return new ChallengeResponse(challenge.getId(), description, participantCount, + progressPercent, PARTICIPANT); } private Member findMemberByName(final String name) {