Skip to content

Commit

Permalink
refacor: NotificationDTO 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdtn0219 committed Jan 24, 2024
1 parent 6721dbf commit 81fe120
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
public record ChatNotificationDto(
Member sender,
Member receiver,
String accommodationName,
String chatRoomCode,
String senderNickname,
String image
String accommodationName
) {

public static ChatNotificationDto from(
Expand All @@ -30,15 +27,13 @@ public static ChatNotificationDto from(
.accommodationName(
chatRoom.getProduct().getOrder().getRoom().getAccommodation().getName()
)
.image(sender.getImage())
.build();
}

public String convertMapToJsonStr(ObjectMapper objectMapper) {
Map<String, String> contentMap = new HashMap<>();
contentMap.put("senderNickname", senderNickname);
contentMap.put("senderNickname", sender().getNickName());
contentMap.put("accommodationName", accommodationName);
contentMap.put("chatRoomCode", chatRoomCode);
try {
return objectMapper.writeValueAsString(contentMap);
} catch (JsonProcessingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void sendChatCreated(ChatNotificationDto chatDto, String content) {
.receiver(chatDto.receiver())
.notificationType(CHAT)
.content(chatDto.convertMapToJsonStr(objectMapper))
.image(chatDto.image())
.image(chatDto.sender().getImage())
.build();

notificationHistoryRepository.save(notificationHistory);
Expand Down

0 comments on commit 81fe120

Please sign in to comment.