From 9192b7cd97322a4da402af38f485a8bc945f7516 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Fri, 15 Jul 2022 17:47:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=85=D0=BE=D0=B4=20=D0=BA=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BD=D0=B8=D0=BA=D0=B0=D1=8E=D1=89=D0=B8=D0=BC=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D1=8F=D0=BC=20=D0=B8=20=D0=B8?= =?UTF-8?q?=D1=85=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot-context/pom.xml | 2 +- .../context/domain/content/EmptyMessage.java | 2 +- .../godfather/context/domain/content/Mail.java | 12 ++++++++++-- .../context/domain/content/Message.java | 16 ++++++++-------- .../godfather/context/domain/event/Event.java | 7 +++++++ .../godfather/context/service/EventProvider.java | 8 +++++--- bot-core/pom.xml | 2 +- .../service/provider/EventStoryLineProvider.java | 5 +++++ pom.xml | 4 ++-- 9 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 bot-context/src/main/java/dev/struchkov/godfather/context/domain/event/Event.java diff --git a/bot-context/pom.xml b/bot-context/pom.xml index ca43f67..fa90386 100644 --- a/bot-context/pom.xml +++ b/bot-context/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.11 + 0.0.12 bot-context diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/EmptyMessage.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/EmptyMessage.java index d828343..15bb442 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/EmptyMessage.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/EmptyMessage.java @@ -10,7 +10,7 @@ import dev.struchkov.godfather.context.exception.AppBotException; public class EmptyMessage extends Message { public EmptyMessage() { - type = ContentType.EMPTY; + contentType = ContentType.EMPTY; } @Override diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Mail.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Mail.java index 66f9286..ead06ff 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Mail.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Mail.java @@ -1,6 +1,7 @@ package dev.struchkov.godfather.context.domain.content; import dev.struchkov.godfather.context.domain.content.attachment.Attachment; +import dev.struchkov.godfather.context.domain.event.Event; import javax.persistence.Column; import javax.persistence.Entity; @@ -18,7 +19,9 @@ import java.util.List; */ @Entity @Table(name = "mail") -public class Mail extends Message { +public class Mail extends Message implements Event { + + public static final String TYPE = "MAIL"; /** * Имя отправителя. @@ -47,7 +50,7 @@ public class Mail extends Message { private List forwardMail; public Mail() { - type = ContentType.MAIL; + contentType = ContentType.MAIL; } public String getFirstName() { @@ -86,4 +89,9 @@ public class Mail extends Message { this.forwardMail = forwardMail; } + @Override + public String getType() { + return TYPE; + } + } diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java index 2c6487f..011efe6 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/content/Message.java @@ -23,7 +23,7 @@ public abstract class Message extends BasicEntity { */ @Column(name = "type") @Enumerated(value = EnumType.STRING) - protected ContentType type; + protected ContentType contentType; /** * Дата создания. @@ -56,18 +56,18 @@ public abstract class Message extends BasicEntity { this.text = source.getText(); this.createDate = source.getCreateDate(); this.id = source.getPersonId(); - this.type = source.getType(); + this.contentType = source.getContentType(); } public Message() { } - public ContentType getType() { - return type; + public ContentType getContentType() { + return contentType; } - public void setType(ContentType type) { - this.type = type; + public void setContentType(ContentType type) { + this.contentType = type; } public LocalDateTime getCreateDate() { @@ -107,12 +107,12 @@ public abstract class Message extends BasicEntity { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Message message = (Message) o; - return type == message.type && Objects.equals(createDate, message.createDate) && Objects.equals(addDate, message.addDate) && Objects.equals(personId, message.personId) && Objects.equals(text, message.text); + return contentType == message.contentType && Objects.equals(createDate, message.createDate) && Objects.equals(addDate, message.addDate) && Objects.equals(personId, message.personId) && Objects.equals(text, message.text); } @Override public int hashCode() { - return Objects.hash(type, createDate, addDate, personId, text); + return Objects.hash(contentType, createDate, addDate, personId, text); } } diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/domain/event/Event.java b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/event/Event.java new file mode 100644 index 0000000..4d6bcdb --- /dev/null +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/domain/event/Event.java @@ -0,0 +1,7 @@ +package dev.struchkov.godfather.context.domain.event; + +public interface Event { + + String getType(); + +} diff --git a/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventProvider.java b/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventProvider.java index 26b8a6d..2bdfc8e 100644 --- a/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventProvider.java +++ b/bot-context/src/main/java/dev/struchkov/godfather/context/service/EventProvider.java @@ -1,9 +1,11 @@ package dev.struchkov.godfather.context.service; -import dev.struchkov.godfather.context.domain.content.Message; +import dev.struchkov.godfather.context.domain.event.Event; -public interface EventProvider { +public interface EventProvider { - void sendEvent(M message); + void sendEvent(T event); + + String getEventType(); } diff --git a/bot-core/pom.xml b/bot-core/pom.xml index 6cb70bb..32a4d90 100644 --- a/bot-core/pom.xml +++ b/bot-core/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.11 + 0.0.12 bot-core diff --git a/bot-core/src/main/java/dev/struchkov/godfather/core/service/provider/EventStoryLineProvider.java b/bot-core/src/main/java/dev/struchkov/godfather/core/service/provider/EventStoryLineProvider.java index f2a48ac..78af56f 100644 --- a/bot-core/src/main/java/dev/struchkov/godfather/core/service/provider/EventStoryLineProvider.java +++ b/bot-core/src/main/java/dev/struchkov/godfather/core/service/provider/EventStoryLineProvider.java @@ -17,4 +17,9 @@ public class EventStoryLineProvider implements EventProvider { generalAutoResponder.processingNewMessage(message); } + @Override + public String getEventType() { + return Mail.TYPE; + } + } diff --git a/pom.xml b/pom.xml index ebf976c..87be887 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.struchkov.godfather godfather-bot - 0.0.11 + 0.0.12 pom @@ -32,7 +32,7 @@ UTF-8 UTF-8 - 0.0.11 + 0.0.12 ${godfather.ver} ${godfather.ver}