From 607109917ea4f6f93e9e5b970bf53d027ee8e385 Mon Sep 17 00:00:00 2001 From: YoungJun Park Date: Sun, 17 Jul 2022 23:26:00 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20=EC=B1=84=ED=8C=85=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=83=9D=EC=84=B1=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5(out=20port=20=EC=98=81=EC=86=8D=EC=84=B1)(#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/port/out/FindChatPort.java | 10 +++++++ .../application/port/out/SaveChatPort.java | 8 +++++ .../core/domain/{Message.java => Chat.java} | 2 +- .../core/domain/jpa/ChatJpaEntity.java | 30 +++++++++++++++++++ .../core/repository/ChatRepository.java | 10 +++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 api/src/main/java/hexagonal/api/chat/application/port/out/FindChatPort.java create mode 100644 api/src/main/java/hexagonal/api/chat/application/port/out/SaveChatPort.java rename core/src/main/java/hexagonal/core/domain/{Message.java => Chat.java} (91%) create mode 100644 core/src/main/java/hexagonal/core/domain/jpa/ChatJpaEntity.java create mode 100644 core/src/main/java/hexagonal/core/repository/ChatRepository.java diff --git a/api/src/main/java/hexagonal/api/chat/application/port/out/FindChatPort.java b/api/src/main/java/hexagonal/api/chat/application/port/out/FindChatPort.java new file mode 100644 index 0000000..61d517b --- /dev/null +++ b/api/src/main/java/hexagonal/api/chat/application/port/out/FindChatPort.java @@ -0,0 +1,10 @@ +package hexagonal.api.chat.application.port.out; + +import hexagonal.core.domain.jpa.ChatJpaEntity; + +import java.util.List; + +public interface FindChatPort { + List findChatByRoom(Long roomId); + +} diff --git a/api/src/main/java/hexagonal/api/chat/application/port/out/SaveChatPort.java b/api/src/main/java/hexagonal/api/chat/application/port/out/SaveChatPort.java new file mode 100644 index 0000000..c8f6316 --- /dev/null +++ b/api/src/main/java/hexagonal/api/chat/application/port/out/SaveChatPort.java @@ -0,0 +1,8 @@ +package hexagonal.api.chat.application.port.out; + +import hexagonal.core.domain.jpa.ChatJpaEntity; + +public interface SaveChatPort { + Long saveChat(ChatJpaEntity entity); + +} diff --git a/core/src/main/java/hexagonal/core/domain/Message.java b/core/src/main/java/hexagonal/core/domain/Chat.java similarity index 91% rename from core/src/main/java/hexagonal/core/domain/Message.java rename to core/src/main/java/hexagonal/core/domain/Chat.java index ece6c55..68abe23 100644 --- a/core/src/main/java/hexagonal/core/domain/Message.java +++ b/core/src/main/java/hexagonal/core/domain/Chat.java @@ -6,7 +6,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Message { +public class Chat { private Long id; private String content; diff --git a/core/src/main/java/hexagonal/core/domain/jpa/ChatJpaEntity.java b/core/src/main/java/hexagonal/core/domain/jpa/ChatJpaEntity.java new file mode 100644 index 0000000..33f6ebf --- /dev/null +++ b/core/src/main/java/hexagonal/core/domain/jpa/ChatJpaEntity.java @@ -0,0 +1,30 @@ +package hexagonal.core.domain.jpa; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.*; + +@Entity +@Table(name = "chat") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ChatJpaEntity { + + @Id + @GeneratedValue + private Long id; + + @Column + private String content; + + @Column + private Long senderId; + + @Column + private Long roomId; +} diff --git a/core/src/main/java/hexagonal/core/repository/ChatRepository.java b/core/src/main/java/hexagonal/core/repository/ChatRepository.java new file mode 100644 index 0000000..4f9c1ff --- /dev/null +++ b/core/src/main/java/hexagonal/core/repository/ChatRepository.java @@ -0,0 +1,10 @@ +package hexagonal.core.repository; + +import hexagonal.core.domain.jpa.ChatJpaEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ChatRepository extends JpaRepository { + +}