From 04bddefedd9c571a071e5ad75f7c4a0cc580befe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:59:18 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[Refactor]:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20nesting=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/AdminController.java | 2 +- .../ChallengeGroupController.java | 4 +-- .../challengegroup/ChallengeGroupRes.java | 4 +-- .../challenge/ChallengeController.java | 10 +++---- .../challenge/ChallengeReq.java | 2 +- .../challenge/ChallengeRes.java | 10 +++---- .../review/ChallengeReviewController.java | 6 ++-- .../review/ChallengeReviewRes.java | 6 ++-- .../{challenge => }/Challenge.java | 5 +--- .../{challenge => }/ChallengeCommand.java | 2 +- .../domain/challengegroup/ChallengeGroup.java | 1 - .../{challenge => }/ChallengeStatus.java | 2 +- .../ChallengeGroupModel.java | 5 ++-- .../ChallengeGroupQueryService.java | 7 +++-- .../ChallengeGroupService.java | 4 ++- .../ChallengeModel.java | 5 ++-- .../ChallengeService.java | 28 ++++++++++--------- .../challenge/port/ChallengeStore.java | 5 ---- .../port/ChallengeGroupReader.java | 4 +-- .../{challenge => }/port/ChallengeReader.java | 4 +-- .../challengegroup/port/ChallengeStore.java | 5 ++++ .../{userexp => }/ChallengeGroupUserExp.java | 2 +- .../{review => }/ChallengeReview.java | 5 ++-- .../ChallengeVerification.java | 5 ++-- .../ChallengeVerificationStatus.java | 2 +- .../domain/userchallenge/UserChallenge.java | 7 ++--- .../AddUserExpByVerificationUseCase.java | 5 ++-- .../ChallengeReviewModel.java | 5 ++-- .../ChallengeVerificationModel.java | 3 +- .../UserChallengeService.java | 18 ++++++------ .../port/ChallengeGroupUserExpStore.java | 7 +++++ .../port/ChallengeReviewReader.java | 4 +-- .../port/ChallengeReviewStore.java | 9 ++++++ .../port/ChallengeVerificationReader.java | 4 +-- .../review/port/ChallengeReviewStore.java | 9 ------ .../port/ChallengeGroupUserExpStore.java | 7 ----- .../{challenge => }/ChallengeRepository.java | 4 +-- .../ChallengeGroupImageReaderImpl.java | 3 +- .../ChallengeGroupReaderImpl.java | 7 +++-- .../ChallengeGroupStoreImpl.java | 3 +- .../ChallengeReaderImpl.java | 7 +++-- .../ChallengeStoreImpl.java | 5 ++-- .../ChallengeGroupUserExpRepository.java | 2 +- .../ChallengeGroupUserExpStoreImpl.java | 4 +-- .../review/ChallengeReviewReaderImpl.java | 4 +-- .../review/ChallengeReviewRepository.java | 2 +- .../review/ChallengeReviewStoreImpl.java | 4 +-- .../UserChallengeReaderImpl.java | 2 +- .../ChallengeVerificationReaderImpl.java | 4 +-- .../ChallengeVerificationRepository.java | 2 +- .../ChallengeGroupQueryServiceTest.java | 8 ++++-- .../ChallengeGroupServiceTest.java | 4 +-- .../challenge/ChallengeServiceTest.java | 26 ++++++++--------- .../UserChallengeServiceTest.java | 19 ++++++------- 54 files changed, 167 insertions(+), 156 deletions(-) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{challenge => }/Challenge.java (88%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{challenge => }/ChallengeCommand.java (97%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{challenge => }/ChallengeStatus.java (82%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{ => application}/ChallengeGroupModel.java (95%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{ => application}/ChallengeGroupQueryService.java (88%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{ => application}/ChallengeGroupService.java (82%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{challenge => application}/ChallengeModel.java (96%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{challenge => application}/ChallengeService.java (76%) delete mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeStore.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/{challenge => }/port/ChallengeReader.java (51%) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{userexp => }/ChallengeGroupUserExp.java (95%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{review => }/ChallengeReview.java (86%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{verification => }/ChallengeVerification.java (84%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{verification => }/ChallengeVerificationStatus.java (77%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{ => application}/AddUserExpByVerificationUseCase.java (78%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{review => application}/ChallengeReviewModel.java (94%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{verification => application}/ChallengeVerificationModel.java (83%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{ => application}/UserChallengeService.java (87%) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{review => }/port/ChallengeReviewReader.java (84%) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewStore.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/{verification => }/port/ChallengeVerificationReader.java (74%) delete mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewStore.java delete mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/port/ChallengeGroupUserExpStore.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/{challenge => }/ChallengeRepository.java (51%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/{ => adapter}/ChallengeGroupImageReaderImpl.java (80%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/{ => adapter}/ChallengeGroupReaderImpl.java (95%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/{ => adapter}/ChallengeGroupStoreImpl.java (82%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/{challenge => adapter}/ChallengeReaderImpl.java (67%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/{challenge => adapter}/ChallengeStoreImpl.java (53%) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/admin/AdminController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/admin/AdminController.java index ba9a83a..0fe06cb 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/admin/AdminController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/admin/AdminController.java @@ -7,7 +7,7 @@ import org.haedal.zzansuni.controller.auth.AuthReq; import org.haedal.zzansuni.core.api.ApiResponse; import org.haedal.zzansuni.domain.auth.AuthService; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupService; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupService; import org.springframework.http.HttpStatus; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.*; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java index 18cdf4f..6cfbf34 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java @@ -8,8 +8,8 @@ import org.haedal.zzansuni.controller.PagingResponse; import org.haedal.zzansuni.core.api.ApiResponse; import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupModel; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupQueryService; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupQueryService; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java index 3b83ab4..91ae6af 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java @@ -3,9 +3,9 @@ import lombok.Builder; import org.haedal.zzansuni.controller.user.UserRes; import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.DayType; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; import org.springframework.data.domain.Page; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java index 597be36..4738f19 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java @@ -10,11 +10,11 @@ import org.haedal.zzansuni.controller.challengegroup.challenge.ChallengeRes.ChallengeCompleteResponse; import org.haedal.zzansuni.core.api.ApiResponse; import org.haedal.zzansuni.domain.ImageUploader; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeComplete; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeCurrent; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeService; -import org.haedal.zzansuni.domain.userchallenge.UserChallengeService; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeComplete; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeCurrent; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; +import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeService; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java index 4f83d74..c24fea5 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java @@ -1,6 +1,6 @@ package org.haedal.zzansuni.controller.challengegroup.challenge; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; import org.springframework.web.multipart.MultipartFile; public class ChallengeReq { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java index 65105a9..a3f7e66 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java @@ -6,11 +6,11 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeComplete; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeCurrent; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeRecord; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerificationModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeComplete; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeCurrent; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; public class ChallengeRes { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java index 64f6c89..463754e 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java @@ -8,9 +8,9 @@ import org.haedal.zzansuni.controller.PagingResponse; import org.haedal.zzansuni.controller.challengegroup.challenge.ChallengeReq; import org.haedal.zzansuni.core.api.ApiResponse; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeService; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel.ChallengeReviewWithChallenge; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel.ChallengeReviewWithUserInfo; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithChallenge; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithUserInfo; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java index a38e899..f3ab99b 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java @@ -3,9 +3,9 @@ import java.util.Map; import lombok.Builder; import org.haedal.zzansuni.controller.user.UserRes; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel.ChallengeReviewWithChallenge; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel.ChallengeReviewWithUserInfo; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithChallenge; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithUserInfo; public class ChallengeReviewRes { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/Challenge.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/Challenge.java similarity index 88% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/Challenge.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/Challenge.java index 13b1987..497aa88 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/Challenge.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/Challenge.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; +package org.haedal.zzansuni.domain.challengegroup; import jakarta.persistence.*; @@ -9,9 +9,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.haedal.zzansuni.domain.BaseTimeEntity; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupCommand; -import org.haedal.zzansuni.domain.challengegroup.DayType; @Entity @AllArgsConstructor diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeCommand.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeCommand.java similarity index 97% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeCommand.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeCommand.java index e54e487..e8dfd5e 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeCommand.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeCommand.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; +package org.haedal.zzansuni.domain.challengegroup; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroup.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroup.java index 09581d1..bc357af 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroup.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroup.java @@ -7,7 +7,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.haedal.zzansuni.domain.BaseTimeEntity; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; import java.util.ArrayList; import java.util.List; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeStatus.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeStatus.java similarity index 82% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeStatus.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeStatus.java index 945bb87..d13b50e 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeStatus.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeStatus.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; +package org.haedal.zzansuni.domain.challengegroup; import lombok.RequiredArgsConstructor; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java similarity index 95% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupModel.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java index fd13513..8b6199b 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java @@ -1,11 +1,10 @@ -package org.haedal.zzansuni.domain.challengegroup; +package org.haedal.zzansuni.domain.challengegroup.application; import lombok.Builder; import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.UserModel; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java similarity index 88% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryService.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java index 7079c58..b8b8d8c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java @@ -1,9 +1,12 @@ -package org.haedal.zzansuni.domain.challengegroup; +package org.haedal.zzansuni.domain.challengegroup.application; import lombok.RequiredArgsConstructor; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupImageReader; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupService.java similarity index 82% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupService.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupService.java index 149dfd0..d51cc66 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupService.java @@ -1,6 +1,8 @@ -package org.haedal.zzansuni.domain.challengegroup; +package org.haedal.zzansuni.domain.challengegroup.application; import lombok.RequiredArgsConstructor; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupCommand; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupStore; import org.springframework.stereotype.Service; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java similarity index 96% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeModel.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java index b2f05e4..e77c690 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; +package org.haedal.zzansuni.domain.challengegroup.application; import java.time.LocalDate; import java.time.LocalDateTime; @@ -6,11 +6,12 @@ import java.util.stream.Collectors; import lombok.Builder; import lombok.Getter; +import org.haedal.zzansuni.domain.challengegroup.Challenge; 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.userchallenge.UserChallenge; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; @Getter @Builder diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java similarity index 76% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeService.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java index 89510ec..4e13b2e 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java @@ -1,19 +1,21 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; +package org.haedal.zzansuni.domain.challengegroup.application; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel.ChallengeRecord; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel.ChallengeReviewWithChallenge; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel.ChallengeReviewWithUserInfo; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewReader; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewStore; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerificationModel; -import org.haedal.zzansuni.domain.userchallenge.verification.port.ChallengeVerificationReader; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithChallenge; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithUserInfo; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.springframework.data.domain.Page; @@ -40,7 +42,7 @@ public class ChallengeService { * 챌린지 기록 가져오기 */ @Transactional(readOnly = true) - public ChallengeModel.ChallengeRecord getChallengeRecord(Long userId, Long challengeId) { + public ChallengeRecord getChallengeRecord(Long userId, Long challengeId) { Challenge challenge = challengeReader.getById(challengeId); UserChallenge userChallenge = userChallengeReader.getByUserIdAndChallengeId(userId, challengeId); diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeStore.java deleted file mode 100644 index 56b50ac..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeStore.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge.port; - -public interface ChallengeStore { - -} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java index a7ad890..35a1510 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java @@ -2,8 +2,8 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupModel; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeReader.java similarity index 51% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeReader.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeReader.java index 00cb52b..848928a 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/port/ChallengeReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeReader.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge.port; +package org.haedal.zzansuni.domain.challengegroup.port; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; +import org.haedal.zzansuni.domain.challengegroup.Challenge; import java.util.Optional; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java new file mode 100644 index 0000000..b6c2af8 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java @@ -0,0 +1,5 @@ +package org.haedal.zzansuni.domain.challengegroup.port; + +public interface ChallengeStore { + +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/ChallengeGroupUserExp.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java similarity index 95% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/ChallengeGroupUserExp.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java index aa740ab..dde1041 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/ChallengeGroupUserExp.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.userchallenge.userexp; +package org.haedal.zzansuni.domain.userchallenge; import jakarta.persistence.*; import lombok.*; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/ChallengeReview.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeReview.java similarity index 86% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/ChallengeReview.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeReview.java index 702e346..0f4a789 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/ChallengeReview.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeReview.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.userchallenge.review; +package org.haedal.zzansuni.domain.userchallenge; import jakarta.persistence.*; import lombok.AccessLevel; @@ -7,8 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.haedal.zzansuni.domain.BaseTimeEntity; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; -import org.haedal.zzansuni.domain.userchallenge.UserChallenge; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; @Entity @AllArgsConstructor diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerification.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeVerification.java similarity index 84% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerification.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeVerification.java index 89357d0..f110d4e 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerification.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeVerification.java @@ -1,10 +1,9 @@ -package org.haedal.zzansuni.domain.userchallenge.verification; +package org.haedal.zzansuni.domain.userchallenge; import jakarta.persistence.*; import lombok.*; import org.haedal.zzansuni.domain.BaseTimeEntity; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; -import org.haedal.zzansuni.domain.userchallenge.UserChallenge; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; @Entity @AllArgsConstructor diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerificationStatus.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeVerificationStatus.java similarity index 77% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerificationStatus.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeVerificationStatus.java index 939e8ae..50e5d0d 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerificationStatus.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeVerificationStatus.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.userchallenge.verification; +package org.haedal.zzansuni.domain.userchallenge; import lombok.RequiredArgsConstructor; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java index 7f4a011..7336b4c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java @@ -7,10 +7,9 @@ import lombok.Getter; import lombok.NoArgsConstructor; import org.haedal.zzansuni.domain.BaseTimeEntity; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeStatus; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; +import org.haedal.zzansuni.domain.challengegroup.ChallengeStatus; import org.haedal.zzansuni.domain.user.User; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/AddUserExpByVerificationUseCase.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java similarity index 78% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/AddUserExpByVerificationUseCase.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java index c1d81b9..45fc154 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/AddUserExpByVerificationUseCase.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.domain.userchallenge; +package org.haedal.zzansuni.domain.userchallenge.application; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.AddUserExpByVerificationEvent; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/ChallengeReviewModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewModel.java similarity index 94% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/ChallengeReviewModel.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewModel.java index 13601ac..f5b3e1d 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/ChallengeReviewModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewModel.java @@ -1,13 +1,14 @@ -package org.haedal.zzansuni.domain.userchallenge.review; +package org.haedal.zzansuni.domain.userchallenge.application; import java.util.HashMap; import java.util.List; import java.util.Map; import lombok.Builder; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; +import org.haedal.zzansuni.domain.challengegroup.Challenge; import org.haedal.zzansuni.domain.user.UserModel; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; public class ChallengeReviewModel { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerificationModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeVerificationModel.java similarity index 83% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerificationModel.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeVerificationModel.java index fb19b86..52d1404 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/ChallengeVerificationModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeVerificationModel.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.domain.userchallenge.verification; +package org.haedal.zzansuni.domain.userchallenge.application; import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; @Getter @Builder diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java similarity index 87% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallengeService.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java index 9b64f39..13686aa 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java @@ -1,18 +1,20 @@ -package org.haedal.zzansuni.domain.userchallenge; +package org.haedal.zzansuni.domain.userchallenge.application; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.haedal.zzansuni.domain.userchallenge.AddUserExpByVerificationEvent; +import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.userchallenge.userexp.port.ChallengeGroupUserExpStore; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeCommand; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeModel; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserReader; import org.springframework.data.domain.Page; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java new file mode 100644 index 0000000..03cfc93 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java @@ -0,0 +1,7 @@ +package org.haedal.zzansuni.domain.userchallenge.port; + +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; + +public interface ChallengeGroupUserExpStore { + ChallengeGroupUserExp store(ChallengeGroupUserExp challengeGroupUserExp); +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewReader.java similarity index 84% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewReader.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewReader.java index f6c0dd6..1ea38dd 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewReader.java @@ -1,10 +1,10 @@ -package org.haedal.zzansuni.domain.userchallenge.review.port; +package org.haedal.zzansuni.domain.userchallenge.port; import java.util.List; import java.util.Map; import java.util.Optional; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewStore.java new file mode 100644 index 0000000..def5fea --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeReviewStore.java @@ -0,0 +1,9 @@ +package org.haedal.zzansuni.domain.userchallenge.port; + +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; + +public interface ChallengeReviewStore { + + ChallengeReview store(ChallengeReview challengeReview); + +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/port/ChallengeVerificationReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeVerificationReader.java similarity index 74% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/port/ChallengeVerificationReader.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeVerificationReader.java index 90829f5..eef54de 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/verification/port/ChallengeVerificationReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeVerificationReader.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.domain.userchallenge.verification.port; +package org.haedal.zzansuni.domain.userchallenge.port; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; import java.util.List; import java.util.Optional; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewStore.java deleted file mode 100644 index 9eaa5ad..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/review/port/ChallengeReviewStore.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.haedal.zzansuni.domain.userchallenge.review.port; - -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; - -public interface ChallengeReviewStore { - - ChallengeReview store(ChallengeReview challengeReview); - -} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/port/ChallengeGroupUserExpStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/port/ChallengeGroupUserExpStore.java deleted file mode 100644 index 0873a46..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/userexp/port/ChallengeGroupUserExpStore.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.haedal.zzansuni.domain.userchallenge.userexp.port; - -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; - -public interface ChallengeGroupUserExpStore { - ChallengeGroupUserExp store(ChallengeGroupUserExp challengeGroupUserExp); -} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeRepository.java similarity index 51% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeRepository.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeRepository.java index af3b667..1f51756 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeRepository.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.infrastructure.challengegroup.challenge; +package org.haedal.zzansuni.infrastructure.challengegroup; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; +import org.haedal.zzansuni.domain.challengegroup.Challenge; import org.springframework.data.jpa.repository.JpaRepository; public interface ChallengeRepository extends JpaRepository { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupImageReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupImageReaderImpl.java similarity index 80% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupImageReaderImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupImageReaderImpl.java index 4c31a45..58cabc7 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupImageReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupImageReaderImpl.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.infrastructure.challengegroup; +package org.haedal.zzansuni.infrastructure.challengegroup.adapter; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupImageReader; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupImageRepository; import org.springframework.stereotype.Component; import java.util.List; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java similarity index 95% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupReaderImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java index f98dc09..b601946 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java @@ -1,17 +1,18 @@ -package org.haedal.zzansuni.infrastructure.challengegroup; +package org.haedal.zzansuni.infrastructure.challengegroup.adapter; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.challengegroup.*; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.QUser; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserModel; import org.haedal.zzansuni.domain.userchallenge.userexp.QChallengeGroupUserExp; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupStoreImpl.java similarity index 82% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupStoreImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupStoreImpl.java index 1c7c59a..68e40fb 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupStoreImpl.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.infrastructure.challengegroup; +package org.haedal.zzansuni.infrastructure.challengegroup.adapter; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupStore; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeReaderImpl.java similarity index 67% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeReaderImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeReaderImpl.java index e0b634c..cc88dd7 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeReaderImpl.java @@ -1,10 +1,11 @@ -package org.haedal.zzansuni.infrastructure.challengegroup.challenge; +package org.haedal.zzansuni.infrastructure.challengegroup.adapter; import java.util.NoSuchElementException; import java.util.Optional; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeReader; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeRepository; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java similarity index 53% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeStoreImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java index 228b0d3..b6b3c64 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java @@ -1,7 +1,8 @@ -package org.haedal.zzansuni.infrastructure.challengegroup.challenge; +package org.haedal.zzansuni.infrastructure.challengegroup.adapter; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeStore; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeStore; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeRepository; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java index 1b077d7..ee8b4c6 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java @@ -1,6 +1,6 @@ package org.haedal.zzansuni.infrastructure.userchallenge; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.springframework.data.jpa.repository.JpaRepository; public interface ChallengeGroupUserExpRepository extends JpaRepository { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java index 9f2ed18..b6cc3cf 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java @@ -1,8 +1,8 @@ package org.haedal.zzansuni.infrastructure.userchallenge; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.userchallenge.userexp.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java index 9bc90c1..76569a9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java @@ -7,8 +7,8 @@ import java.util.NoSuchElementException; import java.util.Optional; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java index 450227f..574f797 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.Optional; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.springframework.data.jpa.repository.JpaRepository; public interface ChallengeReviewRepository extends JpaRepository { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java index 5115bbc..d466934 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java @@ -1,8 +1,8 @@ package org.haedal.zzansuni.infrastructure.userchallenge.review; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewStore; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java index 1d286e9..fcdbd32 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java @@ -3,7 +3,7 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.challenge.ChallengeStatus; +import org.haedal.zzansuni.domain.challengegroup.ChallengeStatus; import org.haedal.zzansuni.domain.userchallenge.DayCountType; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java index 46d4653..6a9623d 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java @@ -4,8 +4,8 @@ import java.util.NoSuchElementException; import java.util.Optional; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; -import org.haedal.zzansuni.domain.userchallenge.verification.port.ChallengeVerificationReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java index 742b892..1548381 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java @@ -1,7 +1,7 @@ package org.haedal.zzansuni.infrastructure.userchallenge.verification; import java.util.List; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; import org.springframework.data.jpa.repository.JpaRepository; public interface ChallengeVerificationRepository extends diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryServiceTest.java index 2f24b02..695b984 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupQueryServiceTest.java @@ -1,10 +1,11 @@ package org.haedal.zzansuni.domain.challengegroup; import jakarta.persistence.EntityManager; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupQueryService; import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupImageRepository; import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; -import org.haedal.zzansuni.infrastructure.challengegroup.challenge.ChallengeRepository; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -21,7 +22,8 @@ @SpringBootTest @Transactional class ChallengeGroupQueryServiceTest { - @Autowired ChallengeGroupQueryService challengeGroupQueryService; + @Autowired + ChallengeGroupQueryService challengeGroupQueryService; @Autowired ChallengeGroupRepository challengeGroupRepository; @Autowired ChallengeRepository challengeRepository; @Autowired ChallengeGroupImageRepository challengeGroupImageRepository; diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupServiceTest.java index 7b0debe..ff0b0e2 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupServiceTest.java @@ -1,8 +1,8 @@ package org.haedal.zzansuni.domain.challengegroup; -import org.haedal.zzansuni.domain.challengegroup.challenge.Challenge; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupService; import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; -import org.haedal.zzansuni.infrastructure.challengegroup.challenge.ChallengeRepository; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java index 311361e..ced534a 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java @@ -1,22 +1,22 @@ package org.haedal.zzansuni.domain.challengegroup.challenge; import java.time.LocalDate; -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.challenge.ChallengeModel.ChallengeRecord; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReview; -import org.haedal.zzansuni.domain.userchallenge.review.ChallengeReviewModel; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewReader; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewStore; + +import org.haedal.zzansuni.domain.challengegroup.*; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerificationModel; -import org.haedal.zzansuni.domain.userchallenge.verification.port.ChallengeVerificationReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; import org.haedal.zzansuni.domain.user.User; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerificationStatus; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerificationStatus; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java index a616b1a..0970b15 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java @@ -1,20 +1,19 @@ package org.haedal.zzansuni.domain.challengegroup.userchallenge; import java.util.ArrayList; -import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; + +import org.haedal.zzansuni.domain.challengegroup.*; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.challengegroup.DayType; -import org.haedal.zzansuni.domain.challengegroup.challenge.*; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.AddUserExpByVerificationUseCase; -import org.haedal.zzansuni.domain.userchallenge.review.port.ChallengeReviewReader; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; +import org.haedal.zzansuni.domain.userchallenge.application.AddUserExpByVerificationUseCase; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.UserChallengeService; +import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeService; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; -import org.haedal.zzansuni.domain.userchallenge.userexp.port.ChallengeGroupUserExpStore; -import org.haedal.zzansuni.domain.userchallenge.userexp.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserReader; import org.haedal.zzansuni.global.security.Role; From 49b139fdd356df18efb81a9614f568ccc3ea41b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:25:52 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[Fix]:=20build=20error=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userchallenge/userchallenge/UserChallengeReaderImpl.java | 2 +- .../userchallenge/userchallenge/UserChallengeRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java index fcdbd32..52654de 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java @@ -58,7 +58,7 @@ public UserChallenge getByUserIdAndChallengeId(Long userId, Long challengeId) { @Override public Optional findByUserIdAndChallengeId(Long userId, Long challengeId) { - return userChallengeRepository.findByUserIdAndChallengeId(userId, challengeId); + return userChallengeRepository.findByUserIdAndChallenge_Id(userId, challengeId); } /** diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java index 68f3b66..47ff0c9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java @@ -12,7 +12,7 @@ import org.springframework.data.repository.query.Param; public interface UserChallengeRepository extends JpaRepository { - Optional findByUserIdAndChallengeId(Long userId, Long challengeId); + Optional findByUserIdAndChallenge_Id(Long userId, Long challengeId); /** * [challengeVerifications]와 [challenge]를 [fetchJoin]으로 OneToMany를 가져온다. From 92abe7d8fc9327037828a04ec64f3c14b683b829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:26:10 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[Refactor]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80?= =?UTF-8?q?=20=EB=A6=AC=EB=B7=B0=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../review/ChallengeReviewController.java | 11 +-- .../application/ChallengeService.java | 68 +--------------- .../application/ChallengeReviewService.java | 79 +++++++++++++++++++ .../adapter/ChallengeGroupReaderImpl.java | 6 +- .../review/ChallengeReviewReaderImpl.java | 9 +-- .../challenge/ChallengeServiceTest.java | 12 ++- 6 files changed, 104 insertions(+), 81 deletions(-) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewService.java diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java index 463754e..b20292c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java @@ -11,6 +11,7 @@ import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithChallenge; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithUserInfo; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewService; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; @@ -22,7 +23,7 @@ @RequiredArgsConstructor public class ChallengeReviewController { - private final ChallengeService challengeService; + private final ChallengeReviewService challengeReviewService; @Operation(summary = "챌린지 그룹 최근 리뷰 페이징", description = "챌린지 최근 리뷰 페이징 조회.") @@ -31,7 +32,7 @@ public ApiResponse> getChallengeReviews( @Valid PagingRequest pagingRequest //TODO SORTING ) { - Page page = challengeService.getChallengeReviews( + Page page = challengeReviewService.getChallengeReviews( pagingRequest.toPageable()); PagingResponse response = PagingResponse.from( @@ -50,7 +51,7 @@ public ApiResponse> getChal @Valid PagingRequest pagingRequest //TODO SORTING ) { - Page page = challengeService.getChallengeReviewsByGroupId( + Page page = challengeReviewService.getChallengeReviewsByGroupId( challengeGroupId, pagingRequest.toPageable()); PagingResponse response = PagingResponse.from( @@ -69,7 +70,7 @@ public ApiResponse challengeReviewCreate( @AuthenticationPrincipal JwtUser jwtUser, @RequestBody ChallengeReq.ReviewCreate request ) { - Long response = challengeService.createReview(request.toCommand(), challengeId, + Long response = challengeReviewService.createReview(request.toCommand(), challengeId, jwtUser.getId()); return ApiResponse.success(response, "챌린지 리뷰 작성에 성공하였습니다."); } @@ -81,7 +82,7 @@ public ApiResponse getChallengeGroupReviewScor @PathVariable Long challengeGroupId ) { var response = ChallengeReviewRes.ScoreResponse.from( - challengeService.getChallengeGroupReviewScore(challengeGroupId)); + challengeReviewService.getChallengeGroupReviewScore(challengeGroupId)); return ApiResponse.success(response, "챌린지 그룹별 리뷰 평점 조회에 성공하였습니다."); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java index 4e13b2e..6a35206 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java @@ -1,28 +1,20 @@ package org.haedal.zzansuni.domain.challengegroup.application; -import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.haedal.zzansuni.domain.challengegroup.Challenge; -import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithChallenge; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithUserInfo; -import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; -import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; -import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + @RequiredArgsConstructor @Service @Slf4j @@ -34,8 +26,7 @@ public class ChallengeService { private final ChallengeVerificationReader challengeVerificationReader; - private final ChallengeReviewStore challengeReviewStore; - private final ChallengeReviewReader challengeReviewReader; + /** @@ -61,56 +52,5 @@ public ChallengeVerificationModel getChallengeRecordDetail(Long recordId) { return ChallengeVerificationModel.from(challengeVerification); } - /** - * 챌린지 리뷰 작성하기 - */ - @Transactional - public Long createReview(ChallengeCommand.ReviewCreate command, Long challengeId, Long userId) { - UserChallenge userChallenge = userChallengeReader.getByUserIdAndChallengeId(userId, - challengeId); - - //이미 리뷰를 작성했는지 확인 - challengeReviewReader.findByUserChallengeId(userChallenge.getId()) - .ifPresent(review -> { - throw new IllegalArgumentException("이미 리뷰를 작성했습니다."); - }); - ChallengeReview challengeReview = ChallengeReview.create(userChallenge, command); - challengeReviewStore.store(challengeReview); - return challengeReview.getId(); - } - - /** - * groupId로 챌린지 리뷰 가져오기 - */ - @Transactional(readOnly = true) - public Page getChallengeReviewsByGroupId( - Long challengeGroupId, Pageable pageable) { - Page challengeReviewPage = challengeReviewReader.getChallengeReviewPageByChallengeGroupId( - challengeGroupId, pageable); - - return challengeReviewPage.map(ChallengeReviewWithChallenge::from); - } - - /** - * 챌린지 리뷰 가져오기 - */ - @Transactional(readOnly = true) - public Page getChallengeReviews(Pageable pageable) { - Page challengeReviewPage = challengeReviewReader.getChallengeReviewPage( - pageable); - return challengeReviewPage.map(ChallengeReviewWithUserInfo::from); - } - - /** - * 챌린지 그룹 리뷰 평점 가져오기 - */ - @Transactional(readOnly = true) - public ChallengeReviewModel.Score getChallengeGroupReviewScore( - Long challengeGroupId) { - List challengeReviews = challengeReviewReader.findByChallengeGroupId( - challengeGroupId); - //TODO 모든 리뷰를 가져와서 계산 -> 성능 이슈 발생 가능 - return ChallengeReviewModel.Score.of(challengeReviews); - } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewService.java new file mode 100644 index 0000000..e168293 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeReviewService.java @@ -0,0 +1,79 @@ +package org.haedal.zzansuni.domain.userchallenge.application; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; +import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; +import org.haedal.zzansuni.domain.userchallenge.UserChallenge; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; +import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@RequiredArgsConstructor +@Service +@Slf4j +public class ChallengeReviewService { + private final ChallengeReviewStore challengeReviewStore; + private final ChallengeReviewReader challengeReviewReader; + private final UserChallengeReader userChallengeReader; + + + /** + * 챌린지 리뷰 작성하기 + */ + @Transactional + public Long createReview(ChallengeCommand.ReviewCreate command, Long challengeId, Long userId) { + UserChallenge userChallenge = userChallengeReader.getByUserIdAndChallengeId(userId, + challengeId); + + //이미 리뷰를 작성했는지 확인 + challengeReviewReader.findByUserChallengeId(userChallenge.getId()) + .ifPresent(review -> { + throw new IllegalArgumentException("이미 리뷰를 작성했습니다."); + }); + ChallengeReview challengeReview = ChallengeReview.create(userChallenge, command); + challengeReviewStore.store(challengeReview); + return challengeReview.getId(); + } + + /** + * groupId로 챌린지 리뷰 가져오기 + */ + @Transactional(readOnly = true) + public Page getChallengeReviewsByGroupId( + Long challengeGroupId, Pageable pageable) { + Page challengeReviewPage = challengeReviewReader.getChallengeReviewPageByChallengeGroupId( + challengeGroupId, pageable); + + return challengeReviewPage.map(ChallengeReviewModel.ChallengeReviewWithChallenge::from); + } + + /** + * 챌린지 리뷰 가져오기 + */ + @Transactional(readOnly = true) + public Page getChallengeReviews(Pageable pageable) { + Page challengeReviewPage = challengeReviewReader.getChallengeReviewPage( + pageable); + + return challengeReviewPage.map(ChallengeReviewModel.ChallengeReviewWithUserInfo::from); + } + + /** + * 챌린지 그룹 리뷰 평점 가져오기 + */ + @Transactional(readOnly = true) + public ChallengeReviewModel.Score getChallengeGroupReviewScore( + Long challengeGroupId) { + List challengeReviews = challengeReviewReader.findByChallengeGroupId( + challengeGroupId); + //TODO 모든 리뷰를 가져와서 계산 -> 성능 이슈 발생 가능 + return ChallengeReviewModel.Score.of(challengeReviews); + } +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java index b601946..f174848 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java @@ -11,7 +11,8 @@ import org.haedal.zzansuni.domain.user.QUser; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserModel; -import org.haedal.zzansuni.domain.userchallenge.userexp.QChallengeGroupUserExp; + +import org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp; import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -24,7 +25,8 @@ import java.util.Optional; import static org.haedal.zzansuni.domain.challengegroup.QChallengeGroup.challengeGroup; -import static org.haedal.zzansuni.domain.userchallenge.userexp.QChallengeGroupUserExp.challengeGroupUserExp; +import static org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp.challengeGroupUserExp; + @Component @RequiredArgsConstructor diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java index 76569a9..2e549df 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java @@ -1,11 +1,6 @@ package org.haedal.zzansuni.infrastructure.userchallenge.review; import com.querydsl.jpa.impl.JPAQueryFactory; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; @@ -14,7 +9,9 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Component; -import static org.haedal.zzansuni.domain.userchallenge.review.QChallengeReview.challengeReview; +import java.util.*; + +import static org.haedal.zzansuni.domain.userchallenge.QChallengeReview.challengeReview; @Component diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java index ced534a..87b4311 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java @@ -8,6 +8,7 @@ import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewService; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; @@ -56,6 +57,9 @@ class ChallengeServiceTest { @InjectMocks private ChallengeService challengeService; + @InjectMocks + private ChallengeReviewService challengeReviewService; + private Challenge challenge; private ChallengeGroup challengeGroup; private UserChallenge userChallenge; @@ -176,7 +180,7 @@ void createReview() { }); //TODO: ChallengeReview가 정적메서드라 테스트하기 어려움 - Long reviewId = challengeService.createReview(command, challengeId, userId); + Long reviewId = challengeReviewService.createReview(command, challengeId, userId); //assertNotNull(reviewId); // 리뷰 ID가 null이 아닌지 확인 //assertEquals(1L, reviewId); // 리뷰 ID가 1L인지 확인 @@ -194,7 +198,7 @@ void getChallengeReviewsByGroupId() { when(challengeReviewReader.getChallengeReviewPageByChallengeGroupId(challengeGroupId, pageable)).thenReturn(challengeReviewPage); - Page result = challengeService.getChallengeReviewsByGroupId( + Page result = challengeReviewService.getChallengeReviewsByGroupId( challengeGroupId, pageable); assertNotNull(result); @@ -209,7 +213,7 @@ void getChallengeReviews() { when(challengeReviewReader.getChallengeReviewPage(pageable)).thenReturn( challengeReviewPage); - Page result = challengeService.getChallengeReviews( + Page result = challengeReviewService.getChallengeReviews( pageable); assertNotNull(result); @@ -223,7 +227,7 @@ void getChallengeGroupReviewScore() { when(challengeReviewReader.findByChallengeGroupId(challengeGroupId)).thenReturn( challengeReviews); - ChallengeReviewModel.Score result = challengeService.getChallengeGroupReviewScore( + ChallengeReviewModel.Score result = challengeReviewService.getChallengeGroupReviewScore( challengeGroupId); assertNotNull(result); From 88bf95092f67e50b2a06fb1a2fffbeed0649f55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:34:53 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[Refactor]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80?= =?UTF-8?q?=20=EA=B8=B0=EB=A1=9D=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge/ChallengeController.java | 12 ++++++------ .../challenge/ChallengeReq.java | 2 +- .../challenge/ChallengeRes.java | 2 +- .../ChallengeReviewController.java | 5 ++--- .../ChallengeReviewRes.java | 2 +- .../domain/challengegroup/port/ChallengeStore.java | 5 ----- .../application/ChallengeRecordService.java} | 10 ++-------- .../challengegroup/adapter/ChallengeStoreImpl.java | 14 -------------- ...ceTest.java => ChallengeRecordServiceTest.java} | 10 +++++----- ...st.java => UserChallengeRecordServiceTest.java} | 2 +- 10 files changed, 19 insertions(+), 45 deletions(-) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/{challengegroup => }/challenge/ChallengeController.java (92%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/{challengegroup => }/challenge/ChallengeReq.java (92%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/{challengegroup => }/challenge/ChallengeRes.java (98%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/{challengegroup/review => challengereview}/ChallengeReviewController.java (94%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/{challengegroup/review => challengereview}/ChallengeReviewRes.java (97%) delete mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/{challengegroup/application/ChallengeService.java => userchallenge/application/ChallengeRecordService.java} (90%) delete mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java rename zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/{ChallengeServiceTest.java => ChallengeRecordServiceTest.java} (95%) rename zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/{UserChallengeServiceTest.java => UserChallengeRecordServiceTest.java} (99%) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java similarity index 92% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java index 4738f19..06198af 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.controller.challengegroup.challenge; +package org.haedal.zzansuni.controller.challenge; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -7,13 +7,13 @@ import lombok.extern.slf4j.Slf4j; import org.haedal.zzansuni.controller.PagingRequest; import org.haedal.zzansuni.controller.PagingResponse; -import org.haedal.zzansuni.controller.challengegroup.challenge.ChallengeRes.ChallengeCompleteResponse; +import org.haedal.zzansuni.controller.challenge.ChallengeRes.ChallengeCompleteResponse; import org.haedal.zzansuni.core.api.ApiResponse; import org.haedal.zzansuni.domain.ImageUploader; import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeComplete; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeCurrent; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeRecordService; import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeService; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.data.domain.Page; @@ -28,7 +28,7 @@ @Slf4j public class ChallengeController { - private final ChallengeService challengeService; + private final ChallengeRecordService challengeRecordService; private final UserChallengeService userChallengeService; private final ImageUploader imageUploader; @@ -70,7 +70,7 @@ public ApiResponse getChallengeRecord( @AuthenticationPrincipal JwtUser jwtUser ) { ChallengeRes.ChallengeRecordResponse response = ChallengeRes.ChallengeRecordResponse.from( - challengeService.getChallengeRecord(jwtUser.getId(), challengeId) + challengeRecordService.getChallengeRecord(jwtUser.getId(), challengeId) ); return ApiResponse.success(response, "챌린지 기록 조회에 성공하였습니다."); } @@ -83,7 +83,7 @@ public ApiResponse getChallengeRecordDeta @AuthenticationPrincipal JwtUser jwtUser ) { ChallengeRes.ChallengeRecordDetailDto response = ChallengeRes.ChallengeRecordDetailDto.from( - challengeService.getChallengeRecordDetail(recordId) + challengeRecordService.getChallengeRecordDetail(recordId) ); log.info("response: {}", response); return ApiResponse.success(response, "챌린지 기록 상세 조회에 성공하였습니다."); diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeReq.java similarity index 92% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeReq.java index c24fea5..479ba5a 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeReq.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeReq.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.controller.challengegroup.challenge; +package org.haedal.zzansuni.controller.challenge; import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; import org.springframework.web.multipart.MultipartFile; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java similarity index 98% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java index a3f7e66..f398e8c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/challenge/ChallengeRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.controller.challengegroup.challenge; +package org.haedal.zzansuni.controller.challenge; import lombok.Builder; import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewController.java similarity index 94% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewController.java index b20292c..97479c9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewController.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.controller.challengegroup.review; +package org.haedal.zzansuni.controller.challengereview; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -6,9 +6,8 @@ import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.controller.PagingRequest; import org.haedal.zzansuni.controller.PagingResponse; -import org.haedal.zzansuni.controller.challengegroup.challenge.ChallengeReq; +import org.haedal.zzansuni.controller.challenge.ChallengeReq; import org.haedal.zzansuni.core.api.ApiResponse; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithChallenge; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel.ChallengeReviewWithUserInfo; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewService; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewRes.java similarity index 97% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewRes.java index f3ab99b..1f298d0 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/review/ChallengeReviewRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewRes.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.controller.challengegroup.review; +package org.haedal.zzansuni.controller.challengereview; import java.util.Map; import lombok.Builder; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java deleted file mode 100644 index b6c2af8..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeStore.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.haedal.zzansuni.domain.challengegroup.port; - -public interface ChallengeStore { - -} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java similarity index 90% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java index 6a35206..0995659 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup.application; +package org.haedal.zzansuni.domain.userchallenge.application; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -7,7 +7,6 @@ import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.springframework.stereotype.Service; @@ -18,17 +17,12 @@ @RequiredArgsConstructor @Service @Slf4j -public class ChallengeService { - +public class ChallengeRecordService { private final ChallengeReader challengeReader; - private final UserChallengeReader userChallengeReader; - private final ChallengeVerificationReader challengeVerificationReader; - - /** * 챌린지 기록 가져오기 */ diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java deleted file mode 100644 index b6b3c64..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeStoreImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.haedal.zzansuni.infrastructure.challengegroup.adapter; - -import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.port.ChallengeStore; -import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeRepository; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class ChallengeStoreImpl implements ChallengeStore { - - private final ChallengeRepository challengeRepository; - -} diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java similarity index 95% rename from zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java rename to zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java index 87b4311..18526b9 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java @@ -3,7 +3,7 @@ import java.time.LocalDate; import org.haedal.zzansuni.domain.challengegroup.*; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeService; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeRecordService; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; @@ -37,7 +37,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -class ChallengeServiceTest { +class ChallengeRecordServiceTest { @Mock private ChallengeReader challengeReader; @@ -55,7 +55,7 @@ class ChallengeServiceTest { private ChallengeReviewReader challengeReviewReader; @InjectMocks - private ChallengeService challengeService; + private ChallengeRecordService challengeRecordService; @InjectMocks private ChallengeReviewService challengeReviewService; @@ -135,7 +135,7 @@ void getChallengeRecord() { when(challengeVerificationReader.findByUserChallengeId(userChallenge.getId())).thenReturn( Collections.singletonList(challengeVerification)); - ChallengeRecord result = challengeService.getChallengeRecord(userId, challengeId); + ChallengeRecord result = challengeRecordService.getChallengeRecord(userId, challengeId); assertNotNull(result); verify(challengeReader).getById(challengeId); @@ -148,7 +148,7 @@ void getChallengeRecordDetail() { Long recordId = 1L; when(challengeVerificationReader.getById(recordId)).thenReturn(challengeVerification); - ChallengeVerificationModel result = challengeService.getChallengeRecordDetail(recordId); + ChallengeVerificationModel result = challengeRecordService.getChallengeRecordDetail(recordId); assertNotNull(result); verify(challengeVerificationReader).getById(recordId); diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java similarity index 99% rename from zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java rename to zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java index 0970b15..d50b602 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java @@ -37,7 +37,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -class UserChallengeServiceTest { +class UserChallengeRecordServiceTest { @Mock private UserChallengeStore userChallengeStore; From e52d8d4ff3e5a7b66d23904b5e7e29d2856e9b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:49:21 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[Refactor]:=20`=EC=B1=8C=EB=A6=B0=EC=A7=80?= =?UTF-8?q?=20=EA=B7=B8=EB=A3=B9`=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EC=88=9C=ED=99=98=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeGroupUserExp.java | 3 +-- .../challengegroup/application/ChallengeGroupModel.java | 2 +- .../application/ChallengeGroupQueryService.java | 2 +- .../domain/challengegroup/port/ChallengeGroupReader.java | 2 +- .../port/ChallengeGroupUserExpStore.java | 4 ++-- .../{challengegroup => userchallenge}/ChallengeStatus.java | 2 +- .../zzansuni/domain/userchallenge/UserChallenge.java | 1 - .../application/AddUserExpByVerificationUseCase.java | 2 +- .../userchallenge/application/UserChallengeService.java | 4 ++-- .../ChallengeGroupUserExpRepository.java | 4 ++-- .../challengegroup/adapter/ChallengeGroupReaderImpl.java | 6 +++--- .../adapter}/ChallengeGroupUserExpStoreImpl.java | 7 ++++--- .../userchallenge/UserChallengeReaderImpl.java | 2 +- .../challenge/ChallengeRecordServiceTest.java | 5 +---- .../userchallenge/UserChallengeRecordServiceTest.java | 5 +++-- 15 files changed, 24 insertions(+), 27 deletions(-) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/{userchallenge => challengegroup}/ChallengeGroupUserExp.java (91%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/{userchallenge => challengegroup}/port/ChallengeGroupUserExpStore.java (50%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/{challengegroup => userchallenge}/ChallengeStatus.java (84%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/{userchallenge => challengegroup}/ChallengeGroupUserExpRepository.java (56%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/{userchallenge => challengegroup/adapter}/ChallengeGroupUserExpStoreImpl.java (60%) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupUserExp.java similarity index 91% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupUserExp.java index dde1041..997ff9b 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupUserExp.java @@ -1,8 +1,7 @@ -package org.haedal.zzansuni.domain.userchallenge; +package org.haedal.zzansuni.domain.challengegroup; import jakarta.persistence.*; import lombok.*; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.user.User; @Getter diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java index 8b6199b..fa7b1ba 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java @@ -4,7 +4,7 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.UserModel; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java index b8b8d8c..5d42c3c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java @@ -6,7 +6,7 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupImageReader; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java index 35a1510..22c3db9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java @@ -3,7 +3,7 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupUserExpStore.java similarity index 50% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupUserExpStore.java index 03cfc93..3a8ddd4 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupUserExpStore.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.domain.userchallenge.port; +package org.haedal.zzansuni.domain.challengegroup.port; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; public interface ChallengeGroupUserExpStore { ChallengeGroupUserExp store(ChallengeGroupUserExp challengeGroupUserExp); diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeStatus.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeStatus.java similarity index 84% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeStatus.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeStatus.java index d13b50e..b057bb7 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeStatus.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeStatus.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup; +package org.haedal.zzansuni.domain.userchallenge; import lombok.RequiredArgsConstructor; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java index 7336b4c..2c5edb6 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/UserChallenge.java @@ -9,7 +9,6 @@ import org.haedal.zzansuni.domain.BaseTimeEntity; import org.haedal.zzansuni.domain.challengegroup.Challenge; import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; -import org.haedal.zzansuni.domain.challengegroup.ChallengeStatus; import org.haedal.zzansuni.domain.user.User; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java index 45fc154..3d2b24c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; import org.haedal.zzansuni.domain.userchallenge.AddUserExpByVerificationEvent; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java index 13686aa..cc3fb20 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java @@ -8,8 +8,8 @@ import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupUserExpStore; import org.haedal.zzansuni.domain.challengegroup.Challenge; import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupUserExpRepository.java similarity index 56% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupUserExpRepository.java index ee8b4c6..c7f7723 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupUserExpRepository.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.infrastructure.userchallenge; +package org.haedal.zzansuni.infrastructure.challengegroup; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.springframework.data.jpa.repository.JpaRepository; public interface ChallengeGroupUserExpRepository extends JpaRepository { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java index f174848..4fd9fe2 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java @@ -7,12 +7,12 @@ import org.haedal.zzansuni.domain.challengegroup.*; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.QUser; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserModel; -import org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp; + import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -25,7 +25,7 @@ import java.util.Optional; import static org.haedal.zzansuni.domain.challengegroup.QChallengeGroup.challengeGroup; -import static org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp.challengeGroupUserExp; +import static org.haedal.zzansuni.domain.challengegroup.QChallengeGroupUserExp.challengeGroupUserExp; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java similarity index 60% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java index b6cc3cf..af8d60e 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.infrastructure.userchallenge; +package org.haedal.zzansuni.infrastructure.challengegroup.adapter; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupUserExpRepository; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java index 52654de..a9d089c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java @@ -3,7 +3,7 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.ChallengeStatus; +import org.haedal.zzansuni.domain.userchallenge.ChallengeStatus; import org.haedal.zzansuni.domain.userchallenge.DayCountType; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java index 18526b9..45cd5ab 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java @@ -3,21 +3,18 @@ import java.time.LocalDate; import org.haedal.zzansuni.domain.challengegroup.*; +import org.haedal.zzansuni.domain.userchallenge.*; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeRecordService; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewService; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; -import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; import org.haedal.zzansuni.domain.user.User; -import org.haedal.zzansuni.domain.userchallenge.ChallengeVerificationStatus; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java index d50b602..5e63330 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java @@ -7,13 +7,14 @@ import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; import org.haedal.zzansuni.domain.userchallenge.application.AddUserExpByVerificationUseCase; +import org.haedal.zzansuni.domain.userchallenge.ChallengeStatus; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeService; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; -import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserReader; import org.haedal.zzansuni.global.security.Role; From 09318d6c75d6e0aae27a3afd24190f3828770f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:50:23 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[Refactor]:=20userchallenge=20adapter=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userchallenge/{review => }/ChallengeReviewRepository.java | 2 +- .../{verification => }/ChallengeVerificationRepository.java | 2 +- .../{userchallenge => }/UserChallengeRepository.java | 2 +- .../{review => adapter}/ChallengeReviewReaderImpl.java | 3 ++- .../{review => adapter}/ChallengeReviewStoreImpl.java | 3 ++- .../ChallengeVerificationReaderImpl.java | 3 ++- .../{userchallenge => adapter}/UserChallengeReaderImpl.java | 3 ++- .../{userchallenge => adapter}/UserChallengeStoreImpl.java | 3 ++- 8 files changed, 13 insertions(+), 8 deletions(-) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{review => }/ChallengeReviewRepository.java (86%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{verification => }/ChallengeVerificationRepository.java (88%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{userchallenge => }/UserChallengeRepository.java (97%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{review => adapter}/ChallengeReviewReaderImpl.java (96%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{review => adapter}/ChallengeReviewStoreImpl.java (79%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{verification => adapter}/ChallengeVerificationReaderImpl.java (89%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{userchallenge => adapter}/UserChallengeReaderImpl.java (97%) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/{userchallenge => adapter}/UserChallengeStoreImpl.java (78%) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeReviewRepository.java similarity index 86% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeReviewRepository.java index 574f797..4ca1ac2 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeReviewRepository.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.review; +package org.haedal.zzansuni.infrastructure.userchallenge; import java.util.List; import java.util.Optional; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeVerificationRepository.java similarity index 88% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeVerificationRepository.java index 1548381..e8dfb6b 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeVerificationRepository.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.verification; +package org.haedal.zzansuni.infrastructure.userchallenge; import java.util.List; import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/UserChallengeRepository.java similarity index 97% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/UserChallengeRepository.java index 47ff0c9..2cc2e9c 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/UserChallengeRepository.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.userchallenge; +package org.haedal.zzansuni.infrastructure.userchallenge; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeReviewReaderImpl.java similarity index 96% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeReviewReaderImpl.java index 2e549df..213c9e1 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeReviewReaderImpl.java @@ -1,9 +1,10 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.review; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; +import org.haedal.zzansuni.infrastructure.userchallenge.ChallengeReviewRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeReviewStoreImpl.java similarity index 79% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeReviewStoreImpl.java index d466934..5013384 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/review/ChallengeReviewStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeReviewStoreImpl.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.review; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.userchallenge.ChallengeReview; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; +import org.haedal.zzansuni.infrastructure.userchallenge.ChallengeReviewRepository; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeVerificationReaderImpl.java similarity index 89% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeVerificationReaderImpl.java index 6a9623d..a58bb4a 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/verification/ChallengeVerificationReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeVerificationReaderImpl.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.verification; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; import java.util.List; import java.util.NoSuchElementException; @@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; +import org.haedal.zzansuni.infrastructure.userchallenge.ChallengeVerificationRepository; import org.springframework.stereotype.Component; @Component diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/UserChallengeReaderImpl.java similarity index 97% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/UserChallengeReaderImpl.java index a9d089c..07a93e4 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/UserChallengeReaderImpl.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.userchallenge; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -7,6 +7,7 @@ import org.haedal.zzansuni.domain.userchallenge.DayCountType; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; +import org.haedal.zzansuni.infrastructure.userchallenge.UserChallengeRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/UserChallengeStoreImpl.java similarity index 78% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeStoreImpl.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/UserChallengeStoreImpl.java index c2617fe..632557f 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/userchallenge/UserChallengeStoreImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/UserChallengeStoreImpl.java @@ -1,8 +1,9 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.userchallenge; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; +import org.haedal.zzansuni.infrastructure.userchallenge.UserChallengeRepository; import org.springframework.stereotype.Component; @Component From cc0dfae983431535dd0c81f3a1f2822f01e00afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:52:47 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[Refactor]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=5F=EC=9C=A0=EC=A0=80=EA=B2=BD=ED=97=98?= =?UTF-8?q?=EC=B9=98=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeGroupController.java | 6 +- .../application/ChallengeGroupModel.java | 2 +- .../ChallengeGroupQueryService.java | 21 ------- .../port/ChallengeGroupReader.java | 7 --- .../ChallengeGroupUserExp.java | 3 +- .../AddUserExpByVerificationUseCase.java | 7 ++- .../application/ChallengeRankingService.java | 37 ++++++++++++ .../application/UserChallengeService.java | 4 +- .../port/ChallengeGroupUserExpReader.java | 13 ++++ .../port/ChallengeGroupUserExpStore.java | 4 +- .../adapter/ChallengeGroupReaderImpl.java | 39 ++---------- .../ChallengeGroupUserExpStoreImpl.java | 18 ------ .../ChallengeGroupUserExpRepository.java | 4 +- .../ChallengeGroupUserExpReaderStoreImpl.java | 59 +++++++++++++++++++ .../UserChallengeRecordServiceTest.java | 4 +- 15 files changed, 132 insertions(+), 96 deletions(-) rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/{challengegroup => userchallenge}/ChallengeGroupUserExp.java (91%) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpReader.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/{challengegroup => userchallenge}/port/ChallengeGroupUserExpStore.java (50%) delete mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java rename zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/{challengegroup => userchallenge}/ChallengeGroupUserExpRepository.java (56%) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeGroupUserExpReaderStoreImpl.java diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java index 6cfbf34..464a0b4 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java @@ -10,6 +10,7 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupQueryService; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeRankingService; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; @@ -22,6 +23,7 @@ @RestController public class ChallengeGroupController { private final ChallengeGroupQueryService challengeGroupQueryService; + private final ChallengeRankingService challengeRankingService; @Operation(summary = "챌린지 그룹 목록 페이징", description = "챌린지 그룹 페이징 조회.") @GetMapping("/api/challengeGroups") @@ -53,8 +55,8 @@ public ApiResponse getChallengeRankings @PathVariable Long challengeGroupId, @Valid PagingRequest pagingRequest ) { - var rankingPage = challengeGroupQueryService.getChallengeGroupRankingsPaging(challengeGroupId, pagingRequest.toPageable()); - var rankingModel = challengeGroupQueryService.getChallengeGroupRanking(challengeGroupId, jwtUser.getId()); + var rankingPage = challengeRankingService.getChallengeGroupRankingsPaging(challengeGroupId, pagingRequest.toPageable()); + var rankingModel = challengeRankingService.getChallengeGroupRanking(challengeGroupId, jwtUser.getId()); var response = ChallengeGroupRes.RankingPagingResponse .from(rankingPage, rankingModel); return ApiResponse.success(response); diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java index fa7b1ba..8b6199b 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java @@ -4,7 +4,7 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.UserModel; import java.time.LocalDate; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java index 5d42c3c..22e20ef 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupQueryService.java @@ -6,7 +6,6 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupImageReader; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -39,24 +38,4 @@ public Page getChallengeGroupsShortsPaging(Pageable pa return challengeGroups.map(ChallengeGroupModel.Info::from); } - @Transactional(readOnly = true) - public Page getChallengeGroupRankingsPaging(Long challengeGroupId, Pageable pageable) { - Page challengeGroupUserExps - = challengeGroupReader.getUserExpPagingWithUserByChallengeGroupId(challengeGroupId, pageable); - - // Page를 Page으로 변환 - // [rank]는 [Pageable]의 위치에 따라 계산된다. - return challengeGroupUserExps.map(e->{ - int rank = challengeGroupUserExps.getNumber() * challengeGroupUserExps.getSize() + 1 - + challengeGroupUserExps.getContent().indexOf(e); - return ChallengeGroupModel.Ranking.from(e, rank); - }); - } - - - public ChallengeGroupModel.Ranking getChallengeGroupRanking(Long challengeGroupId, Long id) { - return challengeGroupReader.getRanking(challengeGroupId, id); - } - - } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java index 22c3db9..eb0dbbe 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java @@ -3,12 +3,9 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import java.util.Optional; - public interface ChallengeGroupReader { ChallengeGroup getById(Long challengeGroupId); @@ -18,9 +15,5 @@ public interface ChallengeGroupReader { Page getChallengeGroupsShortsPaging(Pageable pageable, Long userId); - Optional findByChallengeGroupIdAndUserId(Long challengeGroupId, Long userId); - - Page getUserExpPagingWithUserByChallengeGroupId(Long challengeGroupId, Pageable pageable); - ChallengeGroupModel.Ranking getRanking(Long challengeGroupId, Long userId); } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupUserExp.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java similarity index 91% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupUserExp.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java index 997ff9b..dde1041 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/ChallengeGroupUserExp.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/ChallengeGroupUserExp.java @@ -1,7 +1,8 @@ -package org.haedal.zzansuni.domain.challengegroup; +package org.haedal.zzansuni.domain.userchallenge; import jakarta.persistence.*; import lombok.*; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.user.User; @Getter diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java index 3d2b24c..5870d9b 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/AddUserExpByVerificationUseCase.java @@ -3,21 +3,22 @@ import lombok.RequiredArgsConstructor; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; import org.haedal.zzansuni.domain.userchallenge.AddUserExpByVerificationEvent; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpReader; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @Component @RequiredArgsConstructor public class AddUserExpByVerificationUseCase { - private final ChallengeGroupReader challengeGroupReader; + private final ChallengeGroupUserExpReader challengeGroupUserExpReader; @Transactional public void invoke(AddUserExpByVerificationEvent event) { Long challengeGroupId = event.getChallengeGroupId(); Long userId = event.getUserId(); - ChallengeGroupUserExp challengeGroupUserExp = challengeGroupReader + ChallengeGroupUserExp challengeGroupUserExp = challengeGroupUserExpReader .findByChallengeGroupIdAndUserId(challengeGroupId, userId).orElseThrow(); challengeGroupUserExp.addExp(event.getAcquiredExp()); } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java new file mode 100644 index 0000000..4644641 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java @@ -0,0 +1,37 @@ +package org.haedal.zzansuni.domain.userchallenge.application; + +import lombok.RequiredArgsConstructor; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpReader; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class ChallengeRankingService { + private final ChallengeGroupReader challengeGroupReader; + private final ChallengeGroupUserExpReader challengeGroupUserExpReader; + + @Transactional(readOnly = true) + public Page getChallengeGroupRankingsPaging(Long challengeGroupId, Pageable pageable) { + Page challengeGroupUserExps + = challengeGroupUserExpReader.getUserExpPagingWithUserByChallengeGroupId(challengeGroupId, pageable); + + // Page를 Page으로 변환 + // [rank]는 [Pageable]의 위치에 따라 계산된다. + return challengeGroupUserExps.map(e->{ + int rank = challengeGroupUserExps.getNumber() * challengeGroupUserExps.getSize() + 1 + + challengeGroupUserExps.getContent().indexOf(e); + return ChallengeGroupModel.Ranking.from(e, rank); + }); + } + + + public ChallengeGroupModel.Ranking getChallengeGroupRanking(Long challengeGroupId, Long id) { + return challengeGroupReader.getRanking(challengeGroupId, id); + } +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java index cc3fb20..13686aa 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java @@ -8,8 +8,8 @@ import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; import org.haedal.zzansuni.domain.challengegroup.Challenge; import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpReader.java new file mode 100644 index 0000000..d3434a2 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpReader.java @@ -0,0 +1,13 @@ +package org.haedal.zzansuni.domain.userchallenge.port; + +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +public interface ChallengeGroupUserExpReader { + Optional findByChallengeGroupIdAndUserId(Long challengeGroupId, Long userId); + + Page getUserExpPagingWithUserByChallengeGroupId(Long challengeGroupId, Pageable pageable); +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupUserExpStore.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java similarity index 50% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupUserExpStore.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java index 3a8ddd4..03cfc93 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupUserExpStore.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/port/ChallengeGroupUserExpStore.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.domain.challengegroup.port; +package org.haedal.zzansuni.domain.userchallenge.port; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; public interface ChallengeGroupUserExpStore { ChallengeGroupUserExp store(ChallengeGroupUserExp challengeGroupUserExp); diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java index 4fd9fe2..2d542a1 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java @@ -4,15 +4,15 @@ import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.*; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.QUser; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserModel; - - +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp; import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -22,10 +22,8 @@ import java.util.List; import java.util.NoSuchElementException; -import java.util.Optional; import static org.haedal.zzansuni.domain.challengegroup.QChallengeGroup.challengeGroup; -import static org.haedal.zzansuni.domain.challengegroup.QChallengeGroupUserExp.challengeGroupUserExp; @Component @@ -88,35 +86,6 @@ public Page getChallengeGroupsShortsPaging(Pageable pageable, Lo return new PageImpl<>(page, pageable, count == null ? 0 : count); } - @Override - public Optional findByChallengeGroupIdAndUserId(Long challengeGroupId, Long userId) { - ChallengeGroupUserExp result = queryFactory - .selectFrom(challengeGroupUserExp) - .where(challengeGroupUserExp.challengeGroup.id.eq(challengeGroupId) - .and(challengeGroupUserExp.user.id.eq(userId))) - .fetchOne(); - return Optional.ofNullable(result); - } - - @Override - public Page getUserExpPagingWithUserByChallengeGroupId(Long challengeGroupId, Pageable pageable) { - Long count = queryFactory - .select(challengeGroupUserExp.count()) - .from(challengeGroupUserExp) - .where(challengeGroupUserExp.challengeGroup.id.eq(challengeGroupId)) - .fetchOne(); - - List page = queryFactory - .selectFrom(challengeGroupUserExp) - .where(challengeGroupUserExp.challengeGroup.id.eq(challengeGroupId)) - .innerJoin(challengeGroupUserExp.user).fetchJoin() - .orderBy(challengeGroupUserExp.totalExp.desc()) - .offset(pageable.getOffset()) - .limit(pageable.getPageSize()) - .fetch(); - - return new PageImpl<>(page, pageable, count == null ? 0 : count); - } @Override public ChallengeGroupModel.Ranking getRanking(Long challengeGroupId, Long userId) { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java deleted file mode 100644 index af8d60e..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupUserExpStoreImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.haedal.zzansuni.infrastructure.challengegroup.adapter; - -import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupUserExpStore; -import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupUserExpRepository; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class ChallengeGroupUserExpStoreImpl implements ChallengeGroupUserExpStore { - private final ChallengeGroupUserExpRepository challengeGroupUserExpRepository; - - @Override - public ChallengeGroupUserExp store(ChallengeGroupUserExp challengeGroupUserExp) { - return challengeGroupUserExpRepository.save(challengeGroupUserExp); - } -} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupUserExpRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java similarity index 56% rename from zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupUserExpRepository.java rename to zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java index c7f7723..ee8b4c6 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/ChallengeGroupUserExpRepository.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpRepository.java @@ -1,6 +1,6 @@ -package org.haedal.zzansuni.infrastructure.challengegroup; +package org.haedal.zzansuni.infrastructure.userchallenge; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.springframework.data.jpa.repository.JpaRepository; public interface ChallengeGroupUserExpRepository extends JpaRepository { diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeGroupUserExpReaderStoreImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeGroupUserExpReaderStoreImpl.java new file mode 100644 index 0000000..9a3eb0d --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/adapter/ChallengeGroupUserExpReaderStoreImpl.java @@ -0,0 +1,59 @@ +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; + +import com.querydsl.jpa.JPQLQueryFactory; +import lombok.RequiredArgsConstructor; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpReader; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.infrastructure.userchallenge.ChallengeGroupUserExpRepository; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Optional; + +import static org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp.challengeGroupUserExp; + +@Component +@RequiredArgsConstructor +public class ChallengeGroupUserExpReaderStoreImpl implements ChallengeGroupUserExpReader, ChallengeGroupUserExpStore { + private final ChallengeGroupUserExpRepository challengeGroupUserExpRepository; + private final JPQLQueryFactory queryFactory; + + @Override + public ChallengeGroupUserExp store(ChallengeGroupUserExp challengeGroupUserExp) { + return challengeGroupUserExpRepository.save(challengeGroupUserExp); + } + + @Override + public Optional findByChallengeGroupIdAndUserId(Long challengeGroupId, Long userId) { + ChallengeGroupUserExp result = queryFactory + .selectFrom(challengeGroupUserExp) + .where(challengeGroupUserExp.challengeGroup.id.eq(challengeGroupId) + .and(challengeGroupUserExp.user.id.eq(userId))) + .fetchOne(); + return Optional.ofNullable(result); + } + + @Override + public Page getUserExpPagingWithUserByChallengeGroupId(Long challengeGroupId, Pageable pageable) { + Long count = queryFactory + .select(challengeGroupUserExp.count()) + .from(challengeGroupUserExp) + .where(challengeGroupUserExp.challengeGroup.id.eq(challengeGroupId)) + .fetchOne(); + + List page = queryFactory + .selectFrom(challengeGroupUserExp) + .where(challengeGroupUserExp.challengeGroup.id.eq(challengeGroupId)) + .innerJoin(challengeGroupUserExp.user).fetchJoin() + .orderBy(challengeGroupUserExp.totalExp.desc()) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetch(); + + return new PageImpl<>(page, pageable, count == null ? 0 : count); + } +} diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java index 5e63330..bb13473 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java @@ -13,8 +13,8 @@ import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeService; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeStore; -import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupUserExpStore; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpStore; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.user.User; import org.haedal.zzansuni.domain.user.UserReader; import org.haedal.zzansuni.global.security.Role; From c227c331632f13154015447aa2c96d0b15850683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=ED=99=8D=EC=84=9D?= <78216059+bayy1216@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:01:24 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[Refactor]:=20=EC=B1=8C=EB=A6=B0=EC=A7=80?= =?UTF-8?q?=EB=9E=AD=ED=82=B9=20=EB=AA=A8=EB=8D=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ChallengeGroupModel.java | 17 +------------- .../ChallengeGroupRankingModel.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeGroupRankingModel.java diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java index 8b6199b..e893f7a 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java @@ -4,8 +4,6 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroupImage; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.user.UserModel; import java.time.LocalDate; import java.util.List; @@ -115,19 +113,6 @@ public static Detail from(ChallengeGroup challengeGroup, List Date: Mon, 12 Aug 2024 12:16:02 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[Refactor]:=20=EC=9C=A0=EC=A0=80=EC=B1=8C?= =?UTF-8?q?=EB=A6=B0=EC=A7=80=20=EB=AA=A8=EB=8D=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge/ChallengeController.java | 7 +- .../controller/challenge/ChallengeRes.java | 42 ++++---- .../challengegroup/ChallengeGroupRes.java | 7 +- .../application/ChallengeModel.java | 91 +---------------- .../port/ChallengeGroupReader.java | 3 +- .../application/ChallengeRankingService.java | 9 +- .../application/ChallengeRecordService.java | 5 +- .../application/UserChallengeModel.java | 98 +++++++++++++++++++ .../application/UserChallengeService.java | 12 +-- .../adapter/ChallengeGroupReaderImpl.java | 5 +- ...erviceTest.java => RecordServiceTest.java} | 10 +- ...ceTest.java => UserRecordServiceTest.java} | 7 +- 12 files changed, 151 insertions(+), 145 deletions(-) create mode 100644 zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeModel.java rename zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/{ChallengeRecordServiceTest.java => RecordServiceTest.java} (93%) rename zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/{UserChallengeRecordServiceTest.java => UserRecordServiceTest.java} (96%) diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java index 06198af..3cedae9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java @@ -11,9 +11,8 @@ import org.haedal.zzansuni.core.api.ApiResponse; import org.haedal.zzansuni.domain.ImageUploader; import org.haedal.zzansuni.domain.challengegroup.ChallengeCommand; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeComplete; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeCurrent; import org.haedal.zzansuni.domain.userchallenge.application.ChallengeRecordService; +import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeModel; import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeService; import org.haedal.zzansuni.global.jwt.JwtUser; import org.springframework.data.domain.Page; @@ -95,7 +94,7 @@ public ApiResponse> getCha @Valid PagingRequest pagingRequest, @AuthenticationPrincipal JwtUser jwtUser ) { - Page page = userChallengeService.getCurrentChallenges( + Page page = userChallengeService.getCurrentChallenges( jwtUser.getId(), pagingRequest.toPageable()); PagingResponse response = PagingResponse.from( @@ -110,7 +109,7 @@ public ApiResponse> getChallengeComple @Valid PagingRequest pagingRequest, @AuthenticationPrincipal JwtUser jwtUser ) { - Page page = userChallengeService.getCompleteChallenges( + Page page = userChallengeService.getCompleteChallenges( jwtUser.getId(), pagingRequest.toPageable()); PagingResponse response = PagingResponse.from( diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java index f398e8c..4d69c62 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeRes.java @@ -2,15 +2,13 @@ import lombok.Builder; import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; +import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; +import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeModel; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeComplete; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeCurrent; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; public class ChallengeRes { @@ -41,7 +39,7 @@ public record ChallengeRecordResponse( List recordIds ) { - public static ChallengeRecordResponse from(ChallengeRecord dto) { + public static ChallengeRecordResponse from(UserChallengeModel.Record dto) { return ChallengeRecordResponse.builder() .title(dto.title()) .totalCount(dto.totalCount()) @@ -90,17 +88,17 @@ public record ChallengeCurrentResponse( ) { - public static ChallengeCurrentResponse from(ChallengeCurrent challengeCurrent) { + public static ChallengeCurrentResponse from(UserChallengeModel.Current current) { return ChallengeCurrentResponse.builder() - .challengeId(challengeCurrent.challengeId()) - .title(challengeCurrent.title()) - .successCount(challengeCurrent.successCount()) - .totalCount(challengeCurrent.totalCount()) - .participationDate(challengeCurrent.participationDate()) - .startDate(challengeCurrent.startDate()) - .endDate(challengeCurrent.endDate()) - .category(challengeCurrent.category()) - .reviewWritten(challengeCurrent.reviewWritten()) + .challengeId(current.challengeId()) + .title(current.title()) + .successCount(current.successCount()) + .totalCount(current.totalCount()) + .participationDate(current.participationDate()) + .startDate(current.startDate()) + .endDate(current.endDate()) + .category(current.category()) + .reviewWritten(current.reviewWritten()) .build(); } } @@ -114,13 +112,13 @@ public record ChallengeCompleteResponse( Boolean reviewWritten ) { - public static ChallengeCompleteResponse from(ChallengeComplete challengeComplete) { + public static ChallengeCompleteResponse from(UserChallengeModel.Complete complete) { return ChallengeCompleteResponse.builder() - .id(challengeComplete.challengeId()) - .title(challengeComplete.title()) - .successDate(challengeComplete.successDate()) - .category(challengeComplete.category()) - .reviewWritten(challengeComplete.reviewWritten()) + .id(complete.challengeId()) + .title(complete.title()) + .successDate(complete.successDate()) + .category(complete.category()) + .reviewWritten(complete.reviewWritten()) .build(); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java index 91ae6af..42d85f9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java @@ -6,6 +6,7 @@ import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.DayType; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeGroupRankingModel; import org.springframework.data.domain.Page; import java.time.LocalDate; @@ -137,8 +138,8 @@ public record RankingPagingResponse( ChallengeGroupRes.Ranking myRanking //null이면 랭킹이 없는 것 ) { public static RankingPagingResponse from( - Page rankingPage, - ChallengeGroupModel.Ranking myRanking + Page rankingPage, + ChallengeGroupRankingModel.Main myRanking ){ var data = rankingPage.getContent().stream() .map(ChallengeGroupRes.Ranking::from) @@ -161,7 +162,7 @@ public record Ranking( UserRes.User user ) { public static Ranking from( - ChallengeGroupModel.Ranking model + ChallengeGroupRankingModel.Main model ){ var user = UserRes.User.from(model.user()); return Ranking.builder() diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java index e77c690..dcfb716 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java @@ -1,17 +1,11 @@ package org.haedal.zzansuni.domain.challengegroup.application; -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.Challenge; -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.userchallenge.UserChallenge; -import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; + +import java.time.LocalDate; @Getter @Builder @@ -68,87 +62,6 @@ public static ChallengeVerificationResult from(Integer totalCount, Integer succe } - @Builder - public record ChallengeRecord( - String title, - Integer totalCount, - Integer successCount, - LocalDate startDate, - LocalDate endDate, - List recordIds - ) { - - public static ChallengeRecord from( - Challenge challenge, - List challengeVerificationList - ) { - ChallengeGroup challengeGroup = challenge.getChallengeGroup(); - 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(); - } - } - - @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(); - } - } - - @Builder - public record ChallengeComplete( - Long challengeId, - String title, - LocalDate successDate, - ChallengeCategory category, - Boolean reviewWritten - ) { - - public static ChallengeComplete from(UserChallenge userChallenge, Boolean reviewWritten - ) { - Challenge challenge = userChallenge.getChallenge(); - - return ChallengeComplete.builder() - .challengeId(challenge.getId()) - .title(challenge.getChallengeGroup().getTitle()) - // 성공한 날짜는 가장 최근에 인증한 날짜로 설정 - .successDate(userChallenge.getSuccessDate().orElse(null)) - .category(challenge.getChallengeGroup().getCategory()) - .reviewWritten(reviewWritten) - .build(); - } - - } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java index eb0dbbe..82da7ac 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/port/ChallengeGroupReader.java @@ -3,6 +3,7 @@ import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeGroupRankingModel; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -15,5 +16,5 @@ public interface ChallengeGroupReader { Page getChallengeGroupsShortsPaging(Pageable pageable, Long userId); - ChallengeGroupModel.Ranking getRanking(Long challengeGroupId, Long userId); + ChallengeGroupRankingModel.Main getRanking(Long challengeGroupId, Long userId); } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java index 4644641..f90dcc5 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java @@ -1,9 +1,8 @@ package org.haedal.zzansuni.domain.userchallenge.application; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeGroupModel; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeGroupReader; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeGroupUserExpReader; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -17,7 +16,7 @@ public class ChallengeRankingService { private final ChallengeGroupUserExpReader challengeGroupUserExpReader; @Transactional(readOnly = true) - public Page getChallengeGroupRankingsPaging(Long challengeGroupId, Pageable pageable) { + public Page getChallengeGroupRankingsPaging(Long challengeGroupId, Pageable pageable) { Page challengeGroupUserExps = challengeGroupUserExpReader.getUserExpPagingWithUserByChallengeGroupId(challengeGroupId, pageable); @@ -26,12 +25,12 @@ public Page getChallengeGroupRankingsPaging(Long ch return challengeGroupUserExps.map(e->{ int rank = challengeGroupUserExps.getNumber() * challengeGroupUserExps.getSize() + 1 + challengeGroupUserExps.getContent().indexOf(e); - return ChallengeGroupModel.Ranking.from(e, rank); + return ChallengeGroupRankingModel.Main.from(e, rank); }); } - public ChallengeGroupModel.Ranking getChallengeGroupRanking(Long challengeGroupId, Long id) { + public ChallengeGroupRankingModel.Main getChallengeGroupRanking(Long challengeGroupId, Long id) { return challengeGroupReader.getRanking(challengeGroupId, id); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java index 0995659..472d879 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java @@ -3,7 +3,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.haedal.zzansuni.domain.challengegroup.Challenge; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; @@ -27,13 +26,13 @@ public class ChallengeRecordService { * 챌린지 기록 가져오기 */ @Transactional(readOnly = true) - public ChallengeRecord getChallengeRecord(Long userId, Long challengeId) { + public UserChallengeModel.Record getChallengeRecord(Long userId, Long challengeId) { Challenge challenge = challengeReader.getById(challengeId); UserChallenge userChallenge = userChallengeReader.getByUserIdAndChallengeId(userId, challengeId); List challengeVerifications = challengeVerificationReader.findByUserChallengeId(userChallenge.getId()); - return ChallengeRecord.from(challenge, challengeVerifications); + return UserChallengeModel.Record.from(challenge, challengeVerifications); } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeModel.java new file mode 100644 index 0000000..6889adb --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeModel.java @@ -0,0 +1,98 @@ +package org.haedal.zzansuni.domain.userchallenge.application; + +import lombok.Builder; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; +import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; +import org.haedal.zzansuni.domain.userchallenge.ChallengeVerification; +import org.haedal.zzansuni.domain.userchallenge.UserChallenge; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +public class UserChallengeModel { + @Builder + public record Record( + String title, + Integer totalCount, + Integer successCount, + LocalDate startDate, + LocalDate endDate, + List recordIds + ) { + + public static Record from( + Challenge challenge, + List challengeVerificationList + ) { + ChallengeGroup challengeGroup = challenge.getChallengeGroup(); + return Record.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(); + } + } + + @Builder + public record Current( + Long challengeId, + String title, + Integer totalCount, + Integer successCount, + LocalDateTime participationDate, + LocalDate startDate, + LocalDate endDate, + ChallengeCategory category, + Boolean reviewWritten + ) { + + public static Current from(UserChallenge userChallenge, Boolean reviewWritten) { + Challenge challenge = userChallenge.getChallenge(); + return Current.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(); + } + + } + + @Builder + public record Complete( + Long challengeId, + String title, + LocalDate successDate, + ChallengeCategory category, + Boolean reviewWritten + ) { + + public static Complete from(UserChallenge userChallenge, Boolean reviewWritten + ) { + Challenge challenge = userChallenge.getChallenge(); + + return Complete.builder() + .challengeId(challenge.getId()) + .title(challenge.getChallengeGroup().getTitle()) + // 성공한 날짜는 가장 최근에 인증한 날짜로 설정 + .successDate(userChallenge.getSuccessDate().orElse(null)) + .category(challenge.getChallengeGroup().getCategory()) + .reviewWritten(reviewWritten) + .build(); + } + + } +} diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java index 13686aa..f442233 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java @@ -97,8 +97,8 @@ public ChallengeModel.ChallengeVerificationResult verification( * 진행중인 챌린지 페이징 조회 */ @Transactional(readOnly = true) - public Page getCurrentChallenges(Long userId, - Pageable pageable) { + public Page getCurrentChallenges(Long userId, + Pageable pageable) { Page userChallengePage = userChallengeReader .getCurrentChallengePageByUserId(userId, pageable); @@ -107,15 +107,15 @@ public Page getCurrentChallenges(Long userId, .getReviewWrittenMapByUserChallengeId(userChallengeIds); return userChallengePage.map( - m -> ChallengeModel.ChallengeCurrent.from(m, reviewWrittenMap.get(m.getId()))); + m -> UserChallengeModel.Current.from(m, reviewWrittenMap.get(m.getId()))); } /** * 완료한 챌린지 페이징 조회 */ @Transactional(readOnly = true) - public Page getCompleteChallenges(Long userId, - Pageable pageable) { + public Page getCompleteChallenges(Long userId, + Pageable pageable) { Page userChallengePage = userChallengeReader .getCompletedChallengePageByUserId(userId, pageable); @@ -124,6 +124,6 @@ public Page getCompleteChallenges(Long userId, .getReviewWrittenMapByUserChallengeId(userChallengeIds); return userChallengePage.map( - m -> ChallengeModel.ChallengeComplete.from(m, reviewWrittenMap.get(m.getId()))); + m -> UserChallengeModel.Complete.from(m, reviewWrittenMap.get(m.getId()))); } } diff --git a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java index 2d542a1..3f869a9 100644 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/adapter/ChallengeGroupReaderImpl.java @@ -13,6 +13,7 @@ import org.haedal.zzansuni.domain.user.UserModel; import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; import org.haedal.zzansuni.domain.userchallenge.QChallengeGroupUserExp; +import org.haedal.zzansuni.domain.userchallenge.application.ChallengeGroupRankingModel; import org.haedal.zzansuni.infrastructure.challengegroup.ChallengeGroupRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -88,7 +89,7 @@ public Page getChallengeGroupsShortsPaging(Pageable pageable, Lo @Override - public ChallengeGroupModel.Ranking getRanking(Long challengeGroupId, Long userId) { + public ChallengeGroupRankingModel.Main getRanking(Long challengeGroupId, Long userId) { User user = queryFactory .selectFrom(QUser.user) .where(QUser.user.id.eq(userId)) @@ -114,7 +115,7 @@ public ChallengeGroupModel.Ranking getRanking(Long challengeGroupId, Long userId .and(QChallengeGroupUserExp.challengeGroupUserExp.user.id.eq(userId))) .fetchOne(); - return ChallengeGroupModel.Ranking.builder() + return ChallengeGroupRankingModel.Main.builder() .rank(rank==null ? 0 : rank) .accumulatedPoint(challengeGroupUserExp != null ? challengeGroupUserExp.getTotalExp() : 0) .user(UserModel.Main.from(user)) diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/RecordServiceTest.java similarity index 93% rename from zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java rename to zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/RecordServiceTest.java index 45cd5ab..a334ae0 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeRecordServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/challenge/RecordServiceTest.java @@ -4,15 +4,11 @@ import org.haedal.zzansuni.domain.challengegroup.*; import org.haedal.zzansuni.domain.userchallenge.*; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeRecordService; -import org.haedal.zzansuni.domain.challengegroup.application.ChallengeModel.ChallengeRecord; +import org.haedal.zzansuni.domain.userchallenge.application.*; import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewModel; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeReviewService; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewStore; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; -import org.haedal.zzansuni.domain.userchallenge.application.ChallengeVerificationModel; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeVerificationReader; import org.haedal.zzansuni.domain.user.User; import org.junit.jupiter.api.BeforeEach; @@ -34,7 +30,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -class ChallengeRecordServiceTest { +class RecordServiceTest { @Mock private ChallengeReader challengeReader; @@ -132,7 +128,7 @@ void getChallengeRecord() { when(challengeVerificationReader.findByUserChallengeId(userChallenge.getId())).thenReturn( Collections.singletonList(challengeVerification)); - ChallengeRecord result = challengeRecordService.getChallengeRecord(userId, challengeId); + UserChallengeModel.Record result = challengeRecordService.getChallengeRecord(userId, challengeId); assertNotNull(result); verify(challengeReader).getById(challengeId); diff --git a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserRecordServiceTest.java similarity index 96% rename from zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java rename to zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserRecordServiceTest.java index bb13473..603b214 100644 --- a/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserChallengeRecordServiceTest.java +++ b/zzansuni-api-server/app/src/test/java/org/haedal/zzansuni/domain/challengegroup/userchallenge/UserRecordServiceTest.java @@ -8,6 +8,7 @@ import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; import org.haedal.zzansuni.domain.userchallenge.application.AddUserExpByVerificationUseCase; import org.haedal.zzansuni.domain.userchallenge.ChallengeStatus; +import org.haedal.zzansuni.domain.userchallenge.application.UserChallengeModel; import org.haedal.zzansuni.domain.userchallenge.port.ChallengeReviewReader; import org.haedal.zzansuni.domain.userchallenge.UserChallenge; import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; @@ -38,7 +39,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -class UserChallengeRecordServiceTest { +class UserRecordServiceTest { @Mock private UserChallengeStore userChallengeStore; @@ -195,7 +196,7 @@ void getCurrentChallenges() { Collections.singletonList(userChallenge.getId()))) .thenReturn(Collections.singletonMap(userChallenge.getId(), true)); - Page resultPage = userChallengeService.getCurrentChallenges( + Page resultPage = userChallengeService.getCurrentChallenges( user.getId(), pageable); assertNotNull(resultPage); @@ -219,7 +220,7 @@ void getCompleteChallenges() { Collections.singletonList(userChallenge.getId()))) .thenReturn(Collections.singletonMap(userChallenge.getId(), true)); - Page resultPage = userChallengeService.getCompleteChallenges( + Page resultPage = userChallengeService.getCompleteChallenges( user.getId(), pageable); assertNotNull(resultPage);