Изменил подход к возникающим событиям и их обработки
This commit is contained in:
parent
fc3f9563e2
commit
9192b7cd97
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
<artifactId>godfather-bot</artifactId>
|
<artifactId>godfather-bot</artifactId>
|
||||||
<version>0.0.11</version>
|
<version>0.0.12</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>bot-context</artifactId>
|
<artifactId>bot-context</artifactId>
|
||||||
|
@ -10,7 +10,7 @@ import dev.struchkov.godfather.context.exception.AppBotException;
|
|||||||
public class EmptyMessage extends Message {
|
public class EmptyMessage extends Message {
|
||||||
|
|
||||||
public EmptyMessage() {
|
public EmptyMessage() {
|
||||||
type = ContentType.EMPTY;
|
contentType = ContentType.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content;
|
package dev.struchkov.godfather.context.domain.content;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.content.attachment.Attachment;
|
import dev.struchkov.godfather.context.domain.content.attachment.Attachment;
|
||||||
|
import dev.struchkov.godfather.context.domain.event.Event;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@ -18,7 +19,9 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "mail")
|
@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<Mail> forwardMail;
|
private List<Mail> forwardMail;
|
||||||
|
|
||||||
public Mail() {
|
public Mail() {
|
||||||
type = ContentType.MAIL;
|
contentType = ContentType.MAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFirstName() {
|
public String getFirstName() {
|
||||||
@ -86,4 +89,9 @@ public class Mail extends Message {
|
|||||||
this.forwardMail = forwardMail;
|
this.forwardMail = forwardMail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public abstract class Message extends BasicEntity {
|
|||||||
*/
|
*/
|
||||||
@Column(name = "type")
|
@Column(name = "type")
|
||||||
@Enumerated(value = EnumType.STRING)
|
@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.text = source.getText();
|
||||||
this.createDate = source.getCreateDate();
|
this.createDate = source.getCreateDate();
|
||||||
this.id = source.getPersonId();
|
this.id = source.getPersonId();
|
||||||
this.type = source.getType();
|
this.contentType = source.getContentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message() {
|
public Message() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentType getType() {
|
public ContentType getContentType() {
|
||||||
return type;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(ContentType type) {
|
public void setContentType(ContentType type) {
|
||||||
this.type = type;
|
this.contentType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDateTime getCreateDate() {
|
public LocalDateTime getCreateDate() {
|
||||||
@ -107,12 +107,12 @@ public abstract class Message extends BasicEntity {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Message message = (Message) o;
|
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(type, createDate, addDate, personId, text);
|
return Objects.hash(contentType, createDate, addDate, personId, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.struchkov.godfather.context.domain.event;
|
||||||
|
|
||||||
|
public interface Event {
|
||||||
|
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package dev.struchkov.godfather.context.service;
|
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<M extends Message> {
|
public interface EventProvider<T extends Event> {
|
||||||
|
|
||||||
void sendEvent(M message);
|
void sendEvent(T event);
|
||||||
|
|
||||||
|
String getEventType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
<artifactId>godfather-bot</artifactId>
|
<artifactId>godfather-bot</artifactId>
|
||||||
<version>0.0.11</version>
|
<version>0.0.12</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>bot-core</artifactId>
|
<artifactId>bot-core</artifactId>
|
||||||
|
@ -17,4 +17,9 @@ public class EventStoryLineProvider implements EventProvider<Mail> {
|
|||||||
generalAutoResponder.processingNewMessage(message);
|
generalAutoResponder.processingNewMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return Mail.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
<artifactId>godfather-bot</artifactId>
|
<artifactId>godfather-bot</artifactId>
|
||||||
<version>0.0.11</version>
|
<version>0.0.12</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<godfather.ver>0.0.11</godfather.ver>
|
<godfather.ver>0.0.12</godfather.ver>
|
||||||
|
|
||||||
<godfather.context.ver>${godfather.ver}</godfather.context.ver>
|
<godfather.context.ver>${godfather.ver}</godfather.context.ver>
|
||||||
<godfather.core.ver>${godfather.ver}</godfather.core.ver>
|
<godfather.core.ver>${godfather.ver}</godfather.core.ver>
|
||||||
|
Loading…
Reference in New Issue
Block a user