From b4d122035dfbac2598d8ffde5e7d2ff5e174d9b9 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Fri, 5 Jul 2024 09:24:34 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EB=82=B4=20=ED=8C=9C=ED=81=B4=EB=9F=BD?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EC=8A=A4=ED=85=9D=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmclub/dto/res/GetMyFarmClubResponseDto.java | 2 ++ .../farmclub/repository/FarmClubRepositoryImpl.java | 12 ++++++++---- .../domain/farmclub/vo/GetMyFarmClubVo.java | 4 +++- .../domain/veggieinfo/helper/VeggieInfoHelper.java | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java index cf31e153..cca52a4f 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java @@ -13,6 +13,7 @@ public record GetMyFarmClubResponseDto( String farmClubName, String farmClubImage, Long wholeMemberCount, + Integer currentStep, List steps, String advice, Long daysSinceStart @@ -23,6 +24,7 @@ public static GetMyFarmClubResponseDto of(GetMyFarmClubVo farmClubInfo, List results = queryFactory + .select(userFarmClub.count(), userFarmClub.currentStep) .from(userFarmClub) .join(userFarmClub.farmClub, farmClub) - .fetchOne(); + .fetch(); + + Long userFarmClubCount = results.get(0).get(userFarmClub.count()); + Integer currentStep = results.get(0).get(userFarmClub.currentStep); LocalDate userFarmClubCreatedDate = queryFactory .select(farmClub.startedAt) @@ -96,7 +100,7 @@ public GetMyFarmClubVo findMyFarmClub(Long farmClubId, Long userId) { log.info("userFarmClubCount: {}", userFarmClubCount); log.info("userFarmClubCreatedDate: {}", userFarmClubCreatedDate); - return GetMyFarmClubVo.of(baseInfo, userFarmClubCount, userFarmClubCreatedDate); + return GetMyFarmClubVo.of(baseInfo, userFarmClubCount, currentStep, userFarmClubCreatedDate); } public HistoryDetailVo getFarmClubDetail(Long userFarmClubId) { diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMyFarmClubVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMyFarmClubVo.java index fee9fa37..b583d90b 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMyFarmClubVo.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMyFarmClubVo.java @@ -13,14 +13,16 @@ public record GetMyFarmClubVo( String farmClubImage, String veggieInfoId, Long wholeMemberCount, + Integer currentStep, Long daySinceStart ) { - public static GetMyFarmClubVo of(BaseInfo baseInfo, Long wholeMemberCount, LocalDate dayRegister) { + public static GetMyFarmClubVo of(BaseInfo baseInfo, Long wholeMemberCount, Integer currentStep,LocalDate dayRegister) { return new GetMyFarmClubVo( baseInfo.farmClubName(), baseInfo.farmClubImage(), baseInfo.veggieInfoId(), wholeMemberCount, + currentStep, ChronoUnit.DAYS.between(dayRegister, LocalDate.now()) ); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java index d0f5807f..675ac7fc 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java @@ -37,6 +37,6 @@ public List getStepList(String veggieInfoId) { public String getStepName(String veggieInfoId, int step) { List stepList = getStepList(veggieInfoId); - return stepList.get(step).content(); + return stepList.get(step - 1).content(); } }