Skip to content

Commit

Permalink
Merge pull request #142 from sharemindteam/fix/141-connect-dto
Browse files Browse the repository at this point in the history
fix:새로운 채팅 생성시 dto 누락 문제 해결
  • Loading branch information
aeyongdodam authored Mar 11, 2024
2 parents e5a3f07 + 9ea4a5c commit 500d747
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.example.sharemind.admin.dto.response.PaymentGetSettlementOngoingResponse;
import com.example.sharemind.admin.dto.response.PostGetUnpaidPrivateResponse;
import com.example.sharemind.chat.application.ChatService;
import com.example.sharemind.chat.domain.Chat;
import com.example.sharemind.consult.application.ConsultService;
import com.example.sharemind.consult.domain.Consult;
import com.example.sharemind.consult.exception.ConsultErrorCode;
Expand Down Expand Up @@ -70,9 +69,7 @@ public void updateConsultIsPaid(Long consultId) {

consult.updateIsPaidAndLetter(letter);
}
case CHAT -> {
chatService.createChat(consult);
}
case CHAT -> chatService.createChat(consult);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ public class ChatNotifyEventResponse {
@Schema(description = "채팅 이벤트")
private final ChatRoomWebsocketStatus chatRoomWebsocketStatus;

@Schema(description = "채팅 스타일")
@Schema(description = "상담사 채팅 스타일")
private final String consultStyle;

@Schema(description = "상대방 닉네임")
private final String opponentNickname;

public static ChatNotifyEventResponse of(Long chatId, ChatRoomWebsocketStatus chatRoomWebsocketStatus) {
return new ChatNotifyEventResponse(chatId, LocalDateTime.now(), chatRoomWebsocketStatus, null);
return new ChatNotifyEventResponse(chatId, LocalDateTime.now(), chatRoomWebsocketStatus, null, null);
}

public static ChatNotifyEventResponse of(Chat chat, ChatRoomWebsocketStatus chatRoomWebsocketStatus) {
return new ChatNotifyEventResponse(chat.getChatId(), LocalDateTime.now(), chatRoomWebsocketStatus,
chat.getConsult().getCounselor().getConsultStyle().getDisplayName());
public static ChatNotifyEventResponse of(Chat chat, ChatRoomWebsocketStatus chatRoomWebsocketStatus, Boolean isCustomer) {
if (isCustomer)
return new ChatNotifyEventResponse(chat.getChatId(), LocalDateTime.now(), chatRoomWebsocketStatus,
chat.getConsult().getCounselor().getConsultStyle().getDisplayName(), chat.getConsult().getCounselor().getNickname());
else
return new ChatNotifyEventResponse(chat.getChatId(), LocalDateTime.now(), chatRoomWebsocketStatus,
chat.getConsult().getCounselor().getConsultStyle().getDisplayName(), chat.getConsult().getCustomer().getNickname());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public void handleChatNotifyEvent(ChatNotifyEvent chatNotifyEvent) {
Chat chat = chatService.getChatByChatId(chatNotifyEvent.getChatId());
messageSendingOperations.convertAndSend(
"/queue/chattings/notifications/customers/" + chatNotifyEvent.getCustomerId(),
ChatNotifyEventResponse.of(chat, ChatRoomWebsocketStatus.CHAT_ROOM_CREATE));
ChatNotifyEventResponse.of(chat, ChatRoomWebsocketStatus.CHAT_ROOM_CREATE, true));
messageSendingOperations.convertAndSend(
"/queue/chattings/notifications/counselors/" + chatNotifyEvent.getCounselorId(),
ChatNotifyEventResponse.of(chat, ChatRoomWebsocketStatus.CHAT_ROOM_CREATE));
ChatNotifyEventResponse.of(chat, ChatRoomWebsocketStatus.CHAT_ROOM_CREATE, false));
}

@EventListener
Expand Down

0 comments on commit 500d747

Please sign in to comment.