Skip to content

Commit

Permalink
[Fix] Fix Error
Browse files Browse the repository at this point in the history
  • Loading branch information
bayy1216 committed Jun 1, 2024
1 parent 5d71926 commit b17b79a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel;
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeCurrent;
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeRecord;
import org.haedal.zzansuni.domain.challengegroup.challengeverification.ChallengeVerificationModel;
import org.haedal.zzansuni.domain.challengegroup.verification.ChallengeVerificationModel;

public class ChallengeRes {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.haedal.zzansuni.domain.challengegroup.challenge;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
import lombok.Builder;
import lombok.Getter;
import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory;
import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup;
import org.haedal.zzansuni.domain.challengegroup.DayType;
import org.haedal.zzansuni.domain.challengegroup.userchallenge.UserChallenge;
import org.haedal.zzansuni.domain.challengegroup.verification.ChallengeVerification;

@Getter
Expand Down Expand Up @@ -76,5 +79,36 @@ public static ChallengeRecord from(Challenge challenge, ChallengeGroup challenge
}
}

@Builder
public record ChallengeCurrent(
Long challengeId,
String title,
Integer totalCount,
Integer successCount,
LocalDateTime participationDate,
LocalDate startDate,
LocalDate endDate,
ChallengeCategory category,
Boolean reviewWritten
) {

public static ChallengeCurrent from(UserChallenge userChallenge, Boolean reviewWritten) {
Challenge challenge = userChallenge.getChallenge();
return ChallengeCurrent.builder()
.challengeId(challenge.getId())
.title(challenge.getChallengeGroup().getTitle())
.totalCount(challenge.getRequiredCount())
.successCount(userChallenge.getChallengeVerifications().size())
.participationDate(userChallenge.getCreatedAt())
.startDate(challenge.getStartDate())
.endDate(challenge.getEndDate())
.category(challenge.getChallengeGroup().getCategory())
.reviewWritten(reviewWritten)
.build();
}

}



}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand;
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel;
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeReader;
import org.haedal.zzansuni.domain.challengegroup.challengereview.ChallengeReviewReader;
import org.haedal.zzansuni.domain.challengegroup.review.ChallengeReviewReader;
import org.haedal.zzansuni.domain.user.User;
import org.haedal.zzansuni.domain.user.UserReader;
import org.springframework.data.domain.Page;
Expand Down

0 comments on commit b17b79a

Please sign in to comment.