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(); } }