From: Kai Moritz Date: Mon, 9 Jan 2023 22:10:38 +0000 (+0100) Subject: WIP X-Git-Tag: TEST~13 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=1da3aa3c5581fc27b2fdcdd968c9c8e5afe0307c;p=demos%2Fkafka%2Fchat WIP --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomDao.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomDao.java deleted file mode 100644 index b83966e5..00000000 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomDao.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.juplo.kafka.chat.backend.persistence.storage.mongodb; - -import de.juplo.kafka.chat.backend.domain.ChatRoom; -import lombok.*; - -import java.util.List; -import java.util.UUID; - - -@AllArgsConstructor -@NoArgsConstructor -@Getter(AccessLevel.PACKAGE) -@Setter(AccessLevel.PACKAGE) -@EqualsAndHashCode(of = { "id" }) -@ToString(of = { "id", "name" }) -public class ChatRoomDao -{ - private UUID id; - private String name; - private List messages; - - - public static ChatRoomDao from(ChatRoom chatroom) - { - return new ChatRoomDao( - chatroom.getId(), - chatroom.getName(), - chatroom - .getMessages() - .map(MessageDao::from) - .collectList() - .block()); - } -} diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomTo.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomTo.java new file mode 100644 index 00000000..da33a5bf --- /dev/null +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/ChatRoomTo.java @@ -0,0 +1,34 @@ +package de.juplo.kafka.chat.backend.persistence.storage.mongodb; + +import de.juplo.kafka.chat.backend.domain.ChatRoom; +import lombok.*; + +import java.util.List; +import java.util.UUID; + + +@AllArgsConstructor +@NoArgsConstructor +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) +@EqualsAndHashCode(of = { "id" }) +@ToString(of = { "id", "name" }) +public class ChatRoomTo +{ + private UUID id; + private String name; + private List messages; + + + public static ChatRoomTo from(ChatRoom chatroom) + { + return new ChatRoomTo( + chatroom.getId(), + chatroom.getName(), + chatroom + .getMessages() + .map(MessageTo::from) + .collectList() + .block()); + } +} diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageDao.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageDao.java deleted file mode 100644 index 472b21fa..00000000 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageDao.java +++ /dev/null @@ -1,38 +0,0 @@ -package de.juplo.kafka.chat.backend.persistence.storage.mongodb; - -import de.juplo.kafka.chat.backend.domain.Message; -import lombok.*; - -import java.time.LocalDateTime; - - -@AllArgsConstructor -@NoArgsConstructor -@Getter(AccessLevel.PACKAGE) -@Setter(AccessLevel.PACKAGE) -@EqualsAndHashCode(of = { "user", "id" }) -@ToString(of = { "user", "id" }) -class MessageDao -{ - private Long id; - private Long serial; - private LocalDateTime time; - private String user; - private String text; - - Message toMessage() - { - return new Message(Message.MessageKey.of(user, id), serial, time, text); - } - - static MessageDao from(Message message) - { - return - new MessageDao( - message.getId(), - message.getSerialNumber(), - message.getTimestamp(), - message.getUsername(), - message.getMessageText()); - } -} diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageTo.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageTo.java new file mode 100644 index 00000000..7af18457 --- /dev/null +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/storage/mongodb/MessageTo.java @@ -0,0 +1,38 @@ +package de.juplo.kafka.chat.backend.persistence.storage.mongodb; + +import de.juplo.kafka.chat.backend.domain.Message; +import lombok.*; + +import java.time.LocalDateTime; + + +@AllArgsConstructor +@NoArgsConstructor +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) +@EqualsAndHashCode(of = { "user", "id" }) +@ToString(of = { "user", "id" }) +class MessageTo +{ + private Long id; + private Long serial; + private LocalDateTime time; + private String user; + private String text; + + Message toMessage() + { + return new Message(Message.MessageKey.of(user, id), serial, time, text); + } + + static MessageTo from(Message message) + { + return + new MessageTo( + message.getId(), + message.getSerialNumber(), + message.getTimestamp(), + message.getUsername(), + message.getMessageText()); + } +}