Skip to content

Commit

Permalink
style : 코드 포맷팅
Browse files Browse the repository at this point in the history
  • Loading branch information
kkangh00n committed Apr 18, 2024
1 parent a15cc57 commit 603788d
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
import com.civilwar.boardsignal.user.domain.constants.Role;
import com.civilwar.boardsignal.user.domain.entity.User;
import com.civilwar.boardsignal.user.domain.repository.UserRepository;
import jakarta.validation.constraints.Null;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -285,7 +283,8 @@ void getMyChattingRoomTest2() throws Exception {
//1번방 채팅 추가 x
//2번방 채팅 추가
for (int i = 0; i < 3; i++) {
ChatMessage chatMessage = ChatMessage.of(room2.getId(), 100L, "테스트 " + i, MessageType.CHAT);
ChatMessage chatMessage = ChatMessage.of(room2.getId(), 100L, "테스트 " + i,
MessageType.CHAT);
chatMessageRepository.save(chatMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ List<ChatCountDto> countsByRoomIds(@Param("userId") Long userId,
@Param("roomIds") List<Long> roomIds);

//채팅방 별 마지막 메시지 조회
@Query("select new com.civilwar.boardsignal.chat.dto.response.LastChatMessageDto(c.roomId, c.content) "
@Query(
"select new com.civilwar.boardsignal.chat.dto.response.LastChatMessageDto(c.roomId, c.content) "
+ "from ChatMessage as c "
+ "where c.roomId in :roomIds "
+ "and c.createdAt in (select max(c.createdAt) from ChatMessage as c group by c.roomId) ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public RoomPageResponse<ChatRoomResponse> findMyChattingRoom(
roomIdList);

//매핑
Slice<ChatRoomResponse> myChattingRoomResult = myChattingRoom.map(room -> RoomMapper.toChatRoomResponse(room, unreadChatCounts, lastChatMessages));
Slice<ChatRoomResponse> myChattingRoomResult = myChattingRoom.map(
room -> RoomMapper.toChatRoomResponse(room, unreadChatCounts, lastChatMessages));

return RoomMapper.toRoomPageResponse(myChattingRoomResult);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,6 @@ public static ChatRoomResponse toChatRoomResponse(
room.headCount(),
Integer.parseInt(String.valueOf(unreadChatCount)),
lastChatMessage
);
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public Optional<Room> findById(Long id) {
}

@Override
public Slice<ChatRoomDto> findMyChattingRoom(Long userId, LocalDateTime today, Pageable pageable) {
public Slice<ChatRoomDto> findMyChattingRoom(Long userId, LocalDateTime today,
Pageable pageable) {
return roomJpaRepository.findMyChattingRoom(userId, today, pageable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ public interface RoomJpaRepository extends JpaRepository<Room, Long> {

// 내가 현재 참여한 채팅방 조회
// 미확정 모임 또는 모임 시간이 (오늘~미래)인 모임
@Query("select new com.civilwar.boardsignal.room.dto.response.ChatRoomDto(r.id, r.title, r.imageUrl, r.headCount)"
+ "from Room as r "
+ "left join MeetingInfo as m "
+ "on m.id = r.meetingInfo.id "
+ "join Participant as p "
+ "on r.id = p.roomId "
+ "where p.userId=:userId "
+ "and (m.meetingTime>=:today or m.meetingTime is null) "
+ "order by p.createdAt desc")
@Query(
"select new com.civilwar.boardsignal.room.dto.response.ChatRoomDto(r.id, r.title, r.imageUrl, r.headCount)"
+ "from Room as r "
+ "left join MeetingInfo as m "
+ "on m.id = r.meetingInfo.id "
+ "join Participant as p "
+ "on r.id = p.roomId "
+ "where p.userId=:userId "
+ "and (m.meetingTime>=:today or m.meetingTime is null) "
+ "order by p.createdAt desc")
Slice<ChatRoomDto> findMyChattingRoom(@Param("userId") Long userId,
@Param("today") LocalDateTime today, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.civilwar.boardsignal.chat.infrastructure.repository;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.*;
import static org.mockito.BDDMockito.given;

import com.civilwar.boardsignal.chat.domain.constant.MessageType;
import com.civilwar.boardsignal.chat.domain.entity.ChatMessage;
Expand All @@ -26,7 +26,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.BDDMockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -193,7 +192,8 @@ void findLastChatMessageTest() throws IOException {
chatMessageRepository.save(chatMessage);
}

List<LastChatMessageDto> lastChatMessages = chatMessageRepository.findLastChatMessage(List.of(room2.getId(),
List<LastChatMessageDto> lastChatMessages = chatMessageRepository.findLastChatMessage(
List.of(room2.getId(),
room3.getId()));

assertThat(lastChatMessages).hasSize(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ void findMyChattingRoomTest() throws IOException {
LocalDateTime today = LocalDateTime.of(2024, 4, 11, 0, 0, 0);
PageRequest pageable = PageRequest.of(0, 5);

Slice<ChatRoomDto> myChattingRoom = roomRepository.findMyChattingRoom(user, today, pageable);
Slice<ChatRoomDto> myChattingRoom = roomRepository.findMyChattingRoom(user, today,
pageable);
List<ChatRoomDto> content = myChattingRoom.getContent();

//then
Expand Down

0 comments on commit 603788d

Please sign in to comment.