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/challenge/ChallengeController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeController.java similarity index 84% 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 597be36..3cedae9 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,14 +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.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.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; import org.springframework.http.HttpStatus; @@ -28,7 +27,7 @@ @Slf4j public class ChallengeController { - private final ChallengeService challengeService; + private final ChallengeRecordService challengeRecordService; private final UserChallengeService userChallengeService; private final ImageUploader imageUploader; @@ -70,7 +69,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 +82,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, "챌린지 기록 상세 조회에 성공하였습니다."); @@ -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/challengegroup/challenge/ChallengeReq.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challenge/ChallengeReq.java similarity index 83% 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 4f83d74..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,6 +1,6 @@ -package org.haedal.zzansuni.controller.challengegroup.challenge; +package org.haedal.zzansuni.controller.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/challenge/ChallengeRes.java similarity index 62% 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 65105a9..4d69c62 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,16 +1,14 @@ -package org.haedal.zzansuni.controller.challengegroup.challenge; +package org.haedal.zzansuni.controller.challenge; 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.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; 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/ChallengeGroupController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupController.java index 18cdf4f..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 @@ -8,8 +8,9 @@ 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.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/controller/challengegroup/ChallengeGroupRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengegroup/ChallengeGroupRes.java index 3b83ab4..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 @@ -3,9 +3,10 @@ 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.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/controller/challengegroup/review/ChallengeReviewController.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewController.java similarity index 78% 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 64f6c89..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,11 +6,11 @@ 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.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.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 +22,7 @@ @RequiredArgsConstructor public class ChallengeReviewController { - private final ChallengeService challengeService; + private final ChallengeReviewService challengeReviewService; @Operation(summary = "챌린지 그룹 최근 리뷰 페이징", description = "챌린지 최근 리뷰 페이징 조회.") @@ -31,7 +31,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 +50,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 +69,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 +81,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/controller/challengegroup/review/ChallengeReviewRes.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/controller/challengereview/ChallengeReviewRes.java similarity index 86% 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 a38e899..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,11 +1,11 @@ -package org.haedal.zzansuni.controller.challengegroup.review; +package org.haedal.zzansuni.controller.challengereview; 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/ChallengeGroupModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeGroupModel.java similarity index 84% 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..e893f7a 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,12 +1,9 @@ -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.user.UserModel; import java.time.LocalDate; import java.util.List; @@ -116,19 +113,6 @@ public static Detail from(ChallengeGroup challengeGroup, List 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/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/application/ChallengeModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java new file mode 100644 index 0000000..dcfb716 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/application/ChallengeModel.java @@ -0,0 +1,67 @@ +package org.haedal.zzansuni.domain.challengegroup.application; + +import lombok.Builder; +import lombok.Getter; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +import org.haedal.zzansuni.domain.challengegroup.DayType; + +import java.time.LocalDate; + +@Getter +@Builder +public class ChallengeModel { + + + @Builder + public record Main( + Long id, + Integer requiredCount, + DayType dayType, + Integer onceExp, + Integer successExp, + Integer difficulty, + LocalDate startDate, + LocalDate endDate + ) { + public static Main from(Challenge challenge) { + return Main.builder() + .id(challenge.getId()) + .requiredCount(challenge.getRequiredCount()) + .dayType(challenge.getDayType()) + .onceExp(challenge.getOnceExp()) + .successExp(challenge.getSuccessExp()) + .difficulty(challenge.getDifficulty()) + .startDate(challenge.getStartDate()) + .endDate(challenge.getEndDate()) + .build(); + } + } + + + @Builder + public record ChallengeVerificationResult(Integer totalCount, Integer successCount, + Integer obtainExp) { + + public static ChallengeVerificationResult of(Integer totalCount, Integer successCount, + Integer obtainExp) { + return ChallengeVerificationResult.builder() + .totalCount(totalCount) + .successCount(successCount) + .obtainExp(obtainExp) + .build(); + } + + public static ChallengeVerificationResult from(Integer totalCount, Integer successCount, + Integer obtainExp) { + return ChallengeVerificationResult.builder() + .totalCount(totalCount) + .successCount(successCount) + .obtainExp(obtainExp) + .build(); + } + } + + + + +} 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/challenge/ChallengeModel.java deleted file mode 100644 index b2f05e4..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeModel.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import lombok.Builder; -import lombok.Getter; -import org.haedal.zzansuni.domain.challengegroup.ChallengeCategory; -import org.haedal.zzansuni.domain.challengegroup.ChallengeGroup; -import org.haedal.zzansuni.domain.challengegroup.DayType; -import org.haedal.zzansuni.domain.userchallenge.UserChallenge; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerification; - -@Getter -@Builder -public class ChallengeModel { - - - @Builder - public record Main( - Long id, - Integer requiredCount, - DayType dayType, - Integer onceExp, - Integer successExp, - Integer difficulty, - LocalDate startDate, - LocalDate endDate - ) { - public static Main from(Challenge challenge) { - return Main.builder() - .id(challenge.getId()) - .requiredCount(challenge.getRequiredCount()) - .dayType(challenge.getDayType()) - .onceExp(challenge.getOnceExp()) - .successExp(challenge.getSuccessExp()) - .difficulty(challenge.getDifficulty()) - .startDate(challenge.getStartDate()) - .endDate(challenge.getEndDate()) - .build(); - } - } - - - @Builder - public record ChallengeVerificationResult(Integer totalCount, Integer successCount, - Integer obtainExp) { - - public static ChallengeVerificationResult of(Integer totalCount, Integer successCount, - Integer obtainExp) { - return ChallengeVerificationResult.builder() - .totalCount(totalCount) - .successCount(successCount) - .obtainExp(obtainExp) - .build(); - } - - public static ChallengeVerificationResult from(Integer totalCount, Integer successCount, - Integer obtainExp) { - return ChallengeVerificationResult.builder() - .totalCount(totalCount) - .successCount(successCount) - .obtainExp(obtainExp) - .build(); - } - } - - - @Builder - public record ChallengeRecord( - String title, - Integer totalCount, - Integer successCount, - LocalDate startDate, - LocalDate endDate, - List 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/challenge/ChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeService.java deleted file mode 100644 index 89510ec..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/challengegroup/challenge/ChallengeService.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; - -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.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; - -@RequiredArgsConstructor -@Service -@Slf4j -public class ChallengeService { - - private final ChallengeReader challengeReader; - - private final UserChallengeReader userChallengeReader; - - private final ChallengeVerificationReader challengeVerificationReader; - - private final ChallengeReviewStore challengeReviewStore; - private final ChallengeReviewReader challengeReviewReader; - - - /** - * 챌린지 기록 가져오기 - */ - @Transactional(readOnly = true) - public ChallengeModel.ChallengeRecord 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); - - } - - /** - * 챌린지 기록 상세 가져오기 - */ - @Transactional(readOnly = true) - public ChallengeVerificationModel getChallengeRecordDetail(Long recordId) { - ChallengeVerification challengeVerification = challengeVerificationReader.getById(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/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..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 @@ -2,13 +2,11 @@ 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.application.ChallengeGroupRankingModel; 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 +16,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); + ChallengeGroupRankingModel.Main getRanking(Long challengeGroupId, Long userId); } 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/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/challengegroup/challenge/ChallengeStatus.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/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/userchallenge/ChallengeStatus.java index 945bb87..b057bb7 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/userchallenge/ChallengeStatus.java @@ -1,4 +1,4 @@ -package org.haedal.zzansuni.domain.challengegroup.challenge; +package org.haedal.zzansuni.domain.userchallenge; import lombok.RequiredArgsConstructor; 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..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 @@ -7,10 +7,8 @@ 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.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 65% 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..5870d9b 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,22 +1,24 @@ -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.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/ChallengeGroupRankingModel.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeGroupRankingModel.java new file mode 100644 index 0000000..19b2a68 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeGroupRankingModel.java @@ -0,0 +1,23 @@ +package org.haedal.zzansuni.domain.userchallenge.application; + +import lombok.Builder; +import org.haedal.zzansuni.domain.user.UserModel; +import org.haedal.zzansuni.domain.userchallenge.ChallengeGroupUserExp; + +public class ChallengeGroupRankingModel { + @Builder + public record Main( + UserModel.Main user, + Integer rank, + Integer accumulatedPoint + ) { + public static Main from(ChallengeGroupUserExp challengeGroupUserExp, int rank) { + var userModel = UserModel.Main.from(challengeGroupUserExp.getUser()); + return Main.builder() + .user(userModel) + .rank(rank) + .accumulatedPoint(challengeGroupUserExp.getTotalExp()) + .build(); + } + } +} 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..f90dcc5 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRankingService.java @@ -0,0 +1,36 @@ +package org.haedal.zzansuni.domain.userchallenge.application; + +import lombok.RequiredArgsConstructor; +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; +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 ChallengeGroupRankingModel.Main.from(e, rank); + }); + } + + + 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 new file mode 100644 index 0000000..472d879 --- /dev/null +++ b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/ChallengeRecordService.java @@ -0,0 +1,49 @@ +package org.haedal.zzansuni.domain.userchallenge.application; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.haedal.zzansuni.domain.challengegroup.Challenge; +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.port.ChallengeVerificationReader; +import org.haedal.zzansuni.domain.userchallenge.port.UserChallengeReader; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@RequiredArgsConstructor +@Service +@Slf4j +public class ChallengeRecordService { + private final ChallengeReader challengeReader; + private final UserChallengeReader userChallengeReader; + private final ChallengeVerificationReader challengeVerificationReader; + + + /** + * 챌린지 기록 가져오기 + */ + @Transactional(readOnly = true) + 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 UserChallengeModel.Record.from(challenge, challengeVerifications); + + } + + /** + * 챌린지 기록 상세 가져오기 + */ + @Transactional(readOnly = true) + public ChallengeVerificationModel getChallengeRecordDetail(Long recordId) { + ChallengeVerification challengeVerification = challengeVerificationReader.getById(recordId); + return ChallengeVerificationModel.from(challengeVerification); + } + + +} 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/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/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/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/UserChallengeService.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/domain/userchallenge/application/UserChallengeService.java similarity index 79% 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..f442233 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; @@ -95,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); @@ -105,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); @@ -122,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/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/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 69% 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..3f869a9 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,20 @@ -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.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.userchallenge.userexp.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.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; import org.springframework.data.domain.Pageable; @@ -20,10 +23,9 @@ 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.userchallenge.userexp.QChallengeGroupUserExp.challengeGroupUserExp; + @Component @RequiredArgsConstructor @@ -85,38 +87,9 @@ 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) { + public ChallengeGroupRankingModel.Main getRanking(Long challengeGroupId, Long userId) { User user = queryFactory .selectFrom(QUser.user) .where(QUser.user.id.eq(userId)) @@ -142,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/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/challenge/ChallengeStoreImpl.java deleted file mode 100644 index 228b0d3..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/challengegroup/challenge/ChallengeStoreImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.haedal.zzansuni.infrastructure.challengegroup.challenge; - -import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.challenge.port.ChallengeStore; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class ChallengeStoreImpl implements ChallengeStore { - - private final ChallengeRepository challengeRepository; - -} 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 deleted file mode 100644 index 9f2ed18..0000000 --- a/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeGroupUserExpStoreImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -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.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/userchallenge/review/ChallengeReviewRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeReviewRepository.java similarity index 72% 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 450227f..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,8 +1,8 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.review; +package org.haedal.zzansuni.infrastructure.userchallenge; 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/verification/ChallengeVerificationRepository.java b/zzansuni-api-server/app/src/main/java/org/haedal/zzansuni/infrastructure/userchallenge/ChallengeVerificationRepository.java similarity index 77% 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 742b892..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,7 +1,7 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.verification; +package org.haedal.zzansuni.infrastructure.userchallenge; 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/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 93% 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 68f3b66..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; @@ -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를 가져온다. 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/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 90% 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 9bc90c1..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,20 +1,18 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.review; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; 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.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.haedal.zzansuni.infrastructure.userchallenge.ChallengeReviewRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; 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/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 59% 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 5115bbc..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.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.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 79% 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 46d4653..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,11 +1,12 @@ -package org.haedal.zzansuni.infrastructure.userchallenge.verification; +package org.haedal.zzansuni.infrastructure.userchallenge.adapter; import java.util.List; 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.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 94% 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 1d286e9..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,12 +1,13 @@ -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; import lombok.RequiredArgsConstructor; -import org.haedal.zzansuni.domain.challengegroup.challenge.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; +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; @@ -58,7 +59,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/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 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/RecordServiceTest.java similarity index 81% 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/RecordServiceTest.java index 311361e..a334ae0 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/RecordServiceTest.java @@ -1,22 +1,16 @@ 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.userchallenge.UserChallenge; + +import org.haedal.zzansuni.domain.challengegroup.*; +import org.haedal.zzansuni.domain.userchallenge.*; +import org.haedal.zzansuni.domain.userchallenge.application.*; +import org.haedal.zzansuni.domain.challengegroup.port.ChallengeReader; +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.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.port.ChallengeVerificationReader; import org.haedal.zzansuni.domain.user.User; -import org.haedal.zzansuni.domain.userchallenge.verification.ChallengeVerificationStatus; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -36,7 +30,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -class ChallengeServiceTest { +class RecordServiceTest { @Mock private ChallengeReader challengeReader; @@ -54,7 +48,10 @@ class ChallengeServiceTest { private ChallengeReviewReader challengeReviewReader; @InjectMocks - private ChallengeService challengeService; + private ChallengeRecordService challengeRecordService; + + @InjectMocks + private ChallengeReviewService challengeReviewService; private Challenge challenge; private ChallengeGroup challengeGroup; @@ -131,7 +128,7 @@ void getChallengeRecord() { when(challengeVerificationReader.findByUserChallengeId(userChallenge.getId())).thenReturn( Collections.singletonList(challengeVerification)); - ChallengeRecord result = challengeService.getChallengeRecord(userId, challengeId); + UserChallengeModel.Record result = challengeRecordService.getChallengeRecord(userId, challengeId); assertNotNull(result); verify(challengeReader).getById(challengeId); @@ -144,7 +141,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); @@ -176,7 +173,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 +191,7 @@ void getChallengeReviewsByGroupId() { when(challengeReviewReader.getChallengeReviewPageByChallengeGroupId(challengeGroupId, pageable)).thenReturn(challengeReviewPage); - Page result = challengeService.getChallengeReviewsByGroupId( + Page result = challengeReviewService.getChallengeReviewsByGroupId( challengeGroupId, pageable); assertNotNull(result); @@ -209,7 +206,7 @@ void getChallengeReviews() { when(challengeReviewReader.getChallengeReviewPage(pageable)).thenReturn( challengeReviewPage); - Page result = challengeService.getChallengeReviews( + Page result = challengeReviewService.getChallengeReviews( pageable); assertNotNull(result); @@ -223,7 +220,7 @@ void getChallengeGroupReviewScore() { when(challengeReviewReader.findByChallengeGroupId(challengeGroupId)).thenReturn( challengeReviews); - ChallengeReviewModel.Score result = challengeService.getChallengeGroupReviewScore( + ChallengeReviewModel.Score result = challengeReviewService.getChallengeGroupReviewScore( challengeGroupId); assertNotNull(result); 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/UserRecordServiceTest.java similarity index 89% 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/UserRecordServiceTest.java index a616b1a..603b214 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/UserRecordServiceTest.java @@ -1,20 +1,21 @@ 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.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; -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; @@ -38,7 +39,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -class UserChallengeServiceTest { +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);