From de15f86848853b9d60700959882f82b1eeb83a5a Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Mon, 9 Sep 2024 15:33:23 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[Feat]:=20joinStartDate,=20joinEndDate=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ChallengeGroupModel.java | 127 ++++++++---------- 1 file changed, 58 insertions(+), 69 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java index c63b7d0..687e7a5 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java @@ -11,108 +11,97 @@ public class ChallengeGroupModel { public record Main( - Long id, - ChallengeCategory category, - String title, - String content, - Integer cumulativeCount + Long id, + ChallengeCategory category, + String title, + String content, + Integer cumulativeCount ) { + public static Main from(ChallengeGroup challengeGroup) { return new Main( - challengeGroup.getId(), - challengeGroup.getCategory(), - challengeGroup.getTitle(), - challengeGroup.getContent(), - challengeGroup.getCumulativeCount() + challengeGroup.getId(), + challengeGroup.getCategory(), + challengeGroup.getTitle(), + challengeGroup.getContent(), + challengeGroup.getCumulativeCount() ); } } @Builder public record Info( - Long id, - ChallengeCategory category, - String title, - String content, - String guide, - Integer cumulativeCount, - List challenges + Long id, + ChallengeCategory category, + String title, + String content, + String guide, + Integer cumulativeCount, + List challenges ) { - public LocalDate getMinStartDate() { - return challenges.stream() - .map(ChallengeModel.Main::startDate) - .min(LocalDate::compareTo) - .orElse(LocalDate.now()); - } - - public LocalDate getMaxEndDate() { - return challenges.stream() - .map(ChallengeModel.Main::endDate) - .max(LocalDate::compareTo) - .orElse(LocalDate.now()); - } public static Info from(ChallengeGroup challengeGroup) { var challenges = challengeGroup.getChallenges().stream() - .map(ChallengeModel.Main::from) - .toList(); + .map(ChallengeModel.Main::from) + .toList(); return Info.builder() - .id(challengeGroup.getId()) - .category(challengeGroup.getCategory()) - .title(challengeGroup.getTitle()) - .content(challengeGroup.getContent()) - .guide(challengeGroup.getGuide()) - .cumulativeCount(challengeGroup.getCumulativeCount()) - .challenges(challenges) - .build(); + .id(challengeGroup.getId()) + .category(challengeGroup.getCategory()) + .title(challengeGroup.getTitle()) + .content(challengeGroup.getContent()) + .guide(challengeGroup.getGuide()) + .cumulativeCount(challengeGroup.getCumulativeCount()) + .challenges(challenges) + .build(); } } @Builder public record Detail( - Long id, - ChallengeCategory category, - String title, - String content, - String guide, - Integer cumulativeCount, - List imageUrls, - List challenges + Long id, + ChallengeCategory category, + String title, + String content, + String guide, + Integer cumulativeCount, + List imageUrls, + List challenges ) { + public LocalDate getMinStartDate() { return challenges.stream() - .map(ChallengeModel.Main::startDate) - .min(LocalDate::compareTo) - .orElse(LocalDate.now()); + .map(ChallengeModel.Main::startDate) + .min(LocalDate::compareTo) + .orElse(LocalDate.now()); } public LocalDate getMaxEndDate() { return challenges.stream() - .map(ChallengeModel.Main::endDate) - .max(LocalDate::compareTo) - .orElse(LocalDate.now()); + .map(ChallengeModel.Main::endDate) + .max(LocalDate::compareTo) + .orElse(LocalDate.now()); } - public static Detail from(ChallengeGroup challengeGroup, List challengeGroupImages) { + public static Detail from(ChallengeGroup challengeGroup, + List challengeGroupImages) { var challenges = challengeGroup.getChallenges().stream() - .map(ChallengeModel.Main::from) - .toList(); + .map(ChallengeModel.Main::from) + .toList(); var imageUrls = challengeGroupImages.stream() - .map(ChallengeGroupImage::getImageUrl) - .toList(); + .map(ChallengeGroupImage::getImageUrl) + .toList(); return Detail.builder() - .id(challengeGroup.getId()) - .category(challengeGroup.getCategory()) - .title(challengeGroup.getTitle()) - .content(challengeGroup.getContent()) - .guide(challengeGroup.getGuide()) - .cumulativeCount(challengeGroup.getCumulativeCount()) - .imageUrls(imageUrls) - .challenges(challenges) - .build(); + .id(challengeGroup.getId()) + .category(challengeGroup.getCategory()) + .title(challengeGroup.getTitle()) + .content(challengeGroup.getContent()) + .guide(challengeGroup.getGuide()) + .cumulativeCount(challengeGroup.getCumulativeCount()) + .imageUrls(imageUrls) + .challenges(challenges) + .build(); } } - } From 383885e225a15edcf1abb32ff370050d3ff5a198 Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Mon, 9 Sep 2024 15:40:42 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[Feat]:=20startDate,=20endDate=20ChallengeG?= =?UTF-8?q?roup=20=EC=97=90=EC=84=9C=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChallengeGroupRes.java | 85 ++++++++++--------- .../application/ChallengeGroupModel.java | 4 + 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java index 0aba7e3..005d982 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java @@ -25,31 +25,33 @@ public record Info( ChallengeCategory category ) { + public static Info from( ChallengeGroupModel.Detail challengeGroupDetail - ){ + ) { return Info.builder() - .id(challengeGroupDetail.id()) - .title(challengeGroupDetail.title()) - .content(challengeGroupDetail.content()) - .participantCount(challengeGroupDetail.cumulativeCount()) - .startDate(challengeGroupDetail.getMinStartDate()) - .endDate(challengeGroupDetail.getMaxEndDate()) - .category(challengeGroupDetail.category()) - .build(); + .id(challengeGroupDetail.id()) + .title(challengeGroupDetail.title()) + .content(challengeGroupDetail.content()) + .participantCount(challengeGroupDetail.cumulativeCount()) + .startDate(challengeGroupDetail.getMinStartDate()) + .endDate(challengeGroupDetail.getMaxEndDate()) + .category(challengeGroupDetail.category()) + .build(); } + public static Info from( - ChallengeGroupModel.Info challengeGroupInfo - ){ + ChallengeGroupModel.Info challengeGroupInfo + ) { return Info.builder() - .id(challengeGroupInfo.id()) - .title(challengeGroupInfo.title()) - .content(challengeGroupInfo.content()) - .participantCount(challengeGroupInfo.cumulativeCount()) - .startDate(challengeGroupInfo.getMinStartDate()) - .endDate(challengeGroupInfo.getMaxEndDate()) - .category(challengeGroupInfo.category()) - .build(); + .id(challengeGroupInfo.id()) + .title(challengeGroupInfo.title()) + .content(challengeGroupInfo.content()) + .participantCount(challengeGroupInfo.cumulativeCount()) + .startDate(challengeGroupInfo.joinStartDate()) + .endDate(challengeGroupInfo.joinEndDate()) + .category(challengeGroupInfo.category()) + .build(); } } @@ -69,9 +71,10 @@ public record Detail( List imageUrls, List challenges ) { + public static Detail from( - ChallengeGroupModel.Detail challengeGroupDetail - ){ + ChallengeGroupModel.Detail challengeGroupDetail + ) { List challenges = challengeGroupDetail .challenges(); @@ -80,7 +83,6 @@ public static Detail from( .max(Integer::compareTo) .orElse(0); - return Detail.builder() .id(challengeGroupDetail.id()) .title(challengeGroupDetail.title()) @@ -110,9 +112,10 @@ public record Challenge( Integer successExp, Integer dayCount ) { + public static Challenge from( ChallengeModel.Main challenge - ){ + ) { return Challenge.builder() .id(challenge.id()) .participantCount(challenge.requiredCount()) @@ -126,26 +129,25 @@ public static Challenge from( } - - @Builder public record RankingPagingResponse( - List data, - Integer totalPage, - ChallengeGroupRes.Ranking myRanking //null이면 랭킹이 없는 것 + List data, + Integer totalPage, + ChallengeGroupRes.Ranking myRanking //null이면 랭킹이 없는 것 ) { + public static RankingPagingResponse from( - Page rankingPage, - ChallengeGroupRankingModel.Main myRanking - ){ + Page rankingPage, + ChallengeGroupRankingModel.Main myRanking + ) { var data = rankingPage.getContent().stream() .map(ChallengeGroupRes.Ranking::from) .toList(); return RankingPagingResponse.builder() - .data(data) - .totalPage(rankingPage.getTotalPages()) - .myRanking(ChallengeGroupRes.Ranking.from(myRanking)) - .build(); + .data(data) + .totalPage(rankingPage.getTotalPages()) + .myRanking(ChallengeGroupRes.Ranking.from(myRanking)) + .build(); } } @@ -158,15 +160,16 @@ public record Ranking( Integer acquiredPoint, UserRes.User user ) { + public static Ranking from( - ChallengeGroupRankingModel.Main model - ){ + ChallengeGroupRankingModel.Main model + ) { var user = UserRes.User.from(model.user()); return Ranking.builder() - .ranking(model.rank()) - .acquiredPoint(model.accumulatedPoint()) - .user(user) - .build(); + .ranking(model.rank()) + .acquiredPoint(model.accumulatedPoint()) + .user(user) + .build(); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java index 687e7a5..ba5f25c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java @@ -37,6 +37,8 @@ public record Info( String content, String guide, Integer cumulativeCount, + LocalDate joinStartDate, + LocalDate joinEndDate, List challenges ) { @@ -51,6 +53,8 @@ public static Info from(ChallengeGroup challengeGroup) { .content(challengeGroup.getContent()) .guide(challengeGroup.getGuide()) .cumulativeCount(challengeGroup.getCumulativeCount()) + .joinStartDate(challengeGroup.getJoinStartDate()) + .joinEndDate(challengeGroup.getJoinEndDate()) .challenges(challenges) .build(); } From 675a07c2c4ff3217b1f490d15d0539e3f925b02f Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Mon, 9 Sep 2024 15:56:00 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[Feat]:=20startDate,=20endDate=20ChallengeG?= =?UTF-8?q?roup=20=EC=97=90=EC=84=9C=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChallengeGroupRes.java | 4 ++-- .../application/ChallengeGroupModel.java | 18 ++++-------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java index 005d982..909b8ef 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java @@ -34,8 +34,8 @@ public static Info from( .title(challengeGroupDetail.title()) .content(challengeGroupDetail.content()) .participantCount(challengeGroupDetail.cumulativeCount()) - .startDate(challengeGroupDetail.getMinStartDate()) - .endDate(challengeGroupDetail.getMaxEndDate()) + .startDate(challengeGroupDetail.joinStartDate()) + .endDate(challengeGroupDetail.joinEndDate()) .category(challengeGroupDetail.category()) .build(); } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java index ba5f25c..02e74ff 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeGroupModel.java @@ -67,25 +67,13 @@ public record Detail( String title, String content, String guide, + LocalDate joinStartDate, + LocalDate joinEndDate, Integer cumulativeCount, List imageUrls, List challenges ) { - public LocalDate getMinStartDate() { - return challenges.stream() - .map(ChallengeModel.Main::startDate) - .min(LocalDate::compareTo) - .orElse(LocalDate.now()); - } - - public LocalDate getMaxEndDate() { - return challenges.stream() - .map(ChallengeModel.Main::endDate) - .max(LocalDate::compareTo) - .orElse(LocalDate.now()); - } - public static Detail from(ChallengeGroup challengeGroup, List challengeGroupImages) { var challenges = challengeGroup.getChallenges().stream() @@ -100,6 +88,8 @@ public static Detail from(ChallengeGroup challengeGroup, .title(challengeGroup.getTitle()) .content(challengeGroup.getContent()) .guide(challengeGroup.getGuide()) + .joinStartDate(challengeGroup.getJoinStartDate()) + .joinEndDate(challengeGroup.getJoinEndDate()) .cumulativeCount(challengeGroup.getCumulativeCount()) .imageUrls(imageUrls) .challenges(challenges) From 2efeeb674efc9bdec00192d44e706343350d2824 Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Mon, 9 Sep 2024 15:56:28 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[Feat]:=20startDate,=20endDate=20ChallengeG?= =?UTF-8?q?roup=20=EC=97=90=EC=84=9C=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zzansuni/challengegroup/controller/ChallengeGroupRes.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java index 909b8ef..e3a1741 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java @@ -88,8 +88,8 @@ public static Detail from( .title(challengeGroupDetail.title()) .content(challengeGroupDetail.content()) .participantCount(challengeGroupDetail.cumulativeCount()) - .startDate(challengeGroupDetail.getMinStartDate()) - .endDate(challengeGroupDetail.getMaxEndDate()) + .startDate(challengeGroupDetail.joinStartDate()) + .endDate(challengeGroupDetail.joinEndDate()) .category(challengeGroupDetail.category()) .guide(challengeGroupDetail.guide()) .maxDifficulty(maxDifficulty) From 50f860d174ccd8c6f14b3b1fc941ddb66ac53a51 Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Mon, 9 Sep 2024 17:32:54 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[Feat]:=20ChallengeModel=EC=97=90=20activeP?= =?UTF-8?q?eriod=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challengegroup/domain/application/ChallengeModel.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeModel.java index 90e2509..8cbaf85 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/domain/application/ChallengeModel.java @@ -18,9 +18,9 @@ public record Main( Integer onceExp, Integer successExp, Integer difficulty, - LocalDate startDate, - LocalDate endDate + Integer activePeriod ) { + public static Main from(Challenge challenge) { return Main.builder() .id(challenge.getId()) @@ -28,6 +28,7 @@ public static Main from(Challenge challenge) { .onceExp(challenge.getOnceExp()) .successExp(challenge.getSuccessExp()) .difficulty(challenge.getDifficulty()) + .activePeriod(challenge.getActivePeriod()) .build(); } } @@ -57,6 +58,4 @@ public static ChallengeVerificationResult from(Integer totalCount, Integer succe } - - } From 673c070e11ddaca97f0a876d3e99b6da92a5e5a9 Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Mon, 9 Sep 2024 19:27:15 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[Feat]:=20ChallengeGroupRes=20count=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challengegroup/controller/ChallengeGroupRes.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java index e3a1741..7a466e0 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java @@ -106,11 +106,10 @@ public static Detail from( public record Challenge( Long id, Integer participantCount, - Integer difficulty, Integer onceExp, Integer successExp, - Integer dayCount + Integer count ) { public static Challenge from( @@ -122,7 +121,7 @@ public static Challenge from( .difficulty(challenge.difficulty()) .onceExp(challenge.onceExp()) .successExp(challenge.successExp()) - .dayCount(challenge.requiredCount()) + .count(challenge.requiredCount()) .build(); } From 6450f87f8b58406a08a8fcb3b2f154f2917c9979 Mon Sep 17 00:00:00 2001 From: momnpa333 Date: Tue, 10 Sep 2024 18:58:52 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[Feat]:=20ChallengeGroupRes=20ParticipantCo?= =?UTF-8?q?unt=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zzansuni/challengegroup/controller/ChallengeGroupRes.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java index 7a466e0..04ebca5 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengegroup/controller/ChallengeGroupRes.java @@ -105,7 +105,6 @@ public static Detail from( @Builder public record Challenge( Long id, - Integer participantCount, Integer difficulty, Integer onceExp, Integer successExp, @@ -117,7 +116,6 @@ public static Challenge from( ) { return Challenge.builder() .id(challenge.id()) - .participantCount(challenge.requiredCount()) .difficulty(challenge.difficulty()) .onceExp(challenge.onceExp()) .successExp(challenge.successExp())