Skip to content

Commit

Permalink
Merge pull request #114 from Team-GAJI/feature/#97-community-post-sea…
Browse files Browse the repository at this point in the history
…rch/GAJI-124

🐛 [fix]#97 - 클래스 이름 변경에 의한 의존성 문제 해결
  • Loading branch information
strongmhk authored Aug 17, 2024
2 parents 9ff8ab9 + c239b08 commit 07f3368
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public CommnuityPost findByIdFetchJoinWithUser(Long postId) {

@Override
public Slice<Tuple> findAllPostsByUser(User user, LocalDateTime cursorDateTime, Pageable pageable, PostTypeEnum type) {
List<Tuple> 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<Tuple> 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();

Expand Down Expand Up @@ -125,7 +125,7 @@ private BooleanExpression searchKeyword(String keyword) {
: null;
}

private Slice<CommnuityPost> checkLastPage(Pageable pageable, List<CommnuityPost> postList) {
private <T> Slice<T> checkLastPage(Pageable pageable, List<T> postList) {
boolean hasNext = false;

// (조회한 결과 개수 > 요청한 페이지 사이즈) 이면 뒤에 데이터가 더 존재함
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/gaji/service/domain/user/converter/UserConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,17 +50,17 @@ public static UserResponseDTO.GetRoomListDTO toGetRoomListDTO(Slice<Tuple> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -75,7 +75,7 @@ public Slice<Tuple> getUserPostList(Long userId, LocalDateTime cursorDateTime, P

PageRequest pageRequest = PageRequest.of(0, size);

Slice<Tuple> postList = postJpaRepository.findAllPostsByUser(user, cursorDateTime, pageRequest, type);
Slice<Tuple> postList = communityPostJpaRepository.findAllPostsByUser(user, cursorDateTime, pageRequest, type);

return postList;
}
Expand Down

0 comments on commit 07f3368

Please sign in to comment.