diff --git a/src/main/java/com/example/CatchStudy/domain/dto/response/ChatRoomResponseDto.java b/src/main/java/com/example/CatchStudy/domain/dto/response/ChatRoomResponseDto.java index 2b8c030..be58f1d 100644 --- a/src/main/java/com/example/CatchStudy/domain/dto/response/ChatRoomResponseDto.java +++ b/src/main/java/com/example/CatchStudy/domain/dto/response/ChatRoomResponseDto.java @@ -2,6 +2,7 @@ import com.example.CatchStudy.domain.entity.ChatRoom; import com.example.CatchStudy.domain.entity.Message; +import com.example.CatchStudy.global.enums.Author; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.Getter; @@ -14,7 +15,7 @@ public class ChatRoomResponseDto { private long chatRoomId; private long cafeId; - private String cafeName; + private String name; private String lastChat; private LocalDateTime lastChatDate; private boolean status; @@ -23,12 +24,14 @@ public ChatRoomResponseDto(ChatRoom chatRoom) { this.chatRoomId = chatRoom.getChatRoomId(); } - public ChatRoomResponseDto(ChatRoom chatRoom, Message message, boolean status) { + public ChatRoomResponseDto(ChatRoom chatRoom, Message message, boolean status, Author author) { this.chatRoomId = chatRoom.getChatRoomId(); this.cafeId = chatRoom.getStudyCafe().getCafeId(); - this.cafeName = chatRoom.getStudyCafe().getCafeName(); this.lastChat = message.getChat(); this.lastChatDate = message.getCreateDate(); this.status = status; + + if(author == Author.roleManager) name = chatRoom.getUser().getUserName(); + else name = chatRoom.getStudyCafe().getCafeName(); } } diff --git a/src/main/java/com/example/CatchStudy/service/ChatService.java b/src/main/java/com/example/CatchStudy/service/ChatService.java index 0ca90df..04a6fa9 100644 --- a/src/main/java/com/example/CatchStudy/service/ChatService.java +++ b/src/main/java/com/example/CatchStudy/service/ChatService.java @@ -71,7 +71,7 @@ public List getChatRoomList() { .orElse(null); boolean status = chatNotification == null || chatNotification.isStatus(); // null 인 경우 알림 x 이므로 true - chatRoomResponseDtoList.add(new ChatRoomResponseDto(chatRoom, message, status)); + chatRoomResponseDtoList.add(new ChatRoomResponseDto(chatRoom, message, status, user.getAuthor())); } return chatRoomResponseDtoList;