From 0b67b7cea3a0799231d9cbb8c30f754a7f11a604 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 30 Jul 2024 02:13:35 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[fix]=20Q=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=BD=94=EB=93=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 3f831893..cbe79a71 100644 --- a/build.gradle +++ b/build.gradle @@ -73,20 +73,25 @@ tasks.named('test') { useJUnitPlatform() } -// Querydsl 설정부 -def generated = 'src/main/generated' - -// querydsl QClass 파일 생성 위치를 지정 -tasks.withType(JavaCompile) { - options.getGeneratedSourceOutputDirectory().set(file(generated)) +test { + useJUnitPlatform() } -// java source set 에 querydsl QClass 위치 추가 +def generatedDir = "src/main/generated" + + sourceSets { - main.java.srcDirs += [ generated ] + main { + java { + srcDirs = ['src/main/java'] + } + // Mybatis 쿼리 xml 위치때문에 조정 + resources{ + srcDir "${project.projectDir}/src/main/java" + } + } } -// gradle clean 시에 QClass 디렉토리 삭제 clean { - delete file(generated) + delete file(generatedDir) } \ No newline at end of file From 49161e6ce16f50acf4f869c144256d1f5b499c74 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 30 Jul 2024 02:15:04 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EA=B0=92=20=EB=B0=8F=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=EC=97=90=20userId=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/controller/FarmClubController.java | 7 ++++--- .../domain/farmclub/helper/MissionPostHelper.java | 5 +++++ .../domain/farmclub/service/MissionPostService.java | 4 ++-- 3 files changed, 11 insertions(+), 5 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 09ecb732..ec0dd416 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 @@ -111,11 +111,12 @@ public BaseResponseDto deleteMissionPostLike( return BaseResponseDto.of(SuccessCode.SUCCESS, null); } - @GetMapping("/{id}/mission") + @GetMapping("/{farmClubId}/mission") public BaseResponseDto getMissionPostList( - @PathVariable Long id + @AuthenticationPrincipal CustomUser user, + @PathVariable Long farmClubId ) { - return BaseResponseDto.of(SuccessCode.SUCCESS, missionPostService.getMissionPostList(id)); + return BaseResponseDto.of(SuccessCode.SUCCESS, missionPostService.getMissionPostList(user.getUserId(), farmClubId)); } @GetMapping("/mission/{id}") 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 820a0e8b..2ab5fbef 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 @@ -4,6 +4,7 @@ import com.modernfarmer.farmusspring.domain.farmclub.exception.FarmClubErrorCode; import com.modernfarmer.farmusspring.domain.farmclub.exception.custom.FarmClubEntityNotFoundException; import com.modernfarmer.farmusspring.domain.farmclub.repository.MissionPostRepository; +import com.modernfarmer.farmusspring.domain.farmclub.vo.MissionPostVo; import com.modernfarmer.farmusspring.domain.history.vo.MissionPostHistoryVo; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -26,6 +27,10 @@ public List getMissionPostHistory(Long userFarmClubId) { return missionPostRepository.getMissionPostHistory(userFarmClubId); } + public List getMissionPostList(Long userId, Long missionPostId) { + return missionPostRepository.getMissionPostList(userId, missionPostId); + } + @Transactional public void deleteMissionPostLike(Long userId, Long missionPostId) { missionPostRepository.deleteMissionPostLike(userId, 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 334dd729..1f1e5495 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 @@ -68,8 +68,8 @@ public void deleteMissionPostLike(Long userId, Long missionPostId) { missionPostHelper.deleteMissionPostLike(userId, missionPostId); } - public GetMissionPostListResponseDto getMissionPostList(Long farmClubId) { - List missionPosts = missionPostRepository.getMissionPostList(farmClubId); + public GetMissionPostListResponseDto getMissionPostList(Long userId, Long farmClubId) { + List missionPosts = missionPostHelper.getMissionPostList(userId, farmClubId); return GetMissionPostListResponseDto.of(missionPosts); } From 35ec8ae1f3b09bfd4c86dad4e386c35091cbe518 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 30 Jul 2024 02:15:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80(=EC=A2=8B?= =?UTF-8?q?=EC=95=84=EC=9A=94=20=EC=97=AC=EB=B6=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmusspring/domain/farmclub/vo/MissionPostVo.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostVo.java index d73d54e0..a4b54180 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostVo.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/MissionPostVo.java @@ -12,10 +12,11 @@ public record MissionPostVo( String image, String content, Long likeCount, - Long commentCount + Long commentCount, + Boolean isLiked ) { @QueryProjection - public MissionPostVo(MissionPost missionPost, User user, Long likeCount, Long commentCount) + public MissionPostVo(MissionPost missionPost, User user, Long likeCount, Long commentCount, Boolean isLiked) { this( missionPost.getId(), @@ -25,7 +26,8 @@ public MissionPostVo(MissionPost missionPost, User user, Long likeCount, Long co missionPost.getImage(), missionPost.getContent(), likeCount, - commentCount + commentCount, + isLiked ); } } From d1a5ab5940a9537e3419939da36da6b7a6db8585 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Tue, 30 Jul 2024 02:15:41 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=BF=BC=EB=A6=AC=EC=88=98=EC=A0=95(=EC=A2=8B=EC=95=84?= =?UTF-8?q?=EC=9A=94=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/MissionPostRepositoryCustom.java | 2 +- .../farmclub/repository/MissionPostRepositoryImpl.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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 81c78143..eb923fe0 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 @@ -12,7 +12,7 @@ public interface MissionPostRepositoryCustom { List getMissionPostStepNumAndImage(Long farmClubId); List getMissionPostComment(Long missionPostId); - List getMissionPostList(Long missionPostId); + 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 d0eff5f9..473ab625 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 @@ -51,7 +51,7 @@ public List getMissionPostComment(Long missionPostId) { } @Override - public List getMissionPostList(Long farmClubId) { + public List getMissionPostList(Long userId, Long farmClubId) { return queryFactory .select(new QMissionPostVo( @@ -62,7 +62,13 @@ public List getMissionPostList(Long farmClubId) { .where(missionPostLike.missionPost.eq(missionPost)), JPAExpressions.select(missionPostComment.count()) .from(missionPostComment) - .where(missionPostComment.missionPost.eq(missionPost)))) + .where(missionPostComment.missionPost.eq(missionPost)), + JPAExpressions.selectOne() + .from(missionPostLike) + .where(missionPostLike.missionPost.eq(missionPost) + .and(missionPostLike.user.id.eq(userId))) + .exists() + )) .from(missionPost) .join(missionPost.userFarmClub, userFarmClub) .join(userFarmClub.myVeggie, myVeggie)