Skip to content

Commit

Permalink
Merge pull request #207 from fourix4/dev
Browse files Browse the repository at this point in the history
refactor : 사용자에 따라 채팅방 목록 유저 변경
  • Loading branch information
TaeHoon0 authored Jul 28, 2024
2 parents 5afa5ac + 0ed4388 commit 312dae4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public List<ChatRoomResponseDto> 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;
Expand Down

0 comments on commit 312dae4

Please sign in to comment.