diff --git a/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java b/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java index 3d400b04..d0675c8f 100644 --- a/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java +++ b/src/main/java/gaji/service/domain/post/repository/CommunityPostQueryDslRepositoryImpl.java @@ -76,12 +76,12 @@ public CommnuityPost findByIdFetchJoinWithUser(Long postId) { @Override public Slice findAllPostsByUser(User user, LocalDateTime cursorDateTime, Pageable pageable, PostTypeEnum type) { - List userPosts = jpaQueryFactory.select(post.id, post.user, post.title, post.body, post.type, post.status, post.hit, post.likeCnt, post.createdAt) - .from(post) - .where(post.user.eq(user), (postTypeEq(type)) - ,(post.createdAt.before(cursorDateTime)) + List userPosts = jpaQueryFactory.select(commnuityPost.id, commnuityPost.user, commnuityPost.title, commnuityPost.body, commnuityPost.type, commnuityPost.status, commnuityPost.hit, commnuityPost.likeCnt, commnuityPost.createdAt) + .from(commnuityPost) + .where(commnuityPost.user.eq(user), (postTypeEq(type)) + ,(commnuityPost.createdAt.before(cursorDateTime)) ) - .orderBy(post.createdAt.desc()) + .orderBy(commnuityPost.createdAt.desc()) .limit(pageable.getPageSize() + 1) .fetch(); @@ -125,7 +125,7 @@ private BooleanExpression searchKeyword(String keyword) { : null; } - private Slice checkLastPage(Pageable pageable, List postList) { + private Slice checkLastPage(Pageable pageable, List postList) { boolean hasNext = false; // (조회한 결과 개수 > 요청한 페이지 사이즈) 이면 뒤에 데이터가 더 존재함 diff --git a/src/main/java/gaji/service/domain/user/converter/UserConverter.java b/src/main/java/gaji/service/domain/user/converter/UserConverter.java index c081972c..ee76676c 100644 --- a/src/main/java/gaji/service/domain/user/converter/UserConverter.java +++ b/src/main/java/gaji/service/domain/user/converter/UserConverter.java @@ -2,7 +2,7 @@ import com.querydsl.core.Tuple; import gaji.service.domain.enums.PostTypeEnum; -import gaji.service.domain.post.entity.QPost; +import gaji.service.domain.post.entity.QCommnuityPost; import gaji.service.domain.room.entity.QRoom; import gaji.service.domain.user.entity.User; import gaji.service.domain.user.web.dto.UserResponseDTO; @@ -50,17 +50,17 @@ public static UserResponseDTO.GetRoomListDTO toGetRoomListDTO(Slice roomL public static UserResponseDTO.GetPostDTO toGetPostDTO(Tuple tuple) { return UserResponseDTO.GetPostDTO.builder() - .postId(tuple.get(QPost.post.id)) - .title(tuple.get(QPost.post.title)) - .body(tuple.get(QPost.post.body)) - .type(tuple.get(QPost.post.type)) - .status(tuple.get(QPost.post.status)) - .userId(tuple.get(QPost.post.user.id)) - .nickname(tuple.get(QPost.post.user.nickname)) - .profileImagePth(tuple.get(QPost.post.user.profileImagePth)) - .createdAt(DateConverter.convertToRelativeTimeFormat(tuple.get(QPost.post.createdAt))) - .viewCnt(tuple.get(QPost.post.hit)) - .likeCnt(tuple.get(QPost.post.likeCnt)) + .postId(tuple.get(QCommnuityPost.commnuityPost.id)) + .title(tuple.get(QCommnuityPost.commnuityPost.title)) + .body(tuple.get(QCommnuityPost.commnuityPost.body)) + .type(tuple.get(QCommnuityPost.commnuityPost.type)) + .status(tuple.get(QCommnuityPost.commnuityPost.status)) + .userId(tuple.get(QCommnuityPost.commnuityPost.user.id)) + .nickname(tuple.get(QCommnuityPost.commnuityPost.user.nickname)) + .profileImagePth(tuple.get(QCommnuityPost.commnuityPost.user.profileImagePth)) + .createdAt(DateConverter.convertToRelativeTimeFormat(tuple.get(QCommnuityPost.commnuityPost.createdAt))) + .viewCnt(tuple.get(QCommnuityPost.commnuityPost.hit)) + .likeCnt(tuple.get(QCommnuityPost.commnuityPost.likeCnt)) .build(); } diff --git a/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java b/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java index 76e27377..be8698df 100644 --- a/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java +++ b/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java @@ -3,7 +3,7 @@ import com.querydsl.core.Tuple; import gaji.service.domain.enums.PostTypeEnum; import gaji.service.domain.enums.RoomTypeEnum; -import gaji.service.domain.post.repository.PostJpaRepository; +import gaji.service.domain.post.repository.CommunityPostJpaRepository; import gaji.service.domain.room.repository.RoomCustomRepository; import gaji.service.domain.user.code.UserErrorStatus; import gaji.service.domain.user.entity.User; @@ -25,7 +25,7 @@ public class UserQueryServiceImpl implements UserQueryService { private final UserRepository userRepository; private final RoomCustomRepository roomCustomRepository; - private final PostJpaRepository postJpaRepository; + private final CommunityPostJpaRepository communityPostJpaRepository; @Override public boolean existUserById(Long userId) { @@ -75,7 +75,7 @@ public Slice getUserPostList(Long userId, LocalDateTime cursorDateTime, P PageRequest pageRequest = PageRequest.of(0, size); - Slice postList = postJpaRepository.findAllPostsByUser(user, cursorDateTime, pageRequest, type); + Slice postList = communityPostJpaRepository.findAllPostsByUser(user, cursorDateTime, pageRequest, type); return postList; }