Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#119] Fix: 페이징 content 빈값 문제 #120

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
import java.time.LocalDateTime;

public interface ChatRepository extends MongoRepository<Chat, String> { // MongoDB
Slice<Chat> findAllByRoomId(Long roomId, Pageable pageable);
Slice<Chat> findAllByRoomIdAndCreatedTimeLessThanEqual(Long roomId, LocalDateTime leaveTime, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ public interface UserRoomRepository extends JpaRepository<UserRoom, Long> {
Page<UserRoom> findAllByIsLeaveAndUser_Id(Integer isLeave, Long userId, Pageable pageable);
Page<UserRoom> findAllByIsLeaveAndIsPass(Integer isLeave, Integer isPass, Pageable pageable);
Page<UserRoom> findAllByIsLeaveAndRoom_Problem_Number(Integer isLeave, Integer number, Pageable pageable);
Page<UserRoom> findAllByIsLeaveAndRoom_Link(Integer isLeave, String link, Pageable pageable);
Page<UserRoom> findAllByRoom_Link(String link, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ public Slice<ChatResponseDto> findChatsByRoom(Long roomId, Pageable pageable) {
UserRoom userRoom = userRoomService.findUserRoom(SecurityUtil.getCurrentMemberId(), roomId);
LocalDateTime leaveTime = userRoom.getLeaveTime();

// 본인 퇴장시각 이하까지의 채팅 내역 조회
Slice<Chat> chatSlice = chatRepository.findAllByRoomIdAndCreatedTimeLessThanEqual(roomId, leaveTime, pageable);
// 퇴장한 경우, 본인 퇴장시각 이하까지의 채팅 내역 조회
Slice<Chat> chatSlice;
if(userRoom.getIsLeave() == 1) chatSlice = chatRepository.findAllByRoomIdAndCreatedTimeLessThanEqual(roomId, leaveTime, pageable);
else chatSlice = chatRepository.findAllByRoomId(roomId, pageable);

// 사용자 캐싱을 위한 맵 생성 (이미 검색한것은 다시 검색하지않도록 성능 향상)
Map<Long, User> cacheUserMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ else if(isPass == null && number != null && link == null) { // 문제번호 검
userRoomPage = userRoomRepository.findAllByIsLeaveAndRoom_Problem_Number(1, number, pageable);
}
else if(isPass == null && number == null && link != null) { // 초대링크 탐색 조회의 경우
userRoomPage = userRoomRepository.findAllByIsLeaveAndRoom_Link(1, link, pageable);
userRoomPage = userRoomRepository.findAllByRoom_Link(link, pageable);
}
else { // 잘못된 URI
throw new Exception400.UserRoomBadRequest("잘못된 쿼리파라미터로 API를 요청하였습니다.");
Expand Down
Loading