From cb75fffe62420ae55d01943aea8c096c2545f78f Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 20 Aug 2024 22:14:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[fix]=20=EB=82=B4=20=ED=8C=9C=ED=81=B4?= =?UTF-8?q?=EB=9F=BD=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=8A=A4=ED=85=9D?= =?UTF-8?q?=20=EC=88=98=20=EC=9D=B4=EC=83=81=ED=95=9C=20=EB=B2=84=EA=B7=B8?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/FarmClubRepositoryImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java index 68e2c606..d0bc0485 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/FarmClubRepositoryImpl.java @@ -81,14 +81,18 @@ public GetMyFarmClubVo findMyFarmClub(Long farmClubId, Long userId) { .where(farmClub.id.eq(farmClubId)) .fetchOne(); - List results = queryFactory - .select(userFarmClub.count(), userFarmClub.currentStep) + Long userFarmClubCount = queryFactory + .select(userFarmClub.count()) .from(userFarmClub) .join(userFarmClub.farmClub, farmClub) - .fetch(); + .where(farmClub.id.eq(farmClubId)) + .fetchOne(); - Long userFarmClubCount = results.get(0).get(userFarmClub.count()); - Integer currentStep = results.get(0).get(userFarmClub.currentStep); + Integer currentStep = queryFactory + .select(userFarmClub.currentStep) + .from(userFarmClub) + .where(userFarmClub.userId.eq(userId).and(userFarmClub.farmClub.id.eq(farmClubId))) + .fetchOne(); LocalDate userFarmClubCreatedDate = queryFactory .select(farmClub.startedAt) From 9b4f13618ca07a55d07124d98a8a59f18e00aca7 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 20 Aug 2024 22:20:16 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[fix]=20=ED=8C=9C=ED=81=B4=EB=9F=BD=20?= =?UTF-8?q?=EB=8F=84=EC=9B=80=EB=A7=90=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20?= =?UTF-8?q?=EC=B1=84=EC=86=8C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/dto/res/GetHelpAllResponseDto.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetHelpAllResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetHelpAllResponseDto.java index 0b659f4f..657a948c 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetHelpAllResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetHelpAllResponseDto.java @@ -1,7 +1,6 @@ package com.modernfarmer.farmusspring.domain.farmclub.dto.res; import com.modernfarmer.farmusspring.domain.veggieinfo.entity.VeggieInfo; -import com.modernfarmer.farmusspring.domain.veggieinfo.vo.StepVo; import lombok.AccessLevel; import lombok.Builder; @@ -10,6 +9,7 @@ @Builder(access = AccessLevel.PRIVATE) public record GetHelpAllResponseDto( String veggieName, + String veggieImage, String backgroundColor, VeggieInfo.Help help, List steps @@ -17,6 +17,7 @@ public record GetHelpAllResponseDto( public static GetHelpAllResponseDto of(VeggieInfo veggieInfo) { return builder() .veggieName(veggieInfo.getName()) + .veggieImage(veggieInfo.getVeggieImage()) .backgroundColor(veggieInfo.getBackgroundColor()) .help(veggieInfo.getHelp()) .steps(veggieInfo.getSteps()) From c06b78c53630a73a82ae75e045d6629963d8d0d2 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 20 Aug 2024 22:23:22 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[fix]=20=ED=8C=9C=ED=81=B4=EB=9F=BD=20?= =?UTF-8?q?=ED=83=88=ED=87=B4=EC=97=90=EC=84=9C=20=EC=B1=84=EC=86=8C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=97=AC=EB=B6=80=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/controller/FarmClubController.java | 7 +++---- .../domain/farmclub/service/FarmClubService.java | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java index 958bedf9..c242a56d 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java @@ -149,13 +149,12 @@ public BaseResponseDto getFarmClubHelp( return BaseResponseDto.of(SuccessCode.SUCCESS, farmClubService.getHelpAll(farmClubId)); } - @DeleteMapping + @DeleteMapping("/{farmClubId}") public BaseResponseDto withdrawFarmClub( - @RequestParam Long farmClubId, - @RequestParam Boolean deleteVeggie, + @PathVariable Long farmClubId, @AuthenticationPrincipal CustomUser user ) { - farmClubService.withdrawFarmClub(farmClubId, user.getUserId(), deleteVeggie); + farmClubService.withdrawFarmClub(farmClubId, user.getUserId()); return BaseResponseDto.of(SuccessCode.SUCCESS, null); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java index f0d5e613..74f57a98 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java @@ -157,14 +157,9 @@ public GetHelpAllResponseDto getHelpAll(Long farmClubId) { } // 팜클럽 탈퇴 - public void withdrawFarmClub(Long farmClubId, Long userId, Boolean deleteVeggie) { + public void withdrawFarmClub(Long farmClubId, Long userId) { UserFarmClub userFarmClub = userFarmClubHelper.findByUserIdAndFarmClubId(userId, farmClubId); userFarmClubHelper.deleteUserFarmClub(userFarmClub); - if (deleteVeggie) { - Long myVeggieId = userFarmClub.getMyVeggie().getId(); - myVeggieHelper.getMyVeggieEntity(myVeggieId); - myVeggieHelper.deleteMyVeggie(myVeggieId); - } } private String getRandomTip(List stepList, int currentStep) { From 9ef60cd8fff89728361e9573e70dd7c92bb2a316 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 20 Aug 2024 23:19:51 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EB=8C=93=EA=B8=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EC=97=90=20=EB=82=B4=20=EB=8C=93=EA=B8=80=EC=9D=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/controller/FarmClubController.java | 7 ++++--- .../farmclub/repository/MissionPostRepositoryCustom.java | 2 +- .../farmclub/repository/MissionPostRepositoryImpl.java | 5 +++-- .../domain/farmclub/service/MissionPostService.java | 4 ++-- .../domain/farmclub/vo/MissionPostCommentVo.java | 8 +++++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java index c242a56d..2b13ee7a 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java @@ -120,11 +120,12 @@ public BaseResponseDto getMissionPostList( return BaseResponseDto.of(SuccessCode.SUCCESS, missionPostService.getMissionPostList(user.getUserId(), farmClubId)); } - @GetMapping("/mission/{id}") + @GetMapping("/mission/{missionPostId}") public BaseResponseDto getMissionPostComments( - @PathVariable Long id + @AuthenticationPrincipal CustomUser user, + @PathVariable Long missionPostId ) { - return BaseResponseDto.of(SuccessCode.SUCCESS, missionPostService.getMissionPostComment(id)); + return BaseResponseDto.of(SuccessCode.SUCCESS, missionPostService.getMissionPostComment(missionPostId, user.getUserId())); } @GetMapping("/my-veggie") diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java index eb923fe0..1a7a1979 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java @@ -11,7 +11,7 @@ public interface MissionPostRepositoryCustom { List getMissionPostStepNumAndImage(Long farmClubId); - List getMissionPostComment(Long missionPostId); + List getMissionPostComment(Long missionPostId, Long userId); List getMissionPostList(Long userId, Long missionPostId); List getMissionPostHistory(Long missionPostId); void deleteMissionPostLike(Long userId, Long missionPostId); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java index 473ab625..6ad30799 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java @@ -5,6 +5,7 @@ import com.modernfarmer.farmusspring.domain.history.vo.MissionPostHistoryVo; import com.modernfarmer.farmusspring.domain.history.vo.QMissionPostHistoryVo; import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; @@ -40,10 +41,10 @@ public List getMissionPostStepNumAndImage(Long farmClubId) } @Override - public List getMissionPostComment(Long missionPostId) { + public List getMissionPostComment(Long missionPostId, Long userId) { return queryFactory - .select(new QMissionPostCommentVo(missionPostComment, user)) + .select(new QMissionPostCommentVo(missionPostComment, user, Expressions.constant(userId))) .from(missionPostComment) .join(missionPostComment.missionPost, missionPost) .where(missionPost.id.eq(missionPostId)) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java index effdb8ae..c3880a22 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java @@ -70,8 +70,8 @@ public GetMissionPostListResponseDto getMissionPostList(Long userId, Long farmCl return GetMissionPostListResponseDto.of(missionPosts); } - public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId) { - List comments = missionPostRepository.getMissionPostComment(missionPostId); + public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId) { + List comments = missionPostRepository.getMissionPostComment(missionPostId, userId); return GetMissionPostCommentResponseDto.of(comments); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostCommentVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostCommentVo.java index fe3da5e3..524ab2ee 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostCommentVo.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostCommentVo.java @@ -10,17 +10,19 @@ public record MissionPostCommentVo( String nickname, String profileImage, String date, - String content + String content, + Boolean isMyComment ) { @QueryProjection - public MissionPostCommentVo(MissionPostComment missionPostComment, User user) + public MissionPostCommentVo(MissionPostComment missionPostComment, User user, Long myId) { this( missionPostComment.getId(), user.getNickname(), user.getProfileImage(), missionPostComment.getCreatedDate().toString(), - missionPostComment.getComment() + missionPostComment.getComment(), + user.getId().equals(myId) ); } } From c45deaad0c8af322b85a8f10e2303bc1eba3f678 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 20 Aug 2024 23:29:24 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=EA=B8=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EB=82=B4=20=EA=B8=80=EC=9D=B8?= =?UTF-8?q?=EC=A7=80=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80=20=EB=B0=98?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/res/GetMissionPostCommentResponseDto.java | 4 +++- .../domain/farmclub/helper/MissionPostHelper.java | 5 +++++ .../repository/MissionPostRepositoryCustom.java | 3 ++- .../repository/MissionPostRepositoryImpl.java | 14 +++++++++++--- .../farmclub/service/MissionPostService.java | 3 +-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMissionPostCommentResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMissionPostCommentResponseDto.java index d09e4d15..6e008826 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMissionPostCommentResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMissionPostCommentResponseDto.java @@ -7,10 +7,12 @@ @Builder public record GetMissionPostCommentResponseDto( + Boolean isMyPost, List comments ) { - public static GetMissionPostCommentResponseDto of(List comments) { + public static GetMissionPostCommentResponseDto of(Boolean isMyPost, List comments) { return GetMissionPostCommentResponseDto.builder() + .isMyPost(isMyPost) .comments(comments) .build(); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/helper/MissionPostHelper.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/helper/MissionPostHelper.java index 2ab5fbef..3fcef57e 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/helper/MissionPostHelper.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/helper/MissionPostHelper.java @@ -1,5 +1,6 @@ package com.modernfarmer.farmusspring.domain.farmclub.helper; +import com.modernfarmer.farmusspring.domain.farmclub.dto.res.GetMissionPostCommentResponseDto; import com.modernfarmer.farmusspring.domain.farmclub.entity.MissionPost; import com.modernfarmer.farmusspring.domain.farmclub.exception.FarmClubErrorCode; import com.modernfarmer.farmusspring.domain.farmclub.exception.custom.FarmClubEntityNotFoundException; @@ -31,6 +32,10 @@ public List getMissionPostList(Long userId, Long missionPostId) { return missionPostRepository.getMissionPostList(userId, missionPostId); } + public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId) { + return missionPostRepository.getMissionPostComment(missionPostId, userId); + } + @Transactional public void deleteMissionPostLike(Long userId, Long missionPostId) { missionPostRepository.deleteMissionPostLike(userId, missionPostId); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java index 1a7a1979..1b1d5c8c 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java @@ -1,6 +1,7 @@ package com.modernfarmer.farmusspring.domain.farmclub.repository; +import com.modernfarmer.farmusspring.domain.farmclub.dto.res.GetMissionPostCommentResponseDto; import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.MissionPostCommentVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.MissionPostVo; @@ -11,7 +12,7 @@ public interface MissionPostRepositoryCustom { List getMissionPostStepNumAndImage(Long farmClubId); - List getMissionPostComment(Long missionPostId, Long userId); + GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId); List getMissionPostList(Long userId, Long missionPostId); List getMissionPostHistory(Long missionPostId); void deleteMissionPostLike(Long userId, Long missionPostId); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java index 6ad30799..6e10c371 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java @@ -1,6 +1,7 @@ package com.modernfarmer.farmusspring.domain.farmclub.repository; +import com.modernfarmer.farmusspring.domain.farmclub.dto.res.GetMissionPostCommentResponseDto; import com.modernfarmer.farmusspring.domain.farmclub.vo.*; import com.modernfarmer.farmusspring.domain.history.vo.MissionPostHistoryVo; import com.modernfarmer.farmusspring.domain.history.vo.QMissionPostHistoryVo; @@ -41,14 +42,21 @@ public List getMissionPostStepNumAndImage(Long farmClubId) } @Override - public List getMissionPostComment(Long missionPostId, Long userId) { - - return queryFactory + public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId) { + List comments = queryFactory .select(new QMissionPostCommentVo(missionPostComment, user, Expressions.constant(userId))) .from(missionPostComment) .join(missionPostComment.missionPost, missionPost) .where(missionPost.id.eq(missionPostId)) .fetch(); + + Boolean isMyPost = queryFactory + .select(missionPost.userFarmClub.userId.eq(userId)) + .from(missionPost) + .where(missionPost.id.eq(missionPostId)) + .fetchOne(); + + return GetMissionPostCommentResponseDto.of(isMyPost, comments); } @Override diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java index c3880a22..9b1d928d 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java @@ -71,8 +71,7 @@ public GetMissionPostListResponseDto getMissionPostList(Long userId, Long farmCl } public GetMissionPostCommentResponseDto getMissionPostComment(Long missionPostId, Long userId) { - List comments = missionPostRepository.getMissionPostComment(missionPostId, userId); - return GetMissionPostCommentResponseDto.of(comments); + return missionPostHelper.getMissionPostComment(missionPostId, userId); } private MissionPost saveMissionPost(MissionPost missionPost) {