Большой рефакторинг
This commit is contained in:
parent
4d5f3ad542
commit
08256dadc3
@ -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.4-SNAPSHOT</version>
|
<version>0.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>bot-context</artifactId>
|
<artifactId>bot-context</artifactId>
|
||||||
@ -14,18 +14,10 @@
|
|||||||
<name>Bot Context</name>
|
<name>Bot Context</name>
|
||||||
<description>Доменные сущности, интерфейсы, для библиотеки Godfather</description>
|
<description>Доменные сущности, интерфейсы, для библиотеки Godfather</description>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<skip.deploy>false</skip.deploy>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>dev.struchkov.haiti</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>haiti-utils</artifactId>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.mail</groupId>
|
|
||||||
<artifactId>javax.mail-api</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -41,6 +33,10 @@
|
|||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -1,9 +1,5 @@
|
|||||||
package dev.struchkov.godfather.context.domain;
|
package dev.struchkov.godfather.context.domain;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
@ -13,9 +9,6 @@ import javax.persistence.MappedSuperclass;
|
|||||||
*
|
*
|
||||||
* @author upagge [28/07/2019]
|
* @author upagge [28/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public class BasicEntity {
|
public class BasicEntity {
|
||||||
|
|
||||||
@ -23,4 +16,12 @@ public class BasicEntity {
|
|||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
protected Long id;
|
protected Long id;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,27 +3,17 @@ package dev.struchkov.godfather.context.domain;
|
|||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoard;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoard;
|
||||||
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
|
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Контейнер, которые содержит данные, которые будут отправлены пользователю как ответ на его запрос.
|
* Контейнер, которые содержит данные, которые будут отправлены пользователю как ответ на его запрос.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@Builder(toBuilder = true)
|
|
||||||
public class BoxAnswer {
|
public class BoxAnswer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Обычное текстовое сообщение.
|
* Обычное текстовое сообщение.
|
||||||
*/
|
*/
|
||||||
@Setter
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,12 +23,75 @@ public class BoxAnswer {
|
|||||||
|
|
||||||
private boolean replace;
|
private boolean replace;
|
||||||
|
|
||||||
|
private BoxAnswer(Builder builder) {
|
||||||
|
setMessage(builder.message);
|
||||||
|
keyBoard = builder.keyBoard;
|
||||||
|
replace = builder.replace;
|
||||||
|
}
|
||||||
|
|
||||||
public static BoxAnswer of(String message) {
|
public static BoxAnswer of(String message) {
|
||||||
return BoxAnswer.builder().message(message).build();
|
return BoxAnswer.builder().message(message).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Message> ProcessingData<T> processing(String messageText) {
|
public static <T extends Message> ProcessingData<T> processing(String messageText) {
|
||||||
return message -> builder().message(messageText).build();
|
return message -> of(messageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyBoard getKeyBoard() {
|
||||||
|
return keyBoard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReplace() {
|
||||||
|
return replace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BoxAnswer{" +
|
||||||
|
"message='" + message + '\'' +
|
||||||
|
", keyBoard=" + keyBoard +
|
||||||
|
", replace=" + replace +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private String message;
|
||||||
|
private KeyBoard keyBoard;
|
||||||
|
private boolean replace;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder message(String val) {
|
||||||
|
message = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder keyBoard(KeyBoard val) {
|
||||||
|
keyBoard = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder replace(boolean val) {
|
||||||
|
replace = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoxAnswer build() {
|
||||||
|
return new BoxAnswer(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Сообщение от пользователя типа "Комментарий к обсуждению группы".
|
|
||||||
*
|
|
||||||
* @author upagge [08/07/2019]
|
|
||||||
*/
|
|
||||||
public class BoardComment extends Comment {
|
|
||||||
|
|
||||||
public BoardComment() {
|
|
||||||
type = ContentType.BOARD_COMMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Абстрактная сущность для сообщений от пользователей с привязкой к какому-то контенту (картинка, видео).
|
|
||||||
*
|
|
||||||
* @author upagge [08/07/2019]
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public abstract class Comment extends Message {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Идентификатор контента, к которому ставлено сообщение.
|
|
||||||
*/
|
|
||||||
private Long contentId;
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +1,12 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content;
|
package dev.struchkov.godfather.context.domain.content;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.exception.AppBotException;
|
import dev.struchkov.godfather.context.exception.AppBotException;
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Заглушка для сообщения от пользователя.
|
* Заглушка для сообщения от пользователя.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@ToString
|
|
||||||
public class EmptyMessage extends Message {
|
public class EmptyMessage extends Message {
|
||||||
|
|
||||||
public EmptyMessage() {
|
public EmptyMessage() {
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
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 lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@ -19,11 +15,7 @@ import java.util.List;
|
|||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Table(name = "mail")
|
@Table(name = "mail")
|
||||||
@ToString(callSuper = true)
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class Mail extends Message {
|
public class Mail extends Message {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,4 +48,36 @@ public class Mail extends Message {
|
|||||||
type = ContentType.MAIL;
|
type = ContentType.MAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Attachment> getAttachments() {
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttachments(List<Attachment> attachments) {
|
||||||
|
this.attachments = attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Mail> getForwardMail() {
|
||||||
|
return forwardMail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForwardMail(List<Mail> forwardMail) {
|
||||||
|
this.forwardMail = forwardMail;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content;
|
package dev.struchkov.godfather.context.domain.content;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.BasicEntity;
|
import dev.struchkov.godfather.context.domain.BasicEntity;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
@ -12,18 +8,14 @@ import javax.persistence.Enumerated;
|
|||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Абстрактная сущность - Сообщение от пользователя.
|
* Абстрактная сущность - Сообщение от пользователя.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public abstract class Message extends BasicEntity {
|
public abstract class Message extends BasicEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,4 +59,60 @@ public abstract class Message extends BasicEntity {
|
|||||||
this.type = source.getType();
|
this.type = source.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Message() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContentType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(ContentType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getCreateDate() {
|
||||||
|
return createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateDate(LocalDateTime createDate) {
|
||||||
|
this.createDate = createDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getAddDate() {
|
||||||
|
return addDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddDate(LocalDateTime addDate) {
|
||||||
|
this.addDate = addDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPersonId() {
|
||||||
|
return personId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonId(Long personId) {
|
||||||
|
this.personId = personId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(type, createDate, addDate, personId, text);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content.attachment;
|
package dev.struchkov.godfather.context.domain.content.attachment;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import dev.struchkov.godfather.context.domain.BasicEntity;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Абстрактная сущность, для всех вложений к сообщениям от пользователей.
|
* Абстрактная сущность, для всех вложений к сообщениям от пользователей.
|
||||||
@ -15,12 +13,7 @@ import javax.persistence.Id;
|
|||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@EqualsAndHashCode
|
public abstract class Attachment extends BasicEntity {
|
||||||
public abstract class Attachment {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Тип сущности.
|
* Тип сущности.
|
||||||
|
@ -1,22 +1,12 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content.attachment;
|
package dev.struchkov.godfather.context.domain.content.attachment;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Вложение типа "Аудиосообщение".
|
* Вложение типа "Аудиосообщение".
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString
|
|
||||||
@Setter
|
|
||||||
public class AudioMessage extends Attachment {
|
public class AudioMessage extends Attachment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,4 +18,8 @@ public class AudioMessage extends Attachment {
|
|||||||
type = AttachmentType.AUDIO_MESSAGE;
|
type = AttachmentType.AUDIO_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AudioMessage(URL linkOdd) {
|
||||||
|
this.linkOdd = linkOdd;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content.attachment;
|
package dev.struchkov.godfather.context.domain.content.attachment;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Вложение типа "Карта".
|
* Вложение типа "Карта".
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class Geo extends Attachment {
|
public class Geo extends Attachment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,9 +30,20 @@ public class Geo extends Attachment {
|
|||||||
return new Geo().new Builder();
|
return new Geo().new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GeoCoordinate getGeoCoordinate() {
|
||||||
|
return geoCoordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCountry() {
|
||||||
|
return country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
public class Builder {
|
public class Builder {
|
||||||
private Builder() {
|
private Builder() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder coordinate(Float lat, Float aLong) {
|
public Builder coordinate(Float lat, Float aLong) {
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content.attachment;
|
package dev.struchkov.godfather.context.domain.content.attachment;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сущность для хранения географических координат.
|
* Сущность для хранения географических координат.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class GeoCoordinate {
|
public class GeoCoordinate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,4 +17,25 @@ public class GeoCoordinate {
|
|||||||
*/
|
*/
|
||||||
private Float longitude;
|
private Float longitude;
|
||||||
|
|
||||||
|
public GeoCoordinate(Float latitude, Float longitude) {
|
||||||
|
this.latitude = latitude;
|
||||||
|
this.longitude = longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getLatitude() {
|
||||||
|
return latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitude(Float latitude) {
|
||||||
|
this.latitude = latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getLongitude() {
|
||||||
|
return longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitude(Float longitude) {
|
||||||
|
this.longitude = longitude;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,5 @@
|
|||||||
package dev.struchkov.godfather.context.domain.content.attachment;
|
package dev.struchkov.godfather.context.domain.content.attachment;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class Link extends Attachment {
|
public class Link extends Attachment {
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
@ -17,4 +8,12 @@ public class Link extends Attachment {
|
|||||||
this.type = AttachmentType.LINK;
|
this.type = AttachmentType.LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
package dev.struchkov.godfather.context.domain.keyboard.button;
|
package dev.struchkov.godfather.context.domain.keyboard.button;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
||||||
import lombok.Builder;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
import java.util.Objects;
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Абстрактная сущность кнопки для клавиатуры.
|
* Абстрактная сущность кнопки для клавиатуры.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class SimpleButton implements KeyBoardButton {
|
public class SimpleButton implements KeyBoardButton {
|
||||||
|
|
||||||
public static final String TYPE = "SIMPLE";
|
public static final String TYPE = "SIMPLE";
|
||||||
@ -28,20 +23,40 @@ public class SimpleButton implements KeyBoardButton {
|
|||||||
*/
|
*/
|
||||||
protected String callbackData;
|
protected String callbackData;
|
||||||
|
|
||||||
@Builder(builderMethodName = "simpleBuilder", buildMethodName = "simpleBuild")
|
|
||||||
protected SimpleButton(String label, String callbackData) {
|
protected SimpleButton(String label, String callbackData) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.callbackData = callbackData;
|
this.callbackData = callbackData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleButton of(@NonNull String label, @NonNull String callbackData) {
|
public static SimpleButton of(@NotNull String label, @NotNull String callbackData) {
|
||||||
return new SimpleButton(label, callbackData);
|
return new SimpleButton(label, callbackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleButton of(@NonNull String label) {
|
public static SimpleButton of(@NotNull String label) {
|
||||||
return new SimpleButton(label, label);
|
return new SimpleButton(label, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCallbackData() {
|
||||||
|
return callbackData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
SimpleButton that = (SimpleButton) o;
|
||||||
|
return Objects.equals(label, that.label) && Objects.equals(callbackData, that.callbackData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(label, callbackData);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
|
@ -3,11 +3,6 @@ package dev.struchkov.godfather.context.domain.keyboard.simple;
|
|||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoard;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoard;
|
||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardLine;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardLine;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,9 +12,6 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class SimpleKeyBoard implements KeyBoard {
|
public class SimpleKeyBoard implements KeyBoard {
|
||||||
|
|
||||||
public static final String TYPE = "SIMPLE";
|
public static final String TYPE = "SIMPLE";
|
||||||
@ -29,15 +21,22 @@ public class SimpleKeyBoard implements KeyBoard {
|
|||||||
*/
|
*/
|
||||||
protected List<KeyBoardLine> lines = new ArrayList<>();
|
protected List<KeyBoardLine> lines = new ArrayList<>();
|
||||||
|
|
||||||
@Builder(builderMethodName = "simpleBuilder", buildMethodName = "simpleBuild")
|
public SimpleKeyBoard(List<KeyBoardLine> lines) {
|
||||||
public SimpleKeyBoard(@Singular("line") List<KeyBoardLine> lines) {
|
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SimpleKeyBoard(Builder builder) {
|
||||||
|
lines = builder.lines;
|
||||||
|
}
|
||||||
|
|
||||||
public static SimpleKeyBoard single(KeyBoardLine line) {
|
public static SimpleKeyBoard single(KeyBoardLine line) {
|
||||||
return new SimpleKeyBoard(List.of(line));
|
return new SimpleKeyBoard(List.of(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Builder build() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleKeyBoard single(KeyBoardButton keyBoardButton) {
|
public SimpleKeyBoard single(KeyBoardButton keyBoardButton) {
|
||||||
return single(SimpleKeyBoardLine.single(keyBoardButton));
|
return single(SimpleKeyBoardLine.single(keyBoardButton));
|
||||||
}
|
}
|
||||||
@ -47,4 +46,29 @@ public class SimpleKeyBoard implements KeyBoard {
|
|||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<KeyBoardLine> getLines() {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private List<KeyBoardLine> lines = new ArrayList<>();
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder lines(List<KeyBoardLine> val) {
|
||||||
|
lines = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder line(KeyBoardLine val) {
|
||||||
|
lines.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleKeyBoard build() {
|
||||||
|
return new SimpleKeyBoard(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,6 @@ package dev.struchkov.godfather.context.domain.keyboard.simple;
|
|||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardButton;
|
||||||
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardLine;
|
import dev.struchkov.godfather.context.domain.keyboard.KeyBoardLine;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Singular;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -15,8 +11,6 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode
|
|
||||||
public class SimpleKeyBoardLine implements KeyBoardLine {
|
public class SimpleKeyBoardLine implements KeyBoardLine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,18 +18,45 @@ public class SimpleKeyBoardLine implements KeyBoardLine {
|
|||||||
*/
|
*/
|
||||||
protected List<KeyBoardButton> buttons = new ArrayList<>();
|
protected List<KeyBoardButton> buttons = new ArrayList<>();
|
||||||
|
|
||||||
@Builder(builderMethodName = "simpleBuilder", buildMethodName = "simpleBuild")
|
public SimpleKeyBoardLine(List<KeyBoardButton> buttons) {
|
||||||
public SimpleKeyBoardLine(@Singular(value = "button") List<KeyBoardButton> buttons) {
|
|
||||||
this.buttons = buttons;
|
this.buttons = buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SimpleKeyBoardLine(Builder builder) {
|
||||||
|
buttons = builder.buttons;
|
||||||
|
}
|
||||||
|
|
||||||
public static SimpleKeyBoardLine single(KeyBoardButton keyBoardButton) {
|
public static SimpleKeyBoardLine single(KeyBoardButton keyBoardButton) {
|
||||||
return new SimpleKeyBoardLine(List.of(keyBoardButton));
|
return new SimpleKeyBoardLine(List.of(keyBoardButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<KeyBoardButton> getButtons() {
|
public List<KeyBoardButton> getButtons() {
|
||||||
return buttons;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private List<KeyBoardButton> buttons = new ArrayList<>();
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder buttons(List<KeyBoardButton> val) {
|
||||||
|
buttons = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder button(KeyBoardButton val) {
|
||||||
|
buttons.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleKeyBoardLine build() {
|
||||||
|
return new SimpleKeyBoardLine(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package dev.struchkov.godfather.context.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ошибка, когда что-то не найдено.
|
|
||||||
*
|
|
||||||
* @author upagge [08/07/2019]
|
|
||||||
*/
|
|
||||||
public class NotFoundException extends AppBotException {
|
|
||||||
|
|
||||||
public NotFoundException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.struchkov.godfather.context.exception;
|
||||||
|
|
||||||
|
import dev.struchkov.haiti.context.exception.NotFoundException;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Иключения связанные с настройками юнитов.
|
||||||
|
*
|
||||||
|
* @author upagge 28.04.2022
|
||||||
|
*/
|
||||||
|
public class UnitConfigException extends AppBotException{
|
||||||
|
|
||||||
|
public UnitConfigException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Supplier<NotFoundException> unitConfigException(String message, Object... objects) {
|
||||||
|
return () -> new NotFoundException(MessageFormat.format(message, objects));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package dev.struchkov.godfather.context.repository;
|
package dev.struchkov.godfather.context.repository;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,7 +19,7 @@ public interface ContentRepository<T extends Message> {
|
|||||||
* @param content Объект сообщени
|
* @param content Объект сообщени
|
||||||
* @return Идентификатор сообщения в хранилище
|
* @return Идентификатор сообщения в хранилище
|
||||||
*/
|
*/
|
||||||
T add(@NonNull T content);
|
T add(@NotNull T content);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить все сообщения за определенный временной диапазон
|
* Получить все сообщения за определенный временной диапазон
|
||||||
@ -28,9 +28,9 @@ public interface ContentRepository<T extends Message> {
|
|||||||
* @param dateTo Конец диапазона
|
* @param dateTo Конец диапазона
|
||||||
* @return Список сообщений
|
* @return Список сообщений
|
||||||
*/
|
*/
|
||||||
List<T> betweenByCreateDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
List<T> betweenByCreateDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
List<T> betweenByAddDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
List<T> betweenByAddDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Удаляет данные за указанный период
|
* Удаляет данные за указанный период
|
||||||
@ -38,10 +38,10 @@ public interface ContentRepository<T extends Message> {
|
|||||||
* @param dateFrom Дата начала
|
* @param dateFrom Дата начала
|
||||||
* @param dateTo Дата окончания
|
* @param dateTo Дата окончания
|
||||||
*/
|
*/
|
||||||
void deleteAllByAddDateBetween(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
void deleteAllByAddDateBetween(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
void deleteAllByAddDateBefore(@NonNull LocalDateTime date);
|
void deleteAllByAddDateBefore(@NotNull LocalDateTime date);
|
||||||
|
|
||||||
void deleteAllByAddDateAfter(@NonNull LocalDateTime date);
|
void deleteAllByAddDateAfter(@NotNull LocalDateTime date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package dev.struchkov.godfather.context.repository.impl.local;
|
package dev.struchkov.godfather.context.repository.impl.local;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.repository.ContentRepository;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import dev.struchkov.godfather.context.domain.content.Mail;
|
import dev.struchkov.godfather.context.domain.content.Mail;
|
||||||
|
import dev.struchkov.godfather.context.repository.ContentRepository;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -14,7 +13,6 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author upagge [27/07/2019]
|
* @author upagge [27/07/2019]
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class MailRepositoryList implements ContentRepository<Mail> {
|
public class MailRepositoryList implements ContentRepository<Mail> {
|
||||||
|
|
||||||
private final List<Mail> mails = new ArrayList<>();
|
private final List<Mail> mails = new ArrayList<>();
|
||||||
@ -28,7 +26,7 @@ public class MailRepositoryList implements ContentRepository<Mail> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Mail> betweenByCreateDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo) {
|
public List<Mail> betweenByCreateDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo) {
|
||||||
ArrayList<Mail> rezultMails = new ArrayList<>();
|
ArrayList<Mail> rezultMails = new ArrayList<>();
|
||||||
for (int i = mails.size() - 1; i >= 0; i--) {
|
for (int i = mails.size() - 1; i >= 0; i--) {
|
||||||
Mail mail = mails.get(i);
|
Mail mail = mails.get(i);
|
||||||
@ -42,7 +40,7 @@ public class MailRepositoryList implements ContentRepository<Mail> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Mail> betweenByAddDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo) {
|
public List<Mail> betweenByAddDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo) {
|
||||||
ArrayList<Mail> rezultMails = new ArrayList<>();
|
ArrayList<Mail> rezultMails = new ArrayList<>();
|
||||||
for (int i = mails.size() - 1; i >= 0; i--) {
|
for (int i = mails.size() - 1; i >= 0; i--) {
|
||||||
Mail mail = mails.get(i);
|
Mail mail = mails.get(i);
|
||||||
@ -57,21 +55,21 @@ public class MailRepositoryList implements ContentRepository<Mail> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllByAddDateBetween(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo) {
|
public void deleteAllByAddDateBetween(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo) {
|
||||||
mails.removeIf(mail -> dateFrom.isBefore(mail.getAddDate()) && dateTo.isAfter(mail.getAddDate()));
|
mails.removeIf(mail -> dateFrom.isBefore(mail.getAddDate()) && dateTo.isAfter(mail.getAddDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllByAddDateBefore(LocalDateTime date) {
|
public void deleteAllByAddDateBefore(@NotNull LocalDateTime date) {
|
||||||
mails.removeIf(mail -> date.isBefore(mail.getAddDate()));
|
mails.removeIf(mail -> date.isBefore(mail.getAddDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllByAddDateAfter(LocalDateTime date) {
|
public void deleteAllByAddDateAfter(@NotNull LocalDateTime date) {
|
||||||
mails.removeIf(mail -> date.isAfter(mail.getAddDate()));
|
mails.removeIf(mail -> date.isAfter(mail.getAddDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTimePeriod(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo, @NonNull LocalDateTime dateTime) {
|
private boolean isTimePeriod(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo, @NotNull LocalDateTime dateTime) {
|
||||||
return dateFrom.isBefore(dateTime) && dateTo.isAfter(dateTime);
|
return dateFrom.isBefore(dateTime) && dateTo.isAfter(dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.struchkov.godfather.context.service;
|
package dev.struchkov.godfather.context.service;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface MessageService<T extends Message> {
|
public interface MessageService<T extends Message> {
|
||||||
|
|
||||||
void add(@NonNull T event);
|
void add(@NotNull T event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить список сообщений за заданный временной интервал
|
* Получить список сообщений за заданный временной интервал
|
||||||
@ -22,7 +22,7 @@ public interface MessageService<T extends Message> {
|
|||||||
* @param dateTo Конец интервала
|
* @param dateTo Конец интервала
|
||||||
* @return Список сообщений
|
* @return Список сообщений
|
||||||
*/
|
*/
|
||||||
List<T> getByAddDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
List<T> getByAddDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить список ПОСЛЕДНИХ сообщений для каждого пользователя за заданных временной интервал
|
* Получить список ПОСЛЕДНИХ сообщений для каждого пользователя за заданных временной интервал
|
||||||
@ -31,19 +31,19 @@ public interface MessageService<T extends Message> {
|
|||||||
* @param dateTo Конец интервала
|
* @param dateTo Конец интервала
|
||||||
* @return Список сообщений
|
* @return Список сообщений
|
||||||
*/
|
*/
|
||||||
List<T> getLastEventByCreateDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
List<T> getLastEventByCreateDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
List<T> getLastEventByAddDateTime(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
List<T> getLastEventByAddDateTime(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает новые сообщения от последнего запроса.
|
* Возвращает новые сообщения от последнего запроса.
|
||||||
*/
|
*/
|
||||||
List<T> getNewMessage();
|
List<T> getNewMessage();
|
||||||
|
|
||||||
void deleteAllByAddDateBetween(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo);
|
void deleteAllByAddDateBetween(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo);
|
||||||
|
|
||||||
void deleteAllByAddDateBefore(@NonNull LocalDateTime date);
|
void deleteAllByAddDateBefore(@NotNull LocalDateTime date);
|
||||||
|
|
||||||
void deleteAllByAddDateAfter(@NonNull LocalDateTime date);
|
void deleteAllByAddDateAfter(@NotNull LocalDateTime date);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.struchkov.godfather.context.service;
|
package dev.struchkov.godfather.context.service;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Интерфес для изменения запроса пользователя перед тем, как он попадет в подсистему обработки.
|
* Интерфес для изменения запроса пользователя перед тем, как он попадет в подсистему обработки.
|
||||||
@ -12,6 +12,6 @@ import dev.struchkov.godfather.context.domain.content.Message;
|
|||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Modifiable<T extends Message> {
|
public interface Modifiable<T extends Message> {
|
||||||
|
|
||||||
void change(@NonNull T content);
|
void change(@NotNull T content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package dev.struchkov.godfather.context.service.impl;
|
|||||||
import dev.struchkov.godfather.context.domain.content.Mail;
|
import dev.struchkov.godfather.context.domain.content.Mail;
|
||||||
import dev.struchkov.godfather.context.repository.ContentRepository;
|
import dev.struchkov.godfather.context.repository.ContentRepository;
|
||||||
import dev.struchkov.godfather.context.service.MailService;
|
import dev.struchkov.godfather.context.service.MailService;
|
||||||
import lombok.NonNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import org.slf4j.Logger;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -16,14 +16,18 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class MailServiceImpl implements MailService {
|
public class MailServiceImpl implements MailService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MailServiceImpl.class);
|
||||||
|
|
||||||
private final ContentRepository<Mail> mailRepository;
|
private final ContentRepository<Mail> mailRepository;
|
||||||
private boolean newMessage = false;
|
private boolean newMessage = false;
|
||||||
private LocalDateTime oldDateTime = LocalDateTime.now(Clock.tickSeconds(ZoneId.systemDefault()));
|
private LocalDateTime oldDateTime = LocalDateTime.now(Clock.tickSeconds(ZoneId.systemDefault()));
|
||||||
|
|
||||||
|
public MailServiceImpl(ContentRepository<Mail> mailRepository) {
|
||||||
|
this.mailRepository = mailRepository;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO [13.04.2022]: Подобная реализация с newMessage вызовет проблемы с несколькими инстансами.
|
//TODO [13.04.2022]: Подобная реализация с newMessage вызовет проблемы с несколькими инстансами.
|
||||||
@Override
|
@Override
|
||||||
public void add(Mail mail) {
|
public void add(Mail mail) {
|
||||||
@ -73,17 +77,17 @@ public class MailServiceImpl implements MailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllByAddDateBetween(@NonNull LocalDateTime dateFrom, @NonNull LocalDateTime dateTo) {
|
public void deleteAllByAddDateBetween(@NotNull LocalDateTime dateFrom, @NotNull LocalDateTime dateTo) {
|
||||||
mailRepository.deleteAllByAddDateBetween(dateFrom, dateTo);
|
mailRepository.deleteAllByAddDateBetween(dateFrom, dateTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllByAddDateBefore(@NonNull LocalDateTime date) {
|
public void deleteAllByAddDateBefore(@NotNull LocalDateTime date) {
|
||||||
mailRepository.deleteAllByAddDateBefore(date);
|
mailRepository.deleteAllByAddDateBefore(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteAllByAddDateAfter(@NonNull LocalDateTime date) {
|
public void deleteAllByAddDateAfter(@NotNull LocalDateTime date) {
|
||||||
mailRepository.deleteAllByAddDateAfter(date);
|
mailRepository.deleteAllByAddDateAfter(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.struchkov.godfather.context.service.sender;
|
package dev.struchkov.godfather.context.service.sender;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Интерфейс для отправки ответов пользователю.
|
* Интерфейс для отправки ответов пользователю.
|
||||||
@ -16,9 +16,9 @@ public interface Sending {
|
|||||||
* @param personId Идентификатор пользователя
|
* @param personId Идентификатор пользователя
|
||||||
* @param boxAnswer Объект с данными, которые необходимо отправить
|
* @param boxAnswer Объект с данными, которые необходимо отправить
|
||||||
*/
|
*/
|
||||||
void send(@NonNull Long personId, @NonNull BoxAnswer boxAnswer);
|
void send(@NotNull Long personId, @NotNull BoxAnswer boxAnswer);
|
||||||
|
|
||||||
void send(@NonNull Long contentId, @NonNull Long personId, @NonNull BoxAnswer boxAnswer);
|
void send(@NotNull Long contentId, @NotNull Long personId, @NotNull BoxAnswer boxAnswer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Возвращает тип объекта отправляющего ответ пользователя. В зависимости от типа ответ будет отправлен с помощью
|
* Возвращает тип объекта отправляющего ответ пользователя. В зависимости от типа ответ будет отправлен с помощью
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
package dev.struchkov.godfather.context.service.sender.email;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class EmailConfig {
|
|
||||||
|
|
||||||
private Properties props = new Properties();
|
|
||||||
private String username;
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
private EmailConfig() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new EmailConfig().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder smtpHost(String smtpHost) {
|
|
||||||
EmailConfig.this.props.setProperty("mail.smtp.host", smtpHost);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder smtpSocketFactoryPort(Integer smtpSocketFactoryPortort) {
|
|
||||||
EmailConfig.this.props.setProperty("mail.smtp.socketFactory.port", smtpSocketFactoryPortort.toString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder smtpSocketFactoryClass(String smtpSocketFactoryClass) {
|
|
||||||
EmailConfig.this.props.setProperty("mail.smtp.socketFactory.class", smtpSocketFactoryClass);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder smtpAuth(Boolean smtpAuth) {
|
|
||||||
EmailConfig.this.props.setProperty("mail.smtp.auth", (smtpAuth) ? "true" : "false");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder smtpPort(Integer smtpPort) {
|
|
||||||
EmailConfig.this.props.setProperty("mail.smtp.port", smtpPort.toString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder email(String username) {
|
|
||||||
EmailConfig.this.username = username;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder password(String password) {
|
|
||||||
EmailConfig.this.password = password;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmailConfig build() {
|
|
||||||
return EmailConfig.this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package dev.struchkov.godfather.context.service.sender.email;
|
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.exception.MailSendException;
|
|
||||||
import dev.struchkov.godfather.context.service.sender.SendType;
|
|
||||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
|
||||||
|
|
||||||
import javax.mail.Authenticator;
|
|
||||||
import javax.mail.Message;
|
|
||||||
import javax.mail.MessagingException;
|
|
||||||
import javax.mail.PasswordAuthentication;
|
|
||||||
import javax.mail.Session;
|
|
||||||
import javax.mail.Transport;
|
|
||||||
import javax.mail.internet.InternetAddress;
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class EmailSending implements Sending {
|
|
||||||
|
|
||||||
private final EmailConfig emailConfig;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void send(@NonNull Long personId, @NonNull BoxAnswer boxAnswer) {
|
|
||||||
Session session = Session.getDefaultInstance(emailConfig.getProps(), new Authenticator() {
|
|
||||||
@Override
|
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
|
||||||
return new PasswordAuthentication(emailConfig.getUsername(), emailConfig.getPassword());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
Message message = new MimeMessage(session);
|
|
||||||
message.setFrom(new InternetAddress(emailConfig.getUsername()));
|
|
||||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailConfig.getUsername()));
|
|
||||||
message.setContent(boxAnswer.getMessage(), "text/html; charset=utf-8");
|
|
||||||
Transport.send(message);
|
|
||||||
} catch (MessagingException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new MailSendException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void send(@NonNull Long contentId, @NonNull Long personId, @NonNull BoxAnswer boxAnswer) {
|
|
||||||
throw new MailSendException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SendType getType() {
|
|
||||||
return SendType.PUBLIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +1,13 @@
|
|||||||
package dev.struchkov.godfather.context.utils;
|
package dev.struchkov.godfather.context.utils;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс для вставки слов в текстовую строку вместо подстрок - шаблонов маркеров.
|
* Класс для вставки слов в текстовую строку вместо подстрок - шаблонов маркеров.
|
||||||
*
|
*
|
||||||
@ -16,7 +18,7 @@ public class InsertWords {
|
|||||||
private static final Pattern pattern = Pattern.compile("\\{(\\d+)}");
|
private static final Pattern pattern = Pattern.compile("\\{(\\d+)}");
|
||||||
|
|
||||||
private InsertWords() {
|
private InsertWords() {
|
||||||
throw new IllegalStateException(Messages.UTILITY_CLASS);
|
utilityClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,9 +28,9 @@ public class InsertWords {
|
|||||||
* @param words Список слов, которые необходимо поместить вместо шаблона
|
* @param words Список слов, которые необходимо поместить вместо шаблона
|
||||||
* @return Модифицированная строка
|
* @return Модифицированная строка
|
||||||
*/
|
*/
|
||||||
public static String insert(@NonNull String text, List<String> words) {
|
public static String insert(@NotNull String text, List<String> words) {
|
||||||
Matcher m = pattern.matcher(text);
|
final Matcher m = pattern.matcher(text);
|
||||||
StringBuffer result = new StringBuffer();
|
final StringBuilder result = new StringBuilder();
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
if (Integer.parseInt(m.group(1)) < words.size()) {
|
if (Integer.parseInt(m.group(1)) < words.size()) {
|
||||||
m.appendReplacement(result, words.get(Integer.parseInt(m.group(1))));
|
m.appendReplacement(result, words.get(Integer.parseInt(m.group(1))));
|
||||||
|
@ -27,9 +27,9 @@ public class KeyBoards {
|
|||||||
* @return {@link SimpleKeyBoard}
|
* @return {@link SimpleKeyBoard}
|
||||||
*/
|
*/
|
||||||
public static SimpleKeyBoard keyBoardYesNo() {
|
public static SimpleKeyBoard keyBoardYesNo() {
|
||||||
return SimpleKeyBoard.simpleBuilder().line(
|
return SimpleKeyBoard.build().line(
|
||||||
SimpleKeyBoardLine.simpleBuilder().button(YES_BUTTON).button(NO_BUTTON).simpleBuild()
|
SimpleKeyBoardLine.builder().button(YES_BUTTON).button(NO_BUTTON).build()
|
||||||
).simpleBuild();
|
).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,12 +39,12 @@ public class KeyBoards {
|
|||||||
* @return {@link SimpleKeyBoard}
|
* @return {@link SimpleKeyBoard}
|
||||||
*/
|
*/
|
||||||
public static SimpleKeyBoard verticalMenuString(List<String> labelButtons) {
|
public static SimpleKeyBoard verticalMenuString(List<String> labelButtons) {
|
||||||
final SimpleKeyBoard.SimpleKeyBoardBuilder keyBoard = SimpleKeyBoard.simpleBuilder();
|
final SimpleKeyBoard.Builder keyBoard = SimpleKeyBoard.build();
|
||||||
for (String labelButton : labelButtons) {
|
for (String labelButton : labelButtons) {
|
||||||
final SimpleButton simpleButton = SimpleButton.of(labelButton, "{\"button\": \"" + labelButton + "\"}");
|
final SimpleButton simpleButton = SimpleButton.of(labelButton, "{\"button\": \"" + labelButton + "\"}");
|
||||||
keyBoard.line(SimpleKeyBoardLine.simpleBuilder().button(simpleButton).simpleBuild());
|
keyBoard.line(SimpleKeyBoardLine.builder().button(simpleButton).build());
|
||||||
}
|
}
|
||||||
return keyBoard.simpleBuild();
|
return keyBoard.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,25 +74,25 @@ public class KeyBoards {
|
|||||||
* @return {@link SimpleKeyBoard}
|
* @return {@link SimpleKeyBoard}
|
||||||
*/
|
*/
|
||||||
public static SimpleKeyBoard verticalDuoMenuString(List<String> labelButton) {
|
public static SimpleKeyBoard verticalDuoMenuString(List<String> labelButton) {
|
||||||
final SimpleKeyBoard.SimpleKeyBoardBuilder keyBoard = SimpleKeyBoard.simpleBuilder();
|
final SimpleKeyBoard.Builder keyBoard = SimpleKeyBoard.build();
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
SimpleKeyBoardLine.SimpleKeyBoardLineBuilder keyBoardLine = SimpleKeyBoardLine.simpleBuilder();
|
SimpleKeyBoardLine.Builder keyBoardLine = SimpleKeyBoardLine.builder();
|
||||||
for (int i = 0; i <= labelButton.size() - 1; i++) {
|
for (int i = 0; i <= labelButton.size() - 1; i++) {
|
||||||
String label = labelButton.get(i);
|
String label = labelButton.get(i);
|
||||||
keyBoardLine.button(SimpleButton.of(label));
|
keyBoardLine.button(SimpleButton.of(label));
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (i == labelButton.size() - 1) {
|
if (i == labelButton.size() - 1) {
|
||||||
keyBoard.line(keyBoardLine.simpleBuild());
|
keyBoard.line(keyBoardLine.build());
|
||||||
} else {
|
} else {
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
keyBoard.line(keyBoardLine.simpleBuild());
|
keyBoard.line(keyBoardLine.build());
|
||||||
keyBoardLine = SimpleKeyBoardLine.simpleBuilder();
|
keyBoardLine = SimpleKeyBoardLine.builder();
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return keyBoard.simpleBuild();
|
return keyBoard.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,22 +102,11 @@ public class KeyBoards {
|
|||||||
* @return {@link SimpleKeyBoard}
|
* @return {@link SimpleKeyBoard}
|
||||||
*/
|
*/
|
||||||
public static SimpleKeyBoard verticalMenuButton(List<SimpleButton> simpleButtons) {
|
public static SimpleKeyBoard verticalMenuButton(List<SimpleButton> simpleButtons) {
|
||||||
final SimpleKeyBoard.SimpleKeyBoardBuilder keyBoard = SimpleKeyBoard.simpleBuilder();
|
final SimpleKeyBoard.Builder keyBoard = SimpleKeyBoard.build();
|
||||||
for (SimpleButton simpleButton : simpleButtons) {
|
for (SimpleButton simpleButton : simpleButtons) {
|
||||||
keyBoard.line(SimpleKeyBoardLine.simpleBuilder().button(simpleButton).simpleBuild());
|
keyBoard.line(SimpleKeyBoardLine.builder().button(simpleButton).build());
|
||||||
}
|
}
|
||||||
return keyBoard.simpleBuild();
|
return keyBoard.build();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Возвращает клавиатуру из одной кнопки
|
|
||||||
*
|
|
||||||
* @param simpleButton Кнопка
|
|
||||||
* @return {@link SimpleKeyBoard}
|
|
||||||
*/
|
|
||||||
public static SimpleKeyBoard singleton(SimpleButton simpleButton) {
|
|
||||||
final SimpleKeyBoardLine line = SimpleKeyBoardLine.simpleBuilder().button(simpleButton).simpleBuild();
|
|
||||||
return SimpleKeyBoard.simpleBuilder().line(line).simpleBuild();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package dev.struchkov.godfather.context.utils;
|
|||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
import dev.struchkov.godfather.context.service.sender.Sending;
|
||||||
import dev.struchkov.godfather.context.domain.content.Comment;
|
|
||||||
|
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Используется для отправки сообщений определенного типа.
|
* Используется для отправки сообщений определенного типа.
|
||||||
@ -13,13 +14,12 @@ import dev.struchkov.godfather.context.domain.content.Comment;
|
|||||||
public class Sender {
|
public class Sender {
|
||||||
|
|
||||||
private Sender() {
|
private Sender() {
|
||||||
throw new IllegalStateException(Messages.UTILITY_CLASS);
|
utilityClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sends(Message message, BoxAnswer boxAnswer, Sending sending) {
|
public static void sends(Message message, BoxAnswer boxAnswer, Sending sending) {
|
||||||
switch (sending.getType()) {
|
switch (sending.getType()) {
|
||||||
case PUBLIC:
|
case PUBLIC:
|
||||||
publicSend(message, boxAnswer, sending);
|
|
||||||
break;
|
break;
|
||||||
case PRIVATE:
|
case PRIVATE:
|
||||||
privateSend(message, boxAnswer, sending);
|
privateSend(message, boxAnswer, sending);
|
||||||
@ -27,12 +27,6 @@ public class Sender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void publicSend(Message message, BoxAnswer boxAnswer, Sending sending) {
|
|
||||||
if (message instanceof Comment) {
|
|
||||||
sending.send(((Comment) message).getContentId(), message.getPersonId(), boxAnswer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void privateSend(Message message, BoxAnswer boxAnswer, Sending sending) {
|
private static void privateSend(Message message, BoxAnswer boxAnswer, Sending sending) {
|
||||||
sending.send(message.getPersonId(), boxAnswer);
|
sending.send(message.getPersonId(), boxAnswer);
|
||||||
}
|
}
|
||||||
|
@ -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.4-SNAPSHOT</version>
|
<version>0.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>bot-core</artifactId>
|
<artifactId>bot-core</artifactId>
|
||||||
@ -14,10 +14,6 @@
|
|||||||
<name>Bot Core</name>
|
<name>Bot Core</name>
|
||||||
<description>Реализация основной логики для создания ботов без привязки к конкретным социальным сетям.</description>
|
<description>Реализация основной логики для создания ботов без привязки к конкретным социальным сетям.</description>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<skip.deploy>false</skip.deploy>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
@ -25,7 +21,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sadtech.autoresponder</groupId>
|
<groupId>dev.struchkov</groupId>
|
||||||
<artifactId>autoresponder</artifactId>
|
<artifactId>autoresponder</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package dev.struchkov.godfather.core;
|
package dev.struchkov.godfather.core;
|
||||||
|
|
||||||
|
import dev.struchkov.autoresponder.AutoResponder;
|
||||||
|
import dev.struchkov.autoresponder.entity.UnitPointer;
|
||||||
|
import dev.struchkov.autoresponder.repository.UnitPointerRepository;
|
||||||
|
import dev.struchkov.autoresponder.service.UnitPointerServiceImpl;
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.context.exception.ConfigAppException;
|
import dev.struchkov.godfather.context.exception.ConfigAppException;
|
||||||
import dev.struchkov.godfather.context.exception.NotFoundException;
|
|
||||||
import dev.struchkov.godfather.context.service.MessageService;
|
import dev.struchkov.godfather.context.service.MessageService;
|
||||||
import dev.struchkov.godfather.context.service.Modifiable;
|
import dev.struchkov.godfather.context.service.Modifiable;
|
||||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
import dev.struchkov.godfather.context.service.sender.Sending;
|
||||||
@ -17,10 +20,7 @@ import dev.struchkov.godfather.core.service.action.AnswerTimerAction;
|
|||||||
import dev.struchkov.godfather.core.service.action.AnswerValidityAction;
|
import dev.struchkov.godfather.core.service.action.AnswerValidityAction;
|
||||||
import dev.struchkov.godfather.core.service.timer.TimerService;
|
import dev.struchkov.godfather.core.service.timer.TimerService;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import org.sadtech.autoresponder.AutoResponder;
|
import dev.struchkov.haiti.context.exception.NotFoundException;
|
||||||
import org.sadtech.autoresponder.entity.UnitPointer;
|
|
||||||
import org.sadtech.autoresponder.repository.UnitPointerRepository;
|
|
||||||
import org.sadtech.autoresponder.service.UnitPointerServiceImpl;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -130,7 +130,7 @@ public class GeneralAutoResponder<T extends Message> extends TimerTask {
|
|||||||
MainUnit mainUnit = actionUnit.action(unitAnswer, event);
|
MainUnit mainUnit = actionUnit.action(unitAnswer, event);
|
||||||
return !unitAnswer.equals(mainUnit) ? getAction(event, mainUnit) : mainUnit;
|
return !unitAnswer.equals(mainUnit) ? getAction(event, mainUnit) : mainUnit;
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException("ActionUnit для типа " + unitAnswer.getType() + " не зарегистрирован");
|
throw new NotFoundException("ActionUnit для типа {0} не зарегистрирован", unitAnswer.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
package dev.struchkov.godfather.core.domain;
|
package dev.struchkov.godfather.core.domain;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Getter
|
|
||||||
public class Clarification {
|
public class Clarification {
|
||||||
|
|
||||||
private BoxAnswer question;
|
private BoxAnswer question;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
public Clarification(BoxAnswer question, String value) {
|
||||||
|
this.question = question;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoxAnswer getQuestion() {
|
||||||
|
return question;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@ package dev.struchkov.godfather.core.domain;
|
|||||||
|
|
||||||
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
||||||
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@ -13,9 +10,6 @@ import java.time.LocalDateTime;
|
|||||||
*
|
*
|
||||||
* @author upagge [11/07/2019]
|
* @author upagge [11/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Builder
|
|
||||||
public class Timer {
|
public class Timer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,4 +52,140 @@ public class Timer {
|
|||||||
*/
|
*/
|
||||||
private CheckData checkLoop;
|
private CheckData checkLoop;
|
||||||
|
|
||||||
|
private Timer(Builder builder) {
|
||||||
|
id = builder.id;
|
||||||
|
unitAnswer = builder.unitAnswer;
|
||||||
|
unitDeath = builder.unitDeath;
|
||||||
|
personId = builder.personId;
|
||||||
|
timeActive = builder.timeActive;
|
||||||
|
timeDeath = builder.timeDeath;
|
||||||
|
periodSec = builder.periodSec;
|
||||||
|
checkLoop = builder.checkLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainUnit getUnitAnswer() {
|
||||||
|
return unitAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitAnswer(MainUnit unitAnswer) {
|
||||||
|
this.unitAnswer = unitAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainUnit getUnitDeath() {
|
||||||
|
return unitDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitDeath(MainUnit unitDeath) {
|
||||||
|
this.unitDeath = unitDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPersonId() {
|
||||||
|
return personId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonId(Long personId) {
|
||||||
|
this.personId = personId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getTimeActive() {
|
||||||
|
return timeActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeActive(LocalDateTime timeActive) {
|
||||||
|
this.timeActive = timeActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getTimeDeath() {
|
||||||
|
return timeDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeDeath(LocalDateTime timeDeath) {
|
||||||
|
this.timeDeath = timeDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPeriodSec() {
|
||||||
|
return periodSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriodSec(Integer periodSec) {
|
||||||
|
this.periodSec = periodSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckData getCheckLoop() {
|
||||||
|
return checkLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckLoop(CheckData checkLoop) {
|
||||||
|
this.checkLoop = checkLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private Integer id;
|
||||||
|
private MainUnit unitAnswer;
|
||||||
|
private MainUnit unitDeath;
|
||||||
|
private Long personId;
|
||||||
|
private LocalDateTime timeActive;
|
||||||
|
private LocalDateTime timeDeath;
|
||||||
|
private Integer periodSec;
|
||||||
|
private CheckData checkLoop;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder id(Integer val) {
|
||||||
|
id = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitAnswer(MainUnit val) {
|
||||||
|
unitAnswer = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitDeath(MainUnit val) {
|
||||||
|
unitDeath = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder personId(Long val) {
|
||||||
|
personId = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder timeActive(LocalDateTime val) {
|
||||||
|
timeActive = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder timeDeath(LocalDateTime val) {
|
||||||
|
timeDeath = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder periodSec(Integer val) {
|
||||||
|
periodSec = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder checkLoop(CheckData val) {
|
||||||
|
checkLoop = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timer build() {
|
||||||
|
return new Timer(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
package dev.struchkov.godfather.core.domain.question;
|
//package dev.struchkov.godfather.core.domain.question;
|
||||||
|
//
|
||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
//import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||||
import lombok.Builder;
|
//import lombok.Builder;
|
||||||
import lombok.Getter;
|
//import lombok.Getter;
|
||||||
import lombok.Setter;
|
//import lombok.Setter;
|
||||||
import lombok.Singular;
|
//import lombok.Singular;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Используется для конфигурации генерации цепочки Unit-ов в виде тестов для прохождения пользователем.
|
// * Используется для конфигурации генерации цепочки Unit-ов в виде тестов для прохождения пользователем.
|
||||||
*
|
// *
|
||||||
* @author upagge [14/07/2019]
|
// * @author upagge [14/07/2019]
|
||||||
*/
|
// */
|
||||||
@Getter
|
//@Getter
|
||||||
@Setter
|
//@Setter
|
||||||
@Builder
|
//@Builder
|
||||||
public class Question {
|
//public class Question {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Вопрос.
|
// * Вопрос.
|
||||||
*/
|
// */
|
||||||
private BoxAnswer boxAnswer;
|
// private BoxAnswer boxAnswer;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Список предполагаемых ответов.
|
// * Список предполагаемых ответов.
|
||||||
*/
|
// */
|
||||||
@Singular
|
// @Singular
|
||||||
private List<QuestionAnswer> questionAnswers;
|
// private List<QuestionAnswer> questionAnswers;
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
package dev.struchkov.godfather.core.domain.question;
|
//package dev.struchkov.godfather.core.domain.question;
|
||||||
|
//
|
||||||
import lombok.Getter;
|
//import lombok.Getter;
|
||||||
import lombok.Setter;
|
//import lombok.Setter;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Используется для конфигурации генерации цепочки Unit-ов в виде тестов для прохождения пользователем.
|
// * Используется для конфигурации генерации цепочки Unit-ов в виде тестов для прохождения пользователем.
|
||||||
* Отвечает за варианты ответов.
|
// * Отвечает за варианты ответов.
|
||||||
*
|
// *
|
||||||
* @author upagge [14/07/2019]
|
// * @author upagge [14/07/2019]
|
||||||
*/
|
// */
|
||||||
@Getter
|
//@Getter
|
||||||
@Setter
|
//@Setter
|
||||||
public class QuestionAnswer {
|
//public class QuestionAnswer {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Текстовый ответ.
|
// * Текстовый ответ.
|
||||||
*/
|
// */
|
||||||
private String text;
|
// private String text;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Количество балов за ответ.
|
// * Количество балов за ответ.
|
||||||
*/
|
// */
|
||||||
private int points;
|
// private int points;
|
||||||
|
//
|
||||||
public QuestionAnswer(String text, Integer points) {
|
// public QuestionAnswer(String text, Integer points) {
|
||||||
this.text = text;
|
// this.text = text;
|
||||||
this.points = points;
|
// this.points = points;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public QuestionAnswer(String text) {
|
// public QuestionAnswer(String text) {
|
||||||
this.text = text;
|
// this.text = text;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
package dev.struchkov.godfather.core.domain.question;
|
//package dev.struchkov.godfather.core.domain.question;
|
||||||
|
//
|
||||||
import lombok.AllArgsConstructor;
|
//import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
//import lombok.Getter;
|
||||||
import lombok.Setter;
|
//import lombok.Setter;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Используется для сохранения результатов ответов на вопросы.
|
// * Используется для сохранения результатов ответов на вопросы.
|
||||||
*
|
// *
|
||||||
* @author upagge [14/07/2019]
|
// * @author upagge [14/07/2019]
|
||||||
*/
|
// */
|
||||||
@Getter
|
//@Getter
|
||||||
@Setter
|
//@Setter
|
||||||
@AllArgsConstructor
|
//@AllArgsConstructor
|
||||||
public class QuestionResult {
|
//public class QuestionResult {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Вопрос.
|
// * Вопрос.
|
||||||
*/
|
// */
|
||||||
private String question;
|
// private String question;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Ответ.
|
// * Ответ.
|
||||||
*/
|
// */
|
||||||
private String answer;
|
// private String answer;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Количество баллов за ответ.
|
// * Количество баллов за ответ.
|
||||||
*/
|
// */
|
||||||
private Integer points;
|
// private Integer points;
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
@ -3,21 +3,20 @@ package dev.struchkov.godfather.core.domain.unit;
|
|||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static dev.struchkov.godfather.context.exception.UnitConfigException.unitConfigException;
|
||||||
|
import static dev.struchkov.haiti.utils.Inspector.isAnyNotNull;
|
||||||
|
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Обработчик запроса, который реализует конструкцию IF в сценарии.
|
* Обработчик запроса, который реализует конструкцию IF в сценарии.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AnswerCheck extends MainUnit {
|
public class AnswerCheck extends MainUnit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,23 +34,99 @@ public class AnswerCheck extends MainUnit {
|
|||||||
*/
|
*/
|
||||||
private final CheckData<Message> check;
|
private final CheckData<Message> check;
|
||||||
|
|
||||||
@Builder
|
private AnswerCheck(Builder builder) {
|
||||||
protected AnswerCheck(
|
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, null, builder.activeType, TypeUnit.CHECK);
|
||||||
@Singular Set<String> keyWords,
|
unitTrue = builder.unitTrue;
|
||||||
String phrase,
|
unitFalse = builder.unitFalse;
|
||||||
Pattern pattern,
|
check = builder.check;
|
||||||
Integer matchThreshold,
|
}
|
||||||
Integer priority,
|
|
||||||
@Singular Set<MainUnit> nextUnits,
|
public static Builder builder() {
|
||||||
UnitActiveType activeType,
|
return new Builder();
|
||||||
MainUnit unitTrue,
|
}
|
||||||
MainUnit unitFalse,
|
|
||||||
CheckData<Message> check
|
public MainUnit getUnitTrue() {
|
||||||
) {
|
return unitTrue;
|
||||||
super(keyWords, phrase, pattern, matchThreshold, priority, nextUnits, activeType, TypeUnit.CHECK);
|
}
|
||||||
this.unitTrue = unitTrue;
|
|
||||||
this.unitFalse = unitFalse;
|
public MainUnit getUnitFalse() {
|
||||||
this.check = check;
|
return unitFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckData<Message> getCheck() {
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private Set<String> keyWords = new HashSet<>();
|
||||||
|
private String phrase;
|
||||||
|
private Pattern pattern;
|
||||||
|
private Integer matchThreshold;
|
||||||
|
private Integer priority;
|
||||||
|
private MainUnit unitTrue;
|
||||||
|
private MainUnit unitFalse;
|
||||||
|
private CheckData<Message> check;
|
||||||
|
private UnitActiveType activeType;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder keyWords(Set<String> val) {
|
||||||
|
keyWords = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder keyWord(String val) {
|
||||||
|
keyWords.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder phrase(String val) {
|
||||||
|
phrase = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder pattern(Pattern val) {
|
||||||
|
pattern = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder matchThreshold(Integer val) {
|
||||||
|
matchThreshold = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder priority(Integer val) {
|
||||||
|
priority = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitTrue(MainUnit unitTrue) {
|
||||||
|
this.unitTrue = unitTrue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitFalse(MainUnit unitFalse) {
|
||||||
|
this.unitFalse = unitFalse;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder check(CheckData<Message> check) {
|
||||||
|
this.check = check;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder activeType(UnitActiveType val) {
|
||||||
|
activeType = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerCheck build() {
|
||||||
|
isNotNull(check, unitConfigException("Необходимо установить параметр проверки."));
|
||||||
|
isAnyNotNull(unitConfigException("Необходимо задать хотя бы один unit результата проверки."));
|
||||||
|
return new AnswerCheck(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,8 @@ import dev.struchkov.godfather.context.domain.content.Message;
|
|||||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
import dev.struchkov.godfather.context.service.sender.Sending;
|
||||||
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
|
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -17,8 +14,6 @@ import java.util.regex.Pattern;
|
|||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AnswerProcessing<M extends Message> extends MainUnit {
|
public class AnswerProcessing<M extends Message> extends MainUnit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,21 +26,87 @@ public class AnswerProcessing<M extends Message> extends MainUnit {
|
|||||||
*/
|
*/
|
||||||
private final Sending sending;
|
private final Sending sending;
|
||||||
|
|
||||||
@Builder
|
private AnswerProcessing(Builder<M> builder) {
|
||||||
private AnswerProcessing(
|
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, builder.nextUnits, builder.activeType, TypeUnit.PROCESSING);
|
||||||
@Singular Set<String> keyWords,
|
processingData = builder.processingData;
|
||||||
String phrase,
|
sending = builder.sending;
|
||||||
Pattern pattern,
|
}
|
||||||
Integer matchThreshold,
|
|
||||||
Integer priority,
|
public static <M extends Message> Builder<M> builder() {
|
||||||
@Singular Set<MainUnit> nextUnits,
|
return new Builder<>();
|
||||||
UnitActiveType activeType,
|
}
|
||||||
ProcessingData<M> processingData,
|
|
||||||
Sending sending
|
public ProcessingData<M> getProcessingData() {
|
||||||
) {
|
return processingData;
|
||||||
super(keyWords, phrase, pattern, matchThreshold, priority, nextUnits, activeType, TypeUnit.PROCESSING);
|
}
|
||||||
this.processingData = processingData;
|
|
||||||
this.sending = sending;
|
public Sending getSending() {
|
||||||
|
return sending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder<M extends Message> {
|
||||||
|
private Set<String> keyWords = new HashSet<>();
|
||||||
|
private String phrase;
|
||||||
|
private Pattern pattern;
|
||||||
|
private Integer matchThreshold;
|
||||||
|
private Integer priority;
|
||||||
|
private Set<MainUnit> nextUnits = new HashSet<>();
|
||||||
|
private ProcessingData<M> processingData;
|
||||||
|
private Sending sending;
|
||||||
|
private UnitActiveType activeType;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> keyWords(Set<String> val) {
|
||||||
|
keyWords = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> keyWord(String val) {
|
||||||
|
keyWords.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> phrase(String val) {
|
||||||
|
phrase = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> pattern(Pattern val) {
|
||||||
|
pattern = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> matchThreshold(Integer val) {
|
||||||
|
matchThreshold = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> priority(Integer val) {
|
||||||
|
priority = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> nextUnits(Set<MainUnit> val) {
|
||||||
|
nextUnits = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> nextUnit(MainUnit val) {
|
||||||
|
nextUnits.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> activeType(UnitActiveType val) {
|
||||||
|
activeType = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerProcessing<M> build() {
|
||||||
|
return new AnswerProcessing<>(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,8 @@ import dev.struchkov.godfather.core.service.save.Preservable;
|
|||||||
import dev.struchkov.godfather.core.service.save.data.PreservableData;
|
import dev.struchkov.godfather.core.service.save.data.PreservableData;
|
||||||
import dev.struchkov.godfather.core.service.save.push.Pusher;
|
import dev.struchkov.godfather.core.service.save.push.Pusher;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -21,8 +16,6 @@ import java.util.regex.Pattern;
|
|||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AnswerSave<D> extends MainUnit {
|
public class AnswerSave<D> extends MainUnit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,29 +45,19 @@ public class AnswerSave<D> extends MainUnit {
|
|||||||
|
|
||||||
private final CheckSave<? super Message> checkSave;
|
private final CheckSave<? super Message> checkSave;
|
||||||
|
|
||||||
@Builder
|
private AnswerSave(Builder<D> builder) {
|
||||||
private AnswerSave(
|
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, builder.nextUnits, (builder.hidden) ? UnitActiveType.AFTER : UnitActiveType.DEFAULT, TypeUnit.SAVE);
|
||||||
@Singular Set<String> keyWords,
|
|
||||||
String phrase,
|
|
||||||
Pattern pattern,
|
|
||||||
Integer matchThreshold,
|
|
||||||
Integer priority,
|
|
||||||
@Singular Set<MainUnit> nextUnits,
|
|
||||||
Preservable<D> preservable,
|
|
||||||
String key,
|
|
||||||
Pusher<D> pusher,
|
|
||||||
PreservableData<D, ? super Message> preservableData,
|
|
||||||
CheckSave<? super Message> checkSave,
|
|
||||||
boolean hidden
|
|
||||||
) {
|
|
||||||
super(keyWords, phrase, pattern, matchThreshold, priority, nextUnits, (hidden) ? UnitActiveType.AFTER : UnitActiveType.DEFAULT, TypeUnit.SAVE);
|
|
||||||
this.key = key;
|
|
||||||
this.pusher = pusher;
|
|
||||||
maintenanceNextUnit(nextUnits);
|
maintenanceNextUnit(nextUnits);
|
||||||
this.preservable = preservable;
|
preservable = builder.preservable;
|
||||||
this.preservableData = preservableData;
|
key = builder.key;
|
||||||
this.hidden = Optional.of(hidden).orElse(false);
|
pusher = builder.pusher;
|
||||||
this.checkSave = checkSave;
|
preservableData = builder.preservableData;
|
||||||
|
hidden = builder.hidden;
|
||||||
|
checkSave = builder.checkSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <D> Builder<D> builder() {
|
||||||
|
return new Builder<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maintenanceNextUnit(Collection<MainUnit> units) {
|
private void maintenanceNextUnit(Collection<MainUnit> units) {
|
||||||
@ -83,4 +66,121 @@ public class AnswerSave<D> extends MainUnit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Preservable<D> getPreservable() {
|
||||||
|
return preservable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pusher<D> getPusher() {
|
||||||
|
return pusher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreservableData<D, ? super Message> getPreservableData() {
|
||||||
|
return preservableData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHidden() {
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckSave<? super Message> getCheckSave() {
|
||||||
|
return checkSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder<D> {
|
||||||
|
private Set<String> keyWords;
|
||||||
|
private String phrase;
|
||||||
|
private Pattern pattern;
|
||||||
|
private Integer matchThreshold;
|
||||||
|
private Integer priority;
|
||||||
|
private Set<MainUnit> nextUnits;
|
||||||
|
private Preservable<D> preservable;
|
||||||
|
private String key;
|
||||||
|
private Pusher<D> pusher;
|
||||||
|
private PreservableData<D, ? super Message> preservableData;
|
||||||
|
private boolean hidden;
|
||||||
|
private CheckSave<? super Message> checkSave;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> keyWords(Set<String> val) {
|
||||||
|
keyWords = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> keyWord(String val) {
|
||||||
|
keyWords.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> phrase(String val) {
|
||||||
|
phrase = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> pattern(Pattern val) {
|
||||||
|
pattern = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> matchThreshold(Integer val) {
|
||||||
|
matchThreshold = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> priority(Integer val) {
|
||||||
|
priority = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> nextUnits(Set<MainUnit> val) {
|
||||||
|
nextUnits = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> nextUnit(MainUnit val) {
|
||||||
|
nextUnits.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> preservable(Preservable<D> val) {
|
||||||
|
this.preservable = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> key(String val) {
|
||||||
|
this.key = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> pusher(Pusher<D> val) {
|
||||||
|
this.pusher = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> preservableData(PreservableData<D, ? super Message> val) {
|
||||||
|
this.preservableData = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> hidden(boolean val) {
|
||||||
|
this.hidden = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<D> checkSave(CheckSave<? super Message> val) {
|
||||||
|
this.checkSave = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerSave<D> build() {
|
||||||
|
return new AnswerSave<>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,23 @@ package dev.struchkov.godfather.core.domain.unit;
|
|||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
|
import dev.struchkov.godfather.context.exception.UnitConfigException;
|
||||||
import dev.struchkov.godfather.context.service.sender.Sending;
|
import dev.struchkov.godfather.context.service.sender.Sending;
|
||||||
import dev.struchkov.godfather.context.service.usercode.Insert;
|
import dev.struchkov.godfather.context.service.usercode.Insert;
|
||||||
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
|
import dev.struchkov.godfather.context.service.usercode.ProcessingData;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Используется для отправки ответа пользователю.
|
* Используется для отправки ответа пользователю.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AnswerText<M extends Message> extends MainUnit {
|
public class AnswerText<M extends Message> extends MainUnit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,34 +29,122 @@ public class AnswerText<M extends Message> extends MainUnit {
|
|||||||
/**
|
/**
|
||||||
* Информация, которую необходимо вставить вместо маркеров в строку ответа.
|
* Информация, которую необходимо вставить вместо маркеров в строку ответа.
|
||||||
*/
|
*/
|
||||||
private final Insert insert;
|
private Insert insert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Объект нестандартной отправки ответа.
|
* Объект нестандартной отправки ответа.
|
||||||
*/
|
*/
|
||||||
private final Sending sending;
|
private Sending sending;
|
||||||
|
|
||||||
@Builder(toBuilder = true)
|
private AnswerText(Builder<M> builder) {
|
||||||
private AnswerText(
|
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, builder.nextUnits, builder.activeType, TypeUnit.TEXT);
|
||||||
@Singular Set<String> keyWords,
|
keyWords = builder.keyWords;
|
||||||
String phrase,
|
phrase = builder.phrase;
|
||||||
Pattern pattern,
|
pattern = builder.pattern;
|
||||||
Integer matchThreshold,
|
matchThreshold = builder.matchThreshold;
|
||||||
Integer priority,
|
priority = builder.priority;
|
||||||
@Singular Set<MainUnit> nextUnits,
|
nextUnits = builder.nextUnits;
|
||||||
UnitActiveType activeType,
|
boxAnswer = builder.boxAnswer;
|
||||||
ProcessingData<M> boxAnswer,
|
insert = builder.insert;
|
||||||
Insert insert,
|
sending = builder.sending;
|
||||||
Sending sending
|
activeType = builder.activeType;
|
||||||
) {
|
|
||||||
super(keyWords, phrase, pattern, matchThreshold, priority, nextUnits, activeType, TypeUnit.TEXT);
|
|
||||||
this.boxAnswer = boxAnswer;
|
|
||||||
this.insert = insert;
|
|
||||||
this.sending = sending;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnswerText of(String message) {
|
public static <M extends Message> AnswerText<M> of(String message) {
|
||||||
return builder().boxAnswer(BoxAnswer.processing(message)).build();
|
return AnswerText.<M>builder().boxAnswer(BoxAnswer.processing(message)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <M extends Message> Builder<M> builder() {
|
||||||
|
return new Builder<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProcessingData<M> getBoxAnswer() {
|
||||||
|
return boxAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Insert getInsert() {
|
||||||
|
return insert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sending getSending() {
|
||||||
|
return sending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder<M extends Message> {
|
||||||
|
private ProcessingData<M> boxAnswer;
|
||||||
|
private Insert insert;
|
||||||
|
private Sending sending;
|
||||||
|
private Set<String> keyWords;
|
||||||
|
private String phrase;
|
||||||
|
private Pattern pattern;
|
||||||
|
private Integer matchThreshold;
|
||||||
|
private Integer priority;
|
||||||
|
private Set<MainUnit> nextUnits = new HashSet<>();
|
||||||
|
private UnitActiveType activeType;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> boxAnswer(ProcessingData<M> boxAnswer) {
|
||||||
|
this.boxAnswer = boxAnswer;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> insert(Insert insert) {
|
||||||
|
this.insert = insert;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> sending(Sending sending) {
|
||||||
|
this.sending = sending;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> keyWords(Set<String> val) {
|
||||||
|
keyWords = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> phrase(String val) {
|
||||||
|
phrase = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> pattern(Pattern val) {
|
||||||
|
pattern = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> matchThreshold(Integer val) {
|
||||||
|
matchThreshold = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> priority(Integer val) {
|
||||||
|
priority = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> nextUnits(Set<MainUnit> val) {
|
||||||
|
nextUnits = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> nextUnit(MainUnit val) {
|
||||||
|
nextUnits.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> activeType(UnitActiveType val) {
|
||||||
|
activeType = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerText<M> build() {
|
||||||
|
isNotNull(boxAnswer, UnitConfigException.unitConfigException("BoxAnswer обязательный параметр юнита"));
|
||||||
|
return new AnswerText<>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
package dev.struchkov.godfather.core.domain.unit;
|
package dev.struchkov.godfather.core.domain.unit;
|
||||||
|
|
||||||
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static dev.struchkov.godfather.context.exception.UnitConfigException.unitConfigException;
|
||||||
|
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Обработчик таймер, позволяющий отложить обработку других Unit-ов.
|
* Обработчик таймер, позволяющий отложить обработку других Unit-ов.
|
||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
public class AnswerTimer<M extends Message> extends MainUnit {
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AnswerTimer extends MainUnit {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit обработку которого необходимо отложить.
|
* Unit обработку которого необходимо отложить.
|
||||||
@ -39,27 +35,107 @@ public class AnswerTimer extends MainUnit {
|
|||||||
/**
|
/**
|
||||||
* Условие срабатывания отложенного Unit.
|
* Условие срабатывания отложенного Unit.
|
||||||
*/
|
*/
|
||||||
private final CheckData checkLoop;
|
private final CheckData<M> checkLoop;
|
||||||
|
|
||||||
|
private AnswerTimer(Builder<M> builder) {
|
||||||
|
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, null, builder.activeType, TypeUnit.TIMER);
|
||||||
|
unitAnswer = builder.unitAnswer;
|
||||||
|
timeDelaySec = builder.timeDelaySec;
|
||||||
|
timeDeathSec = builder.timeDeathSec;
|
||||||
|
checkLoop = builder.checkLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <M extends Message> Builder<M> builder() {
|
||||||
|
return new Builder<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainUnit getUnitAnswer() {
|
||||||
|
return unitAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTimeDelaySec() {
|
||||||
|
return timeDelaySec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTimeDeathSec() {
|
||||||
|
return timeDeathSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckData<M> getCheckLoop() {
|
||||||
|
return checkLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder<M extends Message> {
|
||||||
|
private MainUnit unitAnswer;
|
||||||
|
private Integer timeDelaySec;
|
||||||
|
private Integer timeDeathSec;
|
||||||
|
private CheckData<M> checkLoop;
|
||||||
|
private Set<String> keyWords;
|
||||||
|
private String phrase;
|
||||||
|
private Pattern pattern;
|
||||||
|
private Integer matchThreshold;
|
||||||
|
private Integer priority;
|
||||||
|
private UnitActiveType activeType = UnitActiveType.AFTER;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> unitAnswer(MainUnit val) {
|
||||||
|
unitAnswer = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> timeDelaySec(Integer val) {
|
||||||
|
timeDelaySec = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> timeDeathSec(Integer val) {
|
||||||
|
timeDeathSec = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> checkLoop(CheckData<M> val) {
|
||||||
|
checkLoop = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> keyWords(Set<String> val) {
|
||||||
|
keyWords = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> phrase(String val) {
|
||||||
|
phrase = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> pattern(Pattern val) {
|
||||||
|
pattern = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> matchThreshold(Integer val) {
|
||||||
|
matchThreshold = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> priority(Integer val) {
|
||||||
|
priority = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<M> activeType(UnitActiveType val) {
|
||||||
|
activeType = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerTimer<M> build() {
|
||||||
|
isNotNull(unitAnswer, unitConfigException("Необходимо указать юнит, обработка которого будет отложена."));
|
||||||
|
return new AnswerTimer<>(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Builder
|
|
||||||
private AnswerTimer(
|
|
||||||
@Singular Set<String> keyWords,
|
|
||||||
String phrase,
|
|
||||||
Pattern pattern,
|
|
||||||
Integer matchThreshold,
|
|
||||||
Integer priority,
|
|
||||||
@Singular Set<MainUnit> nextUnits,
|
|
||||||
UnitActiveType activeType,
|
|
||||||
MainUnit unitAnswer,
|
|
||||||
Integer timeDelaySec,
|
|
||||||
Integer timeDeathSec,
|
|
||||||
CheckData checkLoop
|
|
||||||
) {
|
|
||||||
super(keyWords, phrase, pattern, matchThreshold, priority, nextUnits, (activeType == null) ? UnitActiveType.AFTER : activeType, TypeUnit.TIMER);
|
|
||||||
this.unitAnswer = unitAnswer;
|
|
||||||
this.timeDelaySec = timeDelaySec;
|
|
||||||
this.timeDeathSec = timeDeathSec;
|
|
||||||
this.checkLoop = checkLoop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,6 @@ import dev.struchkov.godfather.core.service.ClarificationQuestion;
|
|||||||
import dev.struchkov.godfather.core.service.save.LocalPreservable;
|
import dev.struchkov.godfather.core.service.save.LocalPreservable;
|
||||||
import dev.struchkov.godfather.core.service.save.Preservable;
|
import dev.struchkov.godfather.core.service.save.Preservable;
|
||||||
import dev.struchkov.godfather.core.utils.TypeUnit;
|
import dev.struchkov.godfather.core.utils.TypeUnit;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Singular;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -18,9 +13,6 @@ import java.util.regex.Pattern;
|
|||||||
*
|
*
|
||||||
* @author upagge [11/07/2019]
|
* @author upagge [11/07/2019]
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AnswerValidity extends MainUnit {
|
public class AnswerValidity extends MainUnit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,24 +34,121 @@ public class AnswerValidity extends MainUnit {
|
|||||||
|
|
||||||
private final ClarificationQuestion clarificationQuestion;
|
private final ClarificationQuestion clarificationQuestion;
|
||||||
|
|
||||||
@Builder(toBuilder = true)
|
private AnswerValidity(Builder builder) {
|
||||||
private AnswerValidity(
|
super(builder.keyWords, builder.phrase, builder.pattern, builder.matchThreshold, builder.priority, builder.nextUnits, UnitActiveType.DEFAULT, TypeUnit.VALIDITY);
|
||||||
@Singular Set<String> keyWords,
|
unitYes = builder.unitYes;
|
||||||
String phrase,
|
unitNo = builder.unitNo;
|
||||||
Pattern pattern,
|
unitNull = builder.unitNull;
|
||||||
Integer matchThreshold,
|
clarificationQuestion = builder.clarificationQuestion;
|
||||||
Integer priority,
|
}
|
||||||
@Singular Set<MainUnit> nextUnits,
|
|
||||||
MainUnit unitYes,
|
public static Builder builder() {
|
||||||
MainUnit unitNo,
|
return new Builder();
|
||||||
MainUnit unitNull,
|
}
|
||||||
ClarificationQuestion clarificationQuestion
|
|
||||||
) {
|
public MainUnit getUnitYes() {
|
||||||
super(keyWords, phrase, pattern, matchThreshold, priority, nextUnits, UnitActiveType.DEFAULT, TypeUnit.VALIDITY);
|
return unitYes;
|
||||||
this.unitYes = unitYes;
|
}
|
||||||
this.unitNo = unitNo;
|
|
||||||
this.unitNull = unitNull;
|
public MainUnit getUnitNo() {
|
||||||
this.clarificationQuestion = clarificationQuestion;
|
return unitNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainUnit getUnitNull() {
|
||||||
|
return unitNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Preservable<String> getTempSave() {
|
||||||
|
return tempSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClarificationQuestion getClarificationQuestion() {
|
||||||
|
return clarificationQuestion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder {
|
||||||
|
private MainUnit unitYes;
|
||||||
|
private MainUnit unitNo;
|
||||||
|
private MainUnit unitNull;
|
||||||
|
private ClarificationQuestion clarificationQuestion;
|
||||||
|
private Set<String> keyWords;
|
||||||
|
private String phrase;
|
||||||
|
private Pattern pattern;
|
||||||
|
private Integer matchThreshold;
|
||||||
|
private Integer priority;
|
||||||
|
private Set<MainUnit> nextUnits;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitYes(MainUnit val) {
|
||||||
|
unitYes = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitNo(MainUnit val) {
|
||||||
|
unitNo = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder unitNull(MainUnit val) {
|
||||||
|
unitNull = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder clarificationQuestion(ClarificationQuestion val) {
|
||||||
|
clarificationQuestion = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder keyWords(Set<String> val) {
|
||||||
|
keyWords = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder keyWord(String val) {
|
||||||
|
keyWords.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder phrase(String val) {
|
||||||
|
phrase = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder pattern(Pattern val) {
|
||||||
|
pattern = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder matchThreshold(Integer val) {
|
||||||
|
matchThreshold = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder priority(Integer val) {
|
||||||
|
priority = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder nextUnits(Set<MainUnit> val) {
|
||||||
|
nextUnits = val;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder nextUnit(MainUnit val) {
|
||||||
|
nextUnits.add(val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder clearKeyWords() {
|
||||||
|
nextUnits.clear();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnswerValidity build() {
|
||||||
|
return new AnswerValidity(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package dev.struchkov.godfather.core.domain.unit;
|
package dev.struchkov.godfather.core.domain.unit;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
import dev.struchkov.autoresponder.entity.Unit;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.sadtech.autoresponder.entity.Unit;
|
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -16,25 +13,19 @@ import java.util.regex.Pattern;
|
|||||||
*
|
*
|
||||||
* @author upagge [08/07/2019]
|
* @author upagge [08/07/2019]
|
||||||
*/
|
*/
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public abstract class MainUnit extends Unit<MainUnit> {
|
public abstract class MainUnit extends Unit<MainUnit> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Тип Unit-а.
|
* Тип Unit-а.
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
protected final String type;
|
protected final String type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Режим срабатывания Unit-а.
|
* Режим срабатывания Unit-а.
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
protected UnitActiveType activeType;
|
protected UnitActiveType activeType;
|
||||||
|
|
||||||
@Getter
|
private final String uuid = UUID.randomUUID().toString();
|
||||||
private String uuid = UUID.randomUUID().toString();
|
|
||||||
|
|
||||||
protected MainUnit(
|
protected MainUnit(
|
||||||
Set<String> keyWords,
|
Set<String> keyWords,
|
||||||
@ -51,4 +42,34 @@ public abstract class MainUnit extends Unit<MainUnit> {
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveType(UnitActiveType activeType) {
|
||||||
|
this.activeType = activeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitActiveType getActiveType() {
|
||||||
|
return activeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
if (!super.equals(o)) return false;
|
||||||
|
MainUnit mainUnit = (MainUnit) o;
|
||||||
|
return Objects.equals(type, mainUnit.type) && activeType == mainUnit.activeType && Objects.equals(uuid, mainUnit.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(super.hashCode(), type, activeType, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package dev.struchkov.godfather.core.service.action;
|
|||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.core.domain.unit.AnswerCheck;
|
import dev.struchkov.godfather.core.domain.unit.AnswerCheck;
|
||||||
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -12,9 +13,10 @@ import java.util.Optional;
|
|||||||
*
|
*
|
||||||
* @author upagge [11/07/2019]
|
* @author upagge [11/07/2019]
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class AnswerCheckAction implements ActionUnit<AnswerCheck, Message> {
|
public class AnswerCheckAction implements ActionUnit<AnswerCheck, Message> {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(AnswerCheckAction.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MainUnit action(AnswerCheck answerCheck, Message mail) {
|
public MainUnit action(AnswerCheck answerCheck, Message mail) {
|
||||||
MainUnit unitAnswer;
|
MainUnit unitAnswer;
|
||||||
|
@ -22,7 +22,7 @@ public class AnswerProcessingAction implements ActionUnit<AnswerProcessing<Messa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MainUnit action(AnswerProcessing<Message> answerProcessing, Message message) {
|
public MainUnit action(AnswerProcessing<Message> answerProcessing, Message message) {
|
||||||
BoxAnswer boxAnswer = answerProcessing.getProcessingData().processing(message);
|
final BoxAnswer boxAnswer = answerProcessing.getProcessingData().processing(message);
|
||||||
|
|
||||||
Sending answerProcessingSending = answerProcessing.getSending();
|
Sending answerProcessingSending = answerProcessing.getSending();
|
||||||
if (answerProcessingSending != null) {
|
if (answerProcessingSending != null) {
|
||||||
|
@ -7,8 +7,6 @@ import dev.struchkov.godfather.context.utils.InsertWords;
|
|||||||
import dev.struchkov.godfather.context.utils.Sender;
|
import dev.struchkov.godfather.context.utils.Sender;
|
||||||
import dev.struchkov.godfather.core.domain.unit.AnswerText;
|
import dev.struchkov.godfather.core.domain.unit.AnswerText;
|
||||||
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -17,22 +15,20 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author upagge [11/07/2019]
|
* @author upagge [11/07/2019]
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
public class AnswerTextAction implements ActionUnit<AnswerText<Message>, Message> {
|
||||||
@NoArgsConstructor
|
|
||||||
public class AnswerTextAction implements ActionUnit<AnswerText, Message> {
|
|
||||||
|
|
||||||
private Sending sending;
|
private final Sending sending;
|
||||||
|
|
||||||
|
public AnswerTextAction(Sending sending) {
|
||||||
|
this.sending = sending;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MainUnit action(AnswerText answerText, Message message) {
|
public MainUnit action(AnswerText<Message> answerText, Message message) {
|
||||||
BoxAnswer boxAnswer = answerText.getBoxAnswer().processing(message);
|
final BoxAnswer boxAnswer = answerText.getBoxAnswer().processing(message);
|
||||||
if (answerText.getInsert() != null) {
|
replaceMarkers(answerText, message, boxAnswer);
|
||||||
List<String> words = answerText.getInsert().insert(message.getPersonId());
|
|
||||||
String newMessage = InsertWords.insert(boxAnswer.getMessage(), words);
|
|
||||||
boxAnswer.setMessage(newMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Sending answerTextSending = answerText.getSending();
|
final Sending answerTextSending = answerText.getSending();
|
||||||
if (answerTextSending != null) {
|
if (answerTextSending != null) {
|
||||||
Sender.sends(message, boxAnswer, answerTextSending);
|
Sender.sends(message, boxAnswer, answerTextSending);
|
||||||
} else {
|
} else {
|
||||||
@ -42,5 +38,13 @@ public class AnswerTextAction implements ActionUnit<AnswerText, Message> {
|
|||||||
return answerText;
|
return answerText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void replaceMarkers(AnswerText<Message> answerText, Message message, BoxAnswer boxAnswer) {
|
||||||
|
if (answerText.getInsert() != null) {
|
||||||
|
final List<String> words = answerText.getInsert().insert(message.getPersonId());
|
||||||
|
final String newMessage = InsertWords.insert(boxAnswer.getMessage(), words);
|
||||||
|
boxAnswer.setMessage(newMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class AnswerTimerAction implements ActionUnit<AnswerTimer, Message> {
|
|||||||
.ofNullable(answerTimer.getTimeDelaySec())
|
.ofNullable(answerTimer.getTimeDelaySec())
|
||||||
.orElseThrow(() -> new TimerSettingException("Не установлена временная задержка таймера")));
|
.orElseThrow(() -> new TimerSettingException("Не установлена временная задержка таймера")));
|
||||||
|
|
||||||
Timer.TimerBuilder timer = Timer.builder()
|
Timer.Builder timer = Timer.builder()
|
||||||
.personId(message.getPersonId())
|
.personId(message.getPersonId())
|
||||||
.unitAnswer(answerTimer.getUnitAnswer())
|
.unitAnswer(answerTimer.getUnitAnswer())
|
||||||
.timeActive(timeActive)
|
.timeActive(timeActive)
|
||||||
|
@ -39,7 +39,7 @@ public class AnswerValidityAction implements ActionUnit<AnswerValidity, Message>
|
|||||||
return unit.getUnitNull();
|
return unit.getUnitNull();
|
||||||
} else {
|
} else {
|
||||||
unit.getTempSave().save(personId, "temp", value);
|
unit.getTempSave().save(personId, "temp", value);
|
||||||
AnswerValidity newValidity = unit.toBuilder()
|
AnswerValidity newValidity = unit.builder()
|
||||||
.clearKeyWords().keyWords(WORDS_YES_NO)
|
.clearKeyWords().keyWords(WORDS_YES_NO)
|
||||||
.build();
|
.build();
|
||||||
return AnswerText.builder()
|
return AnswerText.builder()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package dev.struchkov.godfather.core.service.save.data;
|
package dev.struchkov.godfather.core.service.save.data;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
import dev.struchkov.godfather.core.utils.Pair;
|
import dev.struchkov.haiti.utils.Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Добавить описание класса.
|
* TODO: Добавить описание класса.
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package dev.struchkov.godfather.core.service.save.jpa;//package org.sadtech.social.bot.service.save.jpa;
|
|
||||||
//
|
|
||||||
//import lombok.RequiredArgsConstructor;
|
|
||||||
//import org.sadtech.social.bot.service.save.Preservable;
|
|
||||||
//import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * TODO: Добавить описание класса.
|
|
||||||
// *
|
|
||||||
// * @author upagge [01/08/2019]
|
|
||||||
// */
|
|
||||||
//@RequiredArgsConstructor
|
|
||||||
//public abstract class PreservableJpa<R extends JpaRepository<D, Long>, D extends SaveObjectJpa> implements Preservable<D> {
|
|
||||||
//
|
|
||||||
// protected final R jpaRepository;
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void save(Long personId, String key, R save) {
|
|
||||||
// save.setPersonId(personId);
|
|
||||||
// jpaRepository.save(save);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
@ -1,25 +0,0 @@
|
|||||||
package dev.struchkov.godfather.core.service.save.jpa;
|
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.BasicEntity;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.MappedSuperclass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Добавить описание класса.
|
|
||||||
*
|
|
||||||
* @author upagge [01/08/2019]
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@MappedSuperclass
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public abstract class SaveObjectJpa extends BasicEntity {
|
|
||||||
|
|
||||||
@Column(name = "personId")
|
|
||||||
private Long personId;
|
|
||||||
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
package dev.struchkov.godfather.core.service.save.push;
|
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.exception.MailSendException;
|
|
||||||
import dev.struchkov.godfather.context.service.sender.email.EmailConfig;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import javax.mail.Authenticator;
|
|
||||||
import javax.mail.Message;
|
|
||||||
import javax.mail.MessagingException;
|
|
||||||
import javax.mail.PasswordAuthentication;
|
|
||||||
import javax.mail.Session;
|
|
||||||
import javax.mail.Transport;
|
|
||||||
import javax.mail.internet.InternetAddress;
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Сохранение результатов анкеты на Email.
|
|
||||||
*
|
|
||||||
* @author upagge [11/07/2019]
|
|
||||||
*/
|
|
||||||
// todo [upagge] [11/07/2019]: Отрефакторить
|
|
||||||
@Slf4j
|
|
||||||
public class EmailPusher implements Pusher<String> {
|
|
||||||
|
|
||||||
private final EmailConfig emailConfig;
|
|
||||||
private final String nameForm;
|
|
||||||
|
|
||||||
public EmailPusher(EmailConfig emailConfig, String nameForm) {
|
|
||||||
this.emailConfig = emailConfig;
|
|
||||||
this.nameForm = nameForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void push(Map<String, String> saveElement) {
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("<table cellspacing=\"0\" cellpadding=\"0\" width=\"600\" bgcolor=\"#FFFFFF\">\n" +
|
|
||||||
" <tbody>\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td>\n" +
|
|
||||||
" <table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n" +
|
|
||||||
" <tbody>\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td width=\"149\" valign=\"top\" bgcolor=\"#476695\" style=\"border-radius: 5px 0px 0px 0px;\"> </td>\n" +
|
|
||||||
" <td width=\"100%\" bgcolor=\"#476695\" valign=\"top\" style=\"border-radius: 0px 5px 0px 0px;\"> </td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" </tbody>\n" +
|
|
||||||
" </table>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td>\n" +
|
|
||||||
" <div style=\"padding:18px 18px 13px 18px;border-left:1px solid #dadee3;border-right:1px solid #dadee3;font-size:12px;color:black;\">\n" +
|
|
||||||
" <h1 style=\"margin:2px 0px 15px 0;padding:0px 0px 4px;border-bottom:1px solid #D8DFE6;color:#45668E;font-size:100%;\">")
|
|
||||||
.append(nameForm)
|
|
||||||
.append("</h1>\n" +
|
|
||||||
" <div style=\"line-height:160%;\">\n" +
|
|
||||||
" <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n" +
|
|
||||||
" <tbody>");
|
|
||||||
for (Map.Entry<String, String> element : saveElement.entrySet()) {
|
|
||||||
stringBuilder.append("<tr>\n" +
|
|
||||||
" <td valign=\"top\" style=\"padding-right:10px;color:#808080\">")
|
|
||||||
.append(element.getKey())
|
|
||||||
.append(":\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" <td style=\"padding-bottom:6px\">")
|
|
||||||
.append(element.getValue())
|
|
||||||
.append("</td></tr>");
|
|
||||||
}
|
|
||||||
stringBuilder.append("</tbody>\n" +
|
|
||||||
" </table>\n" +
|
|
||||||
" \n" +
|
|
||||||
" </div>\n" +
|
|
||||||
" </div>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td>\n" +
|
|
||||||
" <table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n" +
|
|
||||||
" <tbody>\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td width=\"3\">\n" +
|
|
||||||
" <div style=\"width:0;height:1px;max-height:1px;line-height:1px;font-size:0;border-left:1px solid #e6e7eb;border-right:1px solid #e8ebed;\"></div>\n" +
|
|
||||||
" <div style=\"width:0;height:1px;max-height:1px;line-height:1px;font-size:0;border-left:1px solid #f5f5f5;border-right:1px solid #e6e7eb;\"></div>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" <td width=\"100%\" valign=\"bottom\">\n" +
|
|
||||||
" <div style=\"height:1px;max-height:1px;line-height:0;font-size:0;border-bottom:1px solid #dadee3;\"> </div>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" <td width=\"3\" align=\"right\">\n" +
|
|
||||||
" <div style=\"width:0;height:1px;max-height:1px;line-height:1px;font-size:0;border-left:1px solid #e8ebed;border-right:1px solid #e6e7eb;\"></div>\n" +
|
|
||||||
" <div style=\"width:0;height:1px;max-height:1px;line-height:1px;font-size:0;border-left:1px solid #e6e7eb;border-right:1px solid #f5f5f5;\"></div>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" </tbody>\n" +
|
|
||||||
" </table>\n" +
|
|
||||||
" </td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" <tr>\n" +
|
|
||||||
" <td bgcolor=\"#ffffff\" align=\"center\" style=\"padding:13px 0 0 0;font-size:12px;color:#888888;\"></td>\n" +
|
|
||||||
" </tr>\n" +
|
|
||||||
" </tbody>\n" +
|
|
||||||
" </table>");
|
|
||||||
|
|
||||||
Session session = Session.getDefaultInstance(emailConfig.getProps(), new Authenticator() {
|
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
|
||||||
return new PasswordAuthentication(emailConfig.getUsername(), emailConfig.getPassword());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
Message message = new MimeMessage(session);
|
|
||||||
message.setFrom(new InternetAddress(emailConfig.getUsername()));
|
|
||||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailConfig.getUsername()));
|
|
||||||
message.setSubject(nameForm);
|
|
||||||
message.setContent(stringBuilder.toString(), "text/html; charset=utf-8");
|
|
||||||
Transport.send(message);
|
|
||||||
} catch (MessagingException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new MailSendException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +1,12 @@
|
|||||||
package dev.struchkov.godfather.core.service.timer;
|
package dev.struchkov.godfather.core.service.timer;
|
||||||
|
|
||||||
import dev.struchkov.godfather.context.domain.content.Message;
|
import dev.struchkov.godfather.context.domain.content.Message;
|
||||||
|
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
||||||
import dev.struchkov.godfather.context.utils.MessageUtils;
|
import dev.struchkov.godfather.context.utils.MessageUtils;
|
||||||
import dev.struchkov.godfather.core.GeneralAutoResponder;
|
import dev.struchkov.godfather.core.GeneralAutoResponder;
|
||||||
import dev.struchkov.godfather.core.domain.Timer;
|
import dev.struchkov.godfather.core.domain.Timer;
|
||||||
import dev.struchkov.godfather.context.service.usercode.CheckData;
|
import org.slf4j.Logger;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -17,9 +18,10 @@ import java.util.TimerTask;
|
|||||||
*
|
*
|
||||||
* @author upagge [11/07/2019]
|
* @author upagge [11/07/2019]
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class TimerActionTask extends TimerTask {
|
public class TimerActionTask extends TimerTask {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TimerActionTask.class);
|
||||||
|
|
||||||
private final TimerService timerService;
|
private final TimerService timerService;
|
||||||
private final GeneralAutoResponder generalAutoresponder;
|
private final GeneralAutoResponder generalAutoresponder;
|
||||||
|
|
||||||
|
@ -2,19 +2,23 @@ package dev.struchkov.godfather.core.service.timer;
|
|||||||
|
|
||||||
import dev.struchkov.godfather.core.domain.Timer;
|
import dev.struchkov.godfather.core.domain.Timer;
|
||||||
import dev.struchkov.godfather.core.repository.TimerRepository;
|
import dev.struchkov.godfather.core.repository.TimerRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import org.slf4j.Logger;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class TimerServiceImpl implements TimerService {
|
public class TimerServiceImpl implements TimerService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TimerServiceImpl.class);
|
||||||
|
|
||||||
private final TimerRepository timerRepository;
|
private final TimerRepository timerRepository;
|
||||||
|
|
||||||
|
public TimerServiceImpl(TimerRepository timerRepository) {
|
||||||
|
this.timerRepository = timerRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public TimerRepository getTimerRepository() {
|
public TimerRepository getTimerRepository() {
|
||||||
return timerRepository;
|
return timerRepository;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package dev.struchkov.godfather.core.utils;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Pair<K, D> {
|
|
||||||
|
|
||||||
private K key;
|
|
||||||
private D value;
|
|
||||||
|
|
||||||
}
|
|
@ -1,95 +1,95 @@
|
|||||||
package dev.struchkov.godfather.core.utils;
|
//package dev.struchkov.godfather.core.utils;
|
||||||
|
//
|
||||||
import dev.struchkov.godfather.context.domain.BoxAnswer;
|
//import dev.struchkov.godfather.context.domain.BoxAnswer;
|
||||||
import dev.struchkov.godfather.context.utils.KeyBoards;
|
//import dev.struchkov.godfather.context.utils.KeyBoards;
|
||||||
import dev.struchkov.godfather.core.domain.question.Question;
|
//import dev.struchkov.godfather.core.domain.question.Question;
|
||||||
import dev.struchkov.godfather.core.domain.question.QuestionAnswer;
|
//import dev.struchkov.godfather.core.domain.question.QuestionAnswer;
|
||||||
import dev.struchkov.godfather.core.domain.question.QuestionResult;
|
//import dev.struchkov.godfather.core.domain.question.QuestionResult;
|
||||||
import dev.struchkov.godfather.core.domain.unit.AnswerSave;
|
//import dev.struchkov.godfather.core.domain.unit.AnswerSave;
|
||||||
import dev.struchkov.godfather.core.domain.unit.AnswerText;
|
//import dev.struchkov.godfather.core.domain.unit.AnswerText;
|
||||||
import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
//import dev.struchkov.godfather.core.domain.unit.MainUnit;
|
||||||
import dev.struchkov.godfather.core.domain.unit.UnitActiveType;
|
//import dev.struchkov.godfather.core.domain.unit.UnitActiveType;
|
||||||
import dev.struchkov.godfather.core.service.save.Preservable;
|
//import dev.struchkov.godfather.core.service.save.Preservable;
|
||||||
import dev.struchkov.godfather.core.service.save.push.Pusher;
|
//import dev.struchkov.godfather.core.service.save.push.Pusher;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Утилита для быстрой генерации цепочки Unit-ов, образующих сценарий "Тестирование".
|
// * Утилита для быстрой генерации цепочки Unit-ов, образующих сценарий "Тестирование".
|
||||||
*
|
// *
|
||||||
* @author upagge [14/07/2019]
|
// * @author upagge [14/07/2019]
|
||||||
*/
|
// */
|
||||||
public class QuestionUtils {
|
//public class QuestionUtils {
|
||||||
|
//
|
||||||
private final Preservable<QuestionResult> preservable;
|
// private final Preservable<QuestionResult> preservable;
|
||||||
private final List<Question> questions;
|
// private final List<Question> questions;
|
||||||
private Pusher<QuestionResult> pusher;
|
// private Pusher<QuestionResult> pusher;
|
||||||
|
//
|
||||||
private QuestionUtils(List<Question> questions, Preservable<QuestionResult> preservable) {
|
// private QuestionUtils(List<Question> questions, Preservable<QuestionResult> preservable) {
|
||||||
this.questions = questions;
|
// this.questions = questions;
|
||||||
this.preservable = preservable;
|
// this.preservable = preservable;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private QuestionUtils(List<Question> questions, Preservable<QuestionResult> preservable, Pusher<QuestionResult> pusher) {
|
// private QuestionUtils(List<Question> questions, Preservable<QuestionResult> preservable, Pusher<QuestionResult> pusher) {
|
||||||
this.questions = questions;
|
// this.questions = questions;
|
||||||
this.preservable = preservable;
|
// this.preservable = preservable;
|
||||||
this.pusher = pusher;
|
// this.pusher = pusher;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static QuestionUtils builder(Preservable<QuestionResult> preservable, List<Question> questions) {
|
// public static QuestionUtils builder(Preservable<QuestionResult> preservable, List<Question> questions) {
|
||||||
return new QuestionUtils(questions, preservable);
|
// return new QuestionUtils(questions, preservable);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static QuestionUtils builder(Preservable<QuestionResult> preservable, Pusher<QuestionResult> pusher, List<Question> list) {
|
// public static QuestionUtils builder(Preservable<QuestionResult> preservable, Pusher<QuestionResult> pusher, List<Question> list) {
|
||||||
return new QuestionUtils(list, preservable, pusher);
|
// return new QuestionUtils(list, preservable, pusher);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public MainUnit build(MainUnit finishUnit) {
|
// public MainUnit build(MainUnit finishUnit) {
|
||||||
return generateTest(finishUnit);
|
// return generateTest(finishUnit);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public MainUnit build() {
|
// public MainUnit build() {
|
||||||
return generateTest(null);
|
// return generateTest(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private MainUnit generateTest(MainUnit finishUnit) {
|
// private MainUnit generateTest(MainUnit finishUnit) {
|
||||||
AnswerText previousUnit = null;
|
// AnswerText previousUnit = null;
|
||||||
for (int i = questions.size() - 1; i >= 0; i--) {
|
// for (int i = questions.size() - 1; i >= 0; i--) {
|
||||||
Question question = this.questions.get(i);
|
// Question question = this.questions.get(i);
|
||||||
List<String> collectAnswer = question.getQuestionAnswers().stream()
|
// List<String> collectAnswer = question.getQuestionAnswers().stream()
|
||||||
.map(QuestionAnswer::getText)
|
// .map(QuestionAnswer::getText)
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
BoxAnswer boxAnswer = question.getBoxAnswer().toBuilder()
|
// BoxAnswer boxAnswer = question.getBoxAnswer().toBuilder()
|
||||||
.keyBoard(KeyBoards.verticalDuoMenuString(collectAnswer)).build();
|
// .keyBoard(KeyBoards.verticalDuoMenuString(collectAnswer)).build();
|
||||||
|
//
|
||||||
AnswerText.AnswerTextBuilder answerTextBuilder = AnswerText.builder()
|
// AnswerText.Builder answerTextBuilder = AnswerText.builder()
|
||||||
.boxAnswer(message -> boxAnswer);
|
// .boxAnswer(message -> boxAnswer);
|
||||||
|
//
|
||||||
for (QuestionAnswer questionAnswer : question.getQuestionAnswers()) {
|
// for (QuestionAnswer questionAnswer : question.getQuestionAnswers()) {
|
||||||
AnswerSave.AnswerSaveBuilder answerSaveBuilder = AnswerSave.<QuestionResult>builder()
|
// AnswerSave.AnswerSaveBuilder answerSaveBuilder = AnswerSave.<QuestionResult>builder()
|
||||||
.preservable(preservable)
|
// .preservable(preservable)
|
||||||
.preservableData(
|
// .preservableData(
|
||||||
message -> new QuestionResult(
|
// message -> new QuestionResult(
|
||||||
question.getBoxAnswer().getMessage(),
|
// question.getBoxAnswer().getMessage(),
|
||||||
questionAnswer.getText(),
|
// questionAnswer.getText(),
|
||||||
questionAnswer.getPoints()
|
// questionAnswer.getPoints()
|
||||||
)
|
// )
|
||||||
)
|
// )
|
||||||
.phrase(questionAnswer.getText());
|
// .phrase(questionAnswer.getText());
|
||||||
if (i != this.questions.size() - 1) {
|
// if (i != this.questions.size() - 1) {
|
||||||
answerSaveBuilder.nextUnit(previousUnit).build();
|
// answerSaveBuilder.nextUnit(previousUnit).build();
|
||||||
} else {
|
// } else {
|
||||||
answerSaveBuilder.pusher(pusher);
|
// answerSaveBuilder.pusher(pusher);
|
||||||
Optional.of(finishUnit).ifPresent(answerSaveBuilder::nextUnit);
|
// Optional.of(finishUnit).ifPresent(answerSaveBuilder::nextUnit);
|
||||||
}
|
// }
|
||||||
answerTextBuilder.nextUnit(answerSaveBuilder.build());
|
// answerTextBuilder.nextUnit(answerSaveBuilder.build());
|
||||||
}
|
// }
|
||||||
if (i == 0) answerTextBuilder.activeType(UnitActiveType.AFTER);
|
// if (i == 0) answerTextBuilder.activeType(UnitActiveType.AFTER);
|
||||||
previousUnit = answerTextBuilder.build();
|
// previousUnit = answerTextBuilder.build();
|
||||||
}
|
// }
|
||||||
return previousUnit;
|
// return previousUnit;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
66
pom.xml
66
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.4-SNAPSHOT</version>
|
<version>0.0.4</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@ -32,41 +32,46 @@
|
|||||||
<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.context.ver>0.0.4-SNAPSHOT</godfather.context.ver>
|
<godfather.ver>0.0.4</godfather.ver>
|
||||||
<godfather.core.ver>0.0.4-SNAPSHOT</godfather.core.ver>
|
|
||||||
<autoresponder.ver>1.9.4-RELEASE</autoresponder.ver>
|
<godfather.context.ver>${godfather.ver}</godfather.context.ver>
|
||||||
|
<godfather.core.ver>${godfather.ver}</godfather.core.ver>
|
||||||
|
|
||||||
|
<autoresponder.ver>2.0.0</autoresponder.ver>
|
||||||
|
<haiti.utils>1.0.2</haiti.utils>
|
||||||
|
|
||||||
<gson.ver>2.9.0</gson.ver>
|
|
||||||
<mail.ver>1.6.2</mail.ver>
|
|
||||||
<lombok.ver>1.18.22</lombok.ver>
|
|
||||||
<javax.persistence.api.ver>2.2</javax.persistence.api.ver>
|
<javax.persistence.api.ver>2.2</javax.persistence.api.ver>
|
||||||
<validation.api.ver>2.0.1.Final</validation.api.ver>
|
<validation.api.ver>2.0.1.Final</validation.api.ver>
|
||||||
<slf4j.api.ver>1.7.36</slf4j.api.ver>
|
<slf4j.api.ver>1.7.36</slf4j.api.ver>
|
||||||
|
<jetbrains.annotations.ver>23.0.0</jetbrains.annotations.ver>
|
||||||
|
|
||||||
<plugin.maven.compiler.ver>3.9.0</plugin.maven.compiler.ver>
|
<plugin.maven.compiler.ver>3.10.1</plugin.maven.compiler.ver>
|
||||||
<plugin.nexus.staging.ver>1.6.12</plugin.nexus.staging.ver>
|
<plugin.nexus.staging.ver>1.6.13</plugin.nexus.staging.ver>
|
||||||
<plugin.maven.source.ver>3.2.1</plugin.maven.source.ver>
|
<plugin.maven.source.ver>3.2.1</plugin.maven.source.ver>
|
||||||
<plugin.maven.javadoc.ver>3.3.2</plugin.maven.javadoc.ver>
|
<plugin.maven.javadoc.ver>3.4.0</plugin.maven.javadoc.ver>
|
||||||
<plugin.maven.gpg.ver>3.0.1</plugin.maven.gpg.ver>
|
<plugin.maven.gpg.ver>3.0.1</plugin.maven.gpg.ver>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>dev.struchkov.godfather</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>bot-context</artifactId>
|
||||||
<version>${gson.ver}</version>
|
<version>${godfather.core.ver}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.struchkov</groupId>
|
||||||
|
<artifactId>autoresponder</artifactId>
|
||||||
|
<version>${autoresponder.ver}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.mail</groupId>
|
<groupId>dev.struchkov.haiti</groupId>
|
||||||
<artifactId>javax.mail-api</artifactId>
|
<artifactId>haiti-utils</artifactId>
|
||||||
<version>${mail.ver}</version>
|
<version>${haiti.utils}</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.ver}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.persistence</groupId>
|
<groupId>javax.persistence</groupId>
|
||||||
<artifactId>javax.persistence-api</artifactId>
|
<artifactId>javax.persistence-api</artifactId>
|
||||||
@ -78,15 +83,9 @@
|
|||||||
<version>${validation.api.ver}</version>
|
<version>${validation.api.ver}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.struchkov.godfather</groupId>
|
<groupId>org.jetbrains</groupId>
|
||||||
<artifactId>bot-context</artifactId>
|
<artifactId>annotations</artifactId>
|
||||||
<version>${godfather.core.ver}</version>
|
<version>${jetbrains.annotations.ver}</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.sadtech.autoresponder</groupId>
|
|
||||||
<artifactId>autoresponder</artifactId>
|
|
||||||
<version>${autoresponder.ver}</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -118,13 +117,6 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.ver}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
Loading…
Reference in New Issue
Block a user