From 19cb9fe4cc3eff5a04b0b7a3535c223109ce12c5 Mon Sep 17 00:00:00 2001 From: kwonssshyeon Date: Wed, 25 Sep 2024 15:32:34 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[Feat]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EC=97=94=ED=8B=B0=ED=8B=B0=EC=97=90=20?= =?UTF-8?q?=EB=82=9C=EC=9D=B4=EB=8F=84,=20=EC=84=B1=EC=B7=A8=EB=8F=84=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zzansuni/challengereview/domain/ChallengeReview.java | 8 ++++++++ .../main/resources/db/migration/V4__add_column_review.sql | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReview.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReview.java index 6eae2ef..f8c1093 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReview.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReview.java @@ -38,6 +38,12 @@ public class ChallengeReview extends BaseTimeEntity { @Column(nullable = false) private Long challengeGroupId; + @Column(nullable = false) + private Integer difficulty; + + @Column(nullable = false) + private Integer achievement; + public static ChallengeReview create(UserChallenge userChallenge, ChallengeReviewCommand.Create command) { Long challengeGroupId = userChallenge.getChallenge().getChallengeGroupId(); return ChallengeReview.builder() @@ -45,6 +51,8 @@ public static ChallengeReview create(UserChallenge userChallenge, ChallengeRevie .content(command.getContent()) .rating(command.getRating()) .challengeGroupId(challengeGroupId) + .difficulty(command.getDifficulty()) + .achievement(command.getAchievement()) .build(); } diff --git a/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql b/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql new file mode 100644 index 0000000..61258a1 --- /dev/null +++ b/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql @@ -0,0 +1,2 @@ +ALTER TABLE challenge_review ADD COLUMN difficulty BIGINT NOT NULL; +ALTER TABLE challenge_review ADD COLUMN achievement BIGINT NOT NULL; \ No newline at end of file From e3eda069233208dc8dda5bad0c0faa56c7183afc Mon Sep 17 00:00:00 2001 From: kwonssshyeon Date: Wed, 25 Sep 2024 15:32:54 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[Feat]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EC=9E=91=EC=84=B1=20=EC=88=98=EC=A0=95(?= =?UTF-8?q?=EB=82=9C=EC=9D=B4=EB=8F=84,=20=EC=84=B1=EC=B7=A8=EB=8F=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChallengeReviewReq.java | 8 +++++++- .../domain/ChallengeReviewCommand.java | 14 +++++++++++++- .../domain/application/RecordServiceTest.java | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewReq.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewReq.java index 67add1c..5226f7f 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewReq.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewReq.java @@ -7,13 +7,19 @@ public class ChallengeReviewReq { public record Create( String content, @Schema(description = "평점", example = "5") - Integer rating + Integer rating, + @Schema(description = "체감 난이도", example = "1") + Integer difficulty, + @Schema(description = "성취도", example = "1") + Integer achievement ) { public ChallengeReviewCommand.Create toCommand() { return ChallengeReviewCommand.Create.builder() .content(content) .rating(rating) + .difficulty(difficulty) + .achievement(achievement) .build(); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewCommand.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewCommand.java index d555d1e..1fa0ec0 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewCommand.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewCommand.java @@ -20,10 +20,22 @@ public static class Create extends SelfValidating { @Max(5) private final Integer rating; + @NotNull(message = "평점은 필수입니다.") + @Min(1) + @Max(5) + private final Integer difficulty; + + @NotNull(message = "평점은 필수입니다.") + @Min(1) + @Max(3) + private final Integer achievement; + @Builder - public Create(String content, Integer rating) { + public Create(String content, Integer rating, Integer difficulty, Integer achievement) { this.content = content; this.rating = rating; + this.difficulty = difficulty; + this.achievement = achievement; this.validateSelf(); } diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/userchallenge/domain/application/RecordServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/userchallenge/domain/application/RecordServiceTest.java index 6f50f18..4df8714 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/userchallenge/domain/application/RecordServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/userchallenge/domain/application/RecordServiceTest.java @@ -146,7 +146,7 @@ void createReview() { Long userId = 1L; Long challengeId = 1L; ChallengeReviewCommand.Create command = new ChallengeReviewCommand.Create( - "Great challenge!", 5); + "Great challenge!", 5,1,1); when(userChallengeReader.findByUserIdAndChallengeId(userId, challengeId)).thenReturn( Optional.of(userChallenge)); From 80dc94e529ff40e54275404a55ea96d223be8b15 Mon Sep 17 00:00:00 2001 From: kwonssshyeon Date: Wed, 25 Sep 2024 15:52:11 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Feat]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EB=82=9C?= =?UTF-8?q?=EC=9D=B4=EB=8F=84,=EC=84=B1=EC=B7=A8=EB=8F=84,=EC=9E=91?= =?UTF-8?q?=EC=84=B1=EC=9D=BC=EC=9E=90=20=ED=95=84=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challengereview/controller/ChallengeReviewRes.java | 9 ++++++++- .../challengereview/domain/ChallengeReviewModel.java | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewRes.java index 94d0579..d4dbffe 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/controller/ChallengeReviewRes.java @@ -1,5 +1,6 @@ package org.haedal.zzansuni.challengereview.controller; +import java.time.LocalDateTime; import java.util.Map; import lombok.Builder; import org.haedal.zzansuni.user.controller.UserRes; @@ -40,7 +41,10 @@ public record InfoWithChallenge( Integer challengeDifficulty, UserRes.User user, String content, - Integer rating + Integer rating, + Integer difficulty, + Integer achievement, + LocalDateTime createdAt ) { public static InfoWithChallenge from( @@ -53,6 +57,9 @@ public static InfoWithChallenge from( .user(user) .content(challengeReviewWithChallenge.content()) .rating(challengeReviewWithChallenge.rating()) + .difficulty(challengeReviewWithChallenge.difficulty()) + .achievement(challengeReviewWithChallenge.achievement()) + .createdAt(challengeReviewWithChallenge.createdAt()) .build(); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewModel.java index 9834ebd..dee989f 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/challengereview/domain/ChallengeReviewModel.java @@ -1,5 +1,6 @@ package org.haedal.zzansuni.challengereview.domain; +import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,7 +43,10 @@ public record ChallengeReviewWithChallenge( Integer challengeDifficulty, UserModel.Main user, String content, - Integer rating + Integer rating, + Integer difficulty, + Integer achievement, + LocalDateTime createdAt ) { public static ChallengeReviewWithChallenge from(ChallengeReview challengeReview) { @@ -58,6 +62,9 @@ public static ChallengeReviewWithChallenge from(ChallengeReview challengeReview) .user(userModel) .content(challengeReview.getContent()) .rating(challengeReview.getRating()) + .difficulty(challengeReview.getDifficulty()) + .achievement(challengeReview.getAchievement()) + .createdAt(challengeReview.getCreatedAt()) .build(); } From 4d55a62550d894847fd8d91e335257c2c0b8f731 Mon Sep 17 00:00:00 2001 From: kwonssshyeon Date: Wed, 25 Sep 2024 15:52:32 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Feat]:=20ddl=20update=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=B4=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/ChallengeReviewReaderImplTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/challengereview/infrastructure/ChallengeReviewReaderImplTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/challengereview/infrastructure/ChallengeReviewReaderImplTest.java index 446e037..2298d48 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/challengereview/infrastructure/ChallengeReviewReaderImplTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/challengereview/infrastructure/ChallengeReviewReaderImplTest.java @@ -64,6 +64,8 @@ void getScoreModelByChallengeGroupId() { .userChallenge(userChallenge) .content("content") .rating(i % 4 + 1) + .difficulty(1) + .achievement(1) .build()) .toList(); // -> 1:3 / 2:3 / 3:3 / 4:2 / 5:0 From 7fd153da93dcc77f43aafa2bda07d35142cfa468 Mon Sep 17 00:00:00 2001 From: kwonssshyeon <104684033+kwonssshyeon@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:18:14 +0900 Subject: [PATCH 5/5] Update zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 손홍석 <78216059+bayy1216@users.noreply.github.com> --- .../main/resources/db/migration/V4__add_column_review.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql b/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql index 61258a1..fb83052 100644 --- a/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql +++ b/zzansuni-api-server/app/src/main/resources/db/migration/V4__add_column_review.sql @@ -1,2 +1,5 @@ -ALTER TABLE challenge_review ADD COLUMN difficulty BIGINT NOT NULL; -ALTER TABLE challenge_review ADD COLUMN achievement BIGINT NOT NULL; \ No newline at end of file +ALTER TABLE challenge_review ADD COLUMN difficulty TINYINT DEFULT(1) NOT NULL; +ALTER TABLE challenge_review ADD COLUMN achievement TINYINT DEFULT(1) NOT NULL; + +ALTER TABLE challenge_review ALTER COLUMN difficulty DROP DEFAULT; +ALTER TABLE challenge_review ALTER COLUMN achievement DROP DEFAULT; \ No newline at end of file