-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Issue/#5 2
- Loading branch information
Showing
31 changed files
with
662 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 23 additions & 3 deletions
26
...p/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java
This file contains 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 |
---|---|---|
@@ -1,15 +1,35 @@ | ||
package org.haedal.zzansuni.controller.challengegroup.challenge; | ||
|
||
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; | ||
import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public class ChallengeReq { | ||
|
||
public record ChallengeVerificationRequest( | ||
String content | ||
String content | ||
) { | ||
|
||
public ChallengeCommand.Verificate toCommand(MultipartFile image) { | ||
return ChallengeCommand.Verificate.builder() | ||
.content(content) | ||
.image(image) | ||
.build(); | ||
} | ||
|
||
} | ||
|
||
public record ChallengeReviewCreateRequest( | ||
String content, | ||
Integer rating | ||
String content, | ||
Integer rating | ||
) { | ||
|
||
public ChallengeCommand.ReviewCreate toCommand() { | ||
return ChallengeCommand.ReviewCreate.builder() | ||
.content(content) | ||
.rating(rating) | ||
.build(); | ||
} | ||
} | ||
|
||
} |
This file contains 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 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
46 changes: 46 additions & 0 deletions
46
...p/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeCommand.java
This file contains 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,46 @@ | ||
package org.haedal.zzansuni.domain.challengegroup.challenge; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.haedal.zzansuni.core.utils.SelfValidating; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public class ChallengeCommand { | ||
|
||
@Getter | ||
@Builder | ||
public static class Verificate extends SelfValidating<Verificate> { | ||
|
||
@NotBlank(message = "내용은 필수입니다.") | ||
private final String content; | ||
|
||
@NotNull(message = "이미지는 필수입니다.") | ||
private final MultipartFile image; | ||
|
||
public Verificate(String content, MultipartFile image) { | ||
this.content = content; | ||
this.image = image; | ||
this.validateSelf(); | ||
} | ||
} | ||
|
||
@Getter | ||
@Builder | ||
public static class ReviewCreate extends SelfValidating<ReviewCreate> { | ||
|
||
@NotBlank(message = "내용은 필수입니다.") | ||
private final String content; | ||
|
||
@NotNull(message = "평점은 필수입니다.") | ||
private final Integer rating; | ||
|
||
public ReviewCreate(String content, Integer rating) { | ||
this.content = content; | ||
this.rating = rating; | ||
this.validateSelf(); | ||
} | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...rc/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeCurrentDto.java
This file contains 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,36 @@ | ||
package org.haedal.zzansuni.domain.challengegroup.challenge; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; | ||
|
||
@Getter | ||
public class ChallengeCurrentDto { | ||
|
||
private final Long challengeId; | ||
private final String title; | ||
private final Integer successCount; | ||
private final Integer totalCount; | ||
private final LocalDateTime participationDate; | ||
private final LocalDate startDate; | ||
private final LocalDate endDate; | ||
private final ChallengeCategory category; | ||
private final Boolean reviewWritten; | ||
|
||
// 생성자 추가 | ||
public ChallengeCurrentDto(Long challengeId, String title, Integer successCount, | ||
Integer totalCount, LocalDateTime participationDate, LocalDate startDate, LocalDate endDate, | ||
ChallengeCategory category, Boolean reviewWritten) { | ||
this.challengeId = challengeId; | ||
this.title = title; | ||
this.successCount = successCount; | ||
this.totalCount = totalCount; | ||
this.participationDate = participationDate; | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
this.category = category; | ||
this.reviewWritten = reviewWritten; | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeModel.java
This file contains 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,80 @@ | ||
package org.haedal.zzansuni.domain.challengegroup.challenge; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; | ||
import org.haedal.zzansuni.domain.challengegroup.DayType; | ||
import org.haedal.zzansuni.domain.challengegroup.challengeverification.ChallengeVerification; | ||
|
||
@Getter | ||
@Builder | ||
public class ChallengeModel { | ||
|
||
private Long id; | ||
private ChallengeGroup challengeGroup; | ||
private Integer requiredCount; | ||
private DayType dayType; | ||
private Integer onceExp; | ||
private Integer successExp; | ||
private Integer difficulty; | ||
|
||
public static ChallengeModel from(Challenge challenge) { | ||
return ChallengeModel.builder() | ||
.id(challenge.getId()) | ||
.challengeGroup(challenge.getChallengeGroup()) | ||
.requiredCount(challenge.getRequiredCount()) | ||
.dayType(challenge.getDayType()) | ||
.onceExp(challenge.getOnceExp()) | ||
.successExp(challenge.getSuccessExp()) | ||
.difficulty(challenge.getDifficulty()) | ||
.build(); | ||
} | ||
|
||
@Builder | ||
public record ChallengeVerificationResult(Integer totalCount, Integer successCount, | ||
Integer obtainExp) { | ||
|
||
public static ChallengeVerificationResult of(Integer totalCount, Integer successCount, | ||
Integer obtainExp) { | ||
return ChallengeVerificationResult.builder() | ||
.totalCount(totalCount) | ||
.successCount(successCount) | ||
.obtainExp(obtainExp) | ||
.build(); | ||
} | ||
|
||
public static ChallengeVerificationResult from(Integer totalCount, Integer successCount, | ||
Integer obtainExp) { | ||
return ChallengeVerificationResult.builder() | ||
.totalCount(totalCount) | ||
.successCount(successCount) | ||
.obtainExp(obtainExp) | ||
.build(); | ||
} | ||
} | ||
|
||
|
||
@Builder | ||
public record ChallengeRecord(String title, Integer totalCount, Integer successCount, | ||
LocalDate startDate, LocalDate endDate, List<Long> recordIds) { | ||
|
||
public static ChallengeRecord from(Challenge challenge, ChallengeGroup challengeGroup, | ||
List<ChallengeVerification> challengeVerificationList) { | ||
return ChallengeRecord.builder() | ||
.title(challengeGroup.getTitle()) | ||
.totalCount(challenge.getRequiredCount()) | ||
.successCount(challengeVerificationList.size()) | ||
.startDate(challenge.getStartDate()) | ||
.endDate(challenge.getEndDate()) | ||
.recordIds(challengeVerificationList.stream() | ||
.map(ChallengeVerification::getId) | ||
.collect(Collectors.toList())) | ||
.build(); | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.