Первая рабочая версия с lombok и javadoc
This commit is contained in:
parent
5d80ce8faf
commit
ad9a47d837
14
pom.xml
14
pom.xml
@ -4,9 +4,9 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.sadtech.bot</groupId>
|
<groupId>org.sadtech.social</groupId>
|
||||||
<artifactId>bot-core</artifactId>
|
<artifactId>social-core</artifactId>
|
||||||
<version>0.6.2-RELEASE</version>
|
<version>0.6.3-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -26,7 +26,6 @@
|
|||||||
<gson.ver>2.8.5</gson.ver>
|
<gson.ver>2.8.5</gson.ver>
|
||||||
<slf4j.ver>1.7.26</slf4j.ver>
|
<slf4j.ver>1.7.26</slf4j.ver>
|
||||||
<mail.ver>1.4</mail.ver>
|
<mail.ver>1.4</mail.ver>
|
||||||
<junit.ver>4.12</junit.ver>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -35,6 +34,7 @@
|
|||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>${gson.ver}</version>
|
<version>${gson.ver}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
@ -48,9 +48,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${junit.ver}</version>
|
<version>1.18.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content;
|
|
||||||
|
|
||||||
public class BoardComment extends Comment {
|
|
||||||
|
|
||||||
public BoardComment() {
|
|
||||||
type = ContentType.BOARD_COMMENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public abstract class Comment extends Message {
|
|
||||||
|
|
||||||
private Integer contentId;
|
|
||||||
|
|
||||||
public Integer getContentId() {
|
|
||||||
return contentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContentId(Integer contentId) {
|
|
||||||
this.contentId = contentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof Comment)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
Comment that = (Comment) o;
|
|
||||||
return Objects.equals(contentId, that.contentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), contentId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content;
|
|
||||||
|
|
||||||
public enum ContentType {
|
|
||||||
|
|
||||||
MAIL, BOARD_COMMENT, EMPTY
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.exception.AppBotException;
|
|
||||||
|
|
||||||
public class EmptyMessage extends Message {
|
|
||||||
|
|
||||||
public EmptyMessage() {
|
|
||||||
type = ContentType.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMessage(String message) {
|
|
||||||
throw new AppBotException(0, "EmptyMessage no setMessage");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.attachment.Attachment;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Mail extends Message {
|
|
||||||
|
|
||||||
private List<Attachment> attachments;
|
|
||||||
|
|
||||||
public Mail() {
|
|
||||||
type = ContentType.MAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mail(Mail source) {
|
|
||||||
super(source);
|
|
||||||
this.attachments = source.getAttachments();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Mail prototype() {
|
|
||||||
return new Mail(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Attachment> getAttachments() {
|
|
||||||
return attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAttachments(List<Attachment> attachments) {
|
|
||||||
this.attachments = attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof Mail)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
Mail mail = (Mail) o;
|
|
||||||
return Objects.equals(attachments, mail.attachments);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), attachments);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Mail{" +
|
|
||||||
"attachments=" + attachments +
|
|
||||||
", type=" + type +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public abstract class Message {
|
|
||||||
|
|
||||||
private Integer id;
|
|
||||||
protected ContentType type;
|
|
||||||
private LocalDateTime createDate;
|
|
||||||
private Integer personId;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public Message() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Message(Message source) {
|
|
||||||
this.personId = source.getPersonId();
|
|
||||||
this.message = source.getMessage();
|
|
||||||
this.createDate = source.getCreateDate();
|
|
||||||
this.id = source.getPersonId();
|
|
||||||
this.type = source.getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPersonId() {
|
|
||||||
return personId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPersonId(Integer personId) {
|
|
||||||
this.personId = personId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDateTime getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreateDate(LocalDateTime createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContentType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(ContentType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof Message)) return false;
|
|
||||||
Message message = (Message) o;
|
|
||||||
return Objects.equals(id, message.id) &&
|
|
||||||
type == message.type &&
|
|
||||||
Objects.equals(createDate, message.createDate) &&
|
|
||||||
Objects.equals(personId, message.personId) &&
|
|
||||||
Objects.equals(this.message, message.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, type, createDate, personId, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Message{" +
|
|
||||||
"id=" + id +
|
|
||||||
", type=" + type +
|
|
||||||
", createDate=" + createDate +
|
|
||||||
", personId=" + personId +
|
|
||||||
", message='" + message + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content.attachment;
|
|
||||||
|
|
||||||
public abstract class Attachment {
|
|
||||||
|
|
||||||
protected AttachmentType type;
|
|
||||||
|
|
||||||
public AttachmentType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content.attachment;
|
|
||||||
|
|
||||||
public enum AttachmentType {
|
|
||||||
|
|
||||||
AUDIO_MESSAGE, GEO
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content.attachment;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class AudioMessage extends Attachment {
|
|
||||||
|
|
||||||
private URL linkOdd;
|
|
||||||
|
|
||||||
public AudioMessage() {
|
|
||||||
type = AttachmentType.AUDIO_MESSAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL getLinkOdd() {
|
|
||||||
return linkOdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLinkOdd(URL linkOdd) {
|
|
||||||
this.linkOdd = linkOdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof AudioMessage)) return false;
|
|
||||||
AudioMessage that = (AudioMessage) o;
|
|
||||||
return Objects.equals(linkOdd, that.linkOdd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(linkOdd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "AudioMessage{" +
|
|
||||||
"linkOdd=" + linkOdd +
|
|
||||||
", type=" + type +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content.attachment;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Geo extends Attachment {
|
|
||||||
|
|
||||||
private GeoCoordinate geoCoordinate;
|
|
||||||
private String country;
|
|
||||||
private String city;
|
|
||||||
|
|
||||||
private Geo() {
|
|
||||||
type = AttachmentType.GEO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GeoCoordinate getGeoCoordinate() {
|
|
||||||
return geoCoordinate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCountry() {
|
|
||||||
return country;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCity() {
|
|
||||||
return city;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new Geo().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
private Builder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder coordinate(Float lat, Float aLong) {
|
|
||||||
Geo.this.geoCoordinate = new GeoCoordinate(lat, aLong);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder country(String countryName) {
|
|
||||||
Geo.this.country = countryName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder city(String cityName) {
|
|
||||||
Geo.this.city = cityName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Geo build() {
|
|
||||||
return Geo.this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof Geo)) return false;
|
|
||||||
Geo geo = (Geo) o;
|
|
||||||
return Objects.equals(geoCoordinate, geo.geoCoordinate) &&
|
|
||||||
Objects.equals(country, geo.country) &&
|
|
||||||
Objects.equals(city, geo.city);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(geoCoordinate, country, city);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Geo{" +
|
|
||||||
"geoCoordinate=" + geoCoordinate +
|
|
||||||
", country='" + country + '\'' +
|
|
||||||
", city='" + city + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.content.attachment;
|
|
||||||
|
|
||||||
public class GeoCoordinate {
|
|
||||||
|
|
||||||
private Float latitude;
|
|
||||||
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,7 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard;
|
|
||||||
|
|
||||||
public enum ButtonColor {
|
|
||||||
|
|
||||||
PRIMARY, DEFAULT, NEGATIVE, POSITIVE
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard;
|
|
||||||
|
|
||||||
public enum ButtonType {
|
|
||||||
|
|
||||||
TEXT, ACCOUNT
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class KeyBoard {
|
|
||||||
|
|
||||||
private List<KeyBoardLine> keyBoardLines = new ArrayList<>();
|
|
||||||
private boolean oneTime = true;
|
|
||||||
|
|
||||||
private KeyBoard() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<KeyBoardLine> getKeyBoardLines() {
|
|
||||||
return keyBoardLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOneTime() {
|
|
||||||
return oneTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new KeyBoard().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder lineKeyBoard(KeyBoardLine keyBoardLine) {
|
|
||||||
KeyBoard.this.keyBoardLines.add(keyBoardLine);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder oneTime(boolean oneTime) {
|
|
||||||
KeyBoard.this.oneTime = oneTime;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyBoard build() {
|
|
||||||
return KeyBoard.this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof KeyBoard)) return false;
|
|
||||||
KeyBoard keyBoard = (KeyBoard) o;
|
|
||||||
return oneTime == keyBoard.oneTime &&
|
|
||||||
Objects.equals(keyBoardLines, keyBoard.keyBoardLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(keyBoardLines, oneTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "KeyBoard{" +
|
|
||||||
"keyBoardLines=" + keyBoardLines +
|
|
||||||
", oneTime=" + oneTime +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public abstract class KeyBoardButton {
|
|
||||||
|
|
||||||
protected String payload;
|
|
||||||
protected ButtonType type = ButtonType.TEXT;
|
|
||||||
|
|
||||||
public String getPayload() {
|
|
||||||
return payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPayload(String payload) {
|
|
||||||
this.payload = payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ButtonType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(ButtonType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof KeyBoardButton)) return false;
|
|
||||||
KeyBoardButton that = (KeyBoardButton) o;
|
|
||||||
return Objects.equals(payload, that.payload) &&
|
|
||||||
type == that.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(payload, type);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class KeyBoardLine {
|
|
||||||
|
|
||||||
private List<KeyBoardButton> keyBoardButtons = new ArrayList<>();
|
|
||||||
|
|
||||||
private KeyBoardLine() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<KeyBoardButton> getKeyBoardButtons() {
|
|
||||||
return keyBoardButtons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new KeyBoardLine().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder buttonKeyBoard(KeyBoardButton keyBoardButton) {
|
|
||||||
KeyBoardLine.this.keyBoardButtons.add(keyBoardButton);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyBoardLine build() {
|
|
||||||
return KeyBoardLine.this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof KeyBoardLine)) return false;
|
|
||||||
KeyBoardLine that = (KeyBoardLine) o;
|
|
||||||
return Objects.equals(keyBoardButtons, that.keyBoardButtons);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(keyBoardButtons);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "KeyBoardLine{" +
|
|
||||||
"keyBoardButtons=" + keyBoardButtons +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard.button;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.keyboard.ButtonType;
|
|
||||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class KeyBoardButtonAccount extends KeyBoardButton {
|
|
||||||
|
|
||||||
private Integer amount;
|
|
||||||
private Integer accountId;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private KeyBoardButtonAccount() {
|
|
||||||
type = ButtonType.ACCOUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAmount() {
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getAccountId() {
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new KeyBoardButtonAccount().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
private Builder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder amount(Integer amount) {
|
|
||||||
KeyBoardButtonAccount.this.amount = amount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder description(String description) {
|
|
||||||
KeyBoardButtonAccount.this.description = description;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder accountId(Integer accountId) {
|
|
||||||
KeyBoardButtonAccount.this.accountId = accountId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public KeyBoardButtonAccount build() {
|
|
||||||
return KeyBoardButtonAccount.this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof KeyBoardButtonAccount)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
KeyBoardButtonAccount that = (KeyBoardButtonAccount) o;
|
|
||||||
return Objects.equals(amount, that.amount) &&
|
|
||||||
Objects.equals(description, that.description);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), amount, description);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.keyboard.button;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.keyboard.ButtonColor;
|
|
||||||
import org.sadtech.bot.core.domain.keyboard.ButtonType;
|
|
||||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class KeyBoardButtonText extends KeyBoardButton {
|
|
||||||
|
|
||||||
private String label;
|
|
||||||
private ButtonColor color = ButtonColor.DEFAULT;
|
|
||||||
|
|
||||||
public KeyBoardButtonText() {
|
|
||||||
type = ButtonType.TEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ButtonColor getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder builder() {
|
|
||||||
return new KeyBoardButtonText().new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder {
|
|
||||||
private Builder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder label(String label) {
|
|
||||||
KeyBoardButtonText.this.label = label;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder color(ButtonColor color) {
|
|
||||||
KeyBoardButtonText.this.color = color;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder payload(String payload) {
|
|
||||||
KeyBoardButtonText.this.payload = payload;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KeyBoardButtonText build() {
|
|
||||||
return KeyBoardButtonText.this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof KeyBoardButtonText)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
KeyBoardButtonText that = (KeyBoardButtonText) o;
|
|
||||||
return Objects.equals(label, that.label) &&
|
|
||||||
color == that.color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(super.hashCode(), label, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "KeyBoardButtonText{" +
|
|
||||||
"label='" + label + '\'' +
|
|
||||||
", color=" + color +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.money;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Account {
|
|
||||||
|
|
||||||
private Integer id;
|
|
||||||
private Integer totalSum;
|
|
||||||
private Integer belongsPersonId;
|
|
||||||
private Integer extinguishedPersonId;
|
|
||||||
private String description;
|
|
||||||
private AccountStatus accountStatus;
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getTotalSum() {
|
|
||||||
return totalSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalSum(Integer totalSum) {
|
|
||||||
this.totalSum = totalSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getBelongsPersonId() {
|
|
||||||
return belongsPersonId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBelongsPersonId(Integer belongsPersonId) {
|
|
||||||
this.belongsPersonId = belongsPersonId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccountStatus getAccountStatus() {
|
|
||||||
return accountStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountStatus(AccountStatus accountStatus) {
|
|
||||||
this.accountStatus = accountStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getExtinguishedPersonId() {
|
|
||||||
return extinguishedPersonId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExtinguishedPersonId(Integer extinguishedPersonId) {
|
|
||||||
this.extinguishedPersonId = extinguishedPersonId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof Account)) return false;
|
|
||||||
Account account = (Account) o;
|
|
||||||
return Objects.equals(id, account.id) &&
|
|
||||||
Objects.equals(totalSum, account.totalSum) &&
|
|
||||||
Objects.equals(belongsPersonId, account.belongsPersonId) &&
|
|
||||||
Objects.equals(extinguishedPersonId, account.extinguishedPersonId) &&
|
|
||||||
Objects.equals(description, account.description) &&
|
|
||||||
accountStatus == account.accountStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, totalSum, belongsPersonId, extinguishedPersonId, description, accountStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Account{" +
|
|
||||||
"id=" + id +
|
|
||||||
", totalSum=" + totalSum +
|
|
||||||
", belongsPersonId=" + belongsPersonId +
|
|
||||||
", extinguishedPersonId=" + extinguishedPersonId +
|
|
||||||
", description='" + description + '\'' +
|
|
||||||
", accountStatus=" + accountStatus +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package org.sadtech.bot.core.domain.money;
|
|
||||||
|
|
||||||
public enum AccountStatus {
|
|
||||||
|
|
||||||
EXPOSED, CLOSED, CANCELLED, EXCEPTION
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package org.sadtech.bot.core.exception;
|
|
||||||
|
|
||||||
public class TimerSettingExceprion extends AppBotException {
|
|
||||||
|
|
||||||
public TimerSettingExceprion(String message) {
|
|
||||||
super(54, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package org.sadtech.bot.core.repository;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.money.Account;
|
|
||||||
|
|
||||||
public interface AccountRepository {
|
|
||||||
|
|
||||||
Integer add(Account account);
|
|
||||||
|
|
||||||
void edit(Integer accountId, Account account);
|
|
||||||
|
|
||||||
Account findById(Integer accountId);
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package org.sadtech.bot.core.repository;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.Message;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ContentRepository<T extends Message> {
|
|
||||||
|
|
||||||
Integer add(T content);
|
|
||||||
|
|
||||||
List<T> findByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package org.sadtech.bot.core.repository;
|
|
||||||
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
public interface EventRepository<T> {
|
|
||||||
|
|
||||||
void add(T dataObject);
|
|
||||||
|
|
||||||
void cleanAll();
|
|
||||||
|
|
||||||
Queue<T> getEventQueue();
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package org.sadtech.bot.core.service;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.money.Account;
|
|
||||||
|
|
||||||
public interface AccountService {
|
|
||||||
|
|
||||||
Integer add(Account account);
|
|
||||||
|
|
||||||
Boolean pay(Integer accountId, Integer extinguishedPersonId, Integer sum);
|
|
||||||
|
|
||||||
Boolean paymentVerification(Integer accountId);
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package org.sadtech.bot.core.service;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.BoardComment;
|
|
||||||
|
|
||||||
public interface BoardCommentService extends ContentService<BoardComment> {
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package org.sadtech.bot.core.service;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.Message;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ContentService<T extends Message> {
|
|
||||||
|
|
||||||
void add(T event);
|
|
||||||
|
|
||||||
List<T> getByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
|
||||||
|
|
||||||
List<T> getLastEventByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package org.sadtech.bot.core.service;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.Message;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Filter<T extends Message> {
|
|
||||||
|
|
||||||
void processing(T content);
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package org.sadtech.bot.core.service;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.Mail;
|
|
||||||
|
|
||||||
public interface MailService extends ContentService<Mail> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package org.sadtech.bot.core.service.sender;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.BoxAnswer;
|
|
||||||
|
|
||||||
public interface Sent {
|
|
||||||
|
|
||||||
void send(Integer personId, BoxAnswer boxAnswer);
|
|
||||||
|
|
||||||
void send(Integer contentId, Integer personId, BoxAnswer boxAnswer);
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package org.sadtech.bot.core.utils;
|
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.EmptyMessage;
|
|
||||||
|
|
||||||
public class Contents {
|
|
||||||
|
|
||||||
private Contents() {
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final EmptyMessage EMPTY_CONTENT = new EmptyMessage();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +1,32 @@
|
|||||||
package org.sadtech.bot.core.domain;
|
package org.sadtech.social.core.domain;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.attachment.GeoCoordinate;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.sadtech.bot.core.domain.keyboard.KeyBoard;
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
import java.util.Objects;
|
import org.sadtech.social.core.domain.content.attachment.GeoCoordinate;
|
||||||
|
import org.sadtech.social.core.domain.keyboard.KeyBoard;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Контейнер, которые содержит данные, которые будут отправлены пользователю как ответ на его запрос.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString
|
||||||
|
@Getter
|
||||||
public class BoxAnswer {
|
public class BoxAnswer {
|
||||||
|
|
||||||
|
@Description("Обычное текстовое сообщение")
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
@Description("Клавиатура - меню")
|
||||||
private KeyBoard keyboard;
|
private KeyBoard keyboard;
|
||||||
|
|
||||||
|
@Description("Географические координаты")
|
||||||
private GeoCoordinate coordinates;
|
private GeoCoordinate coordinates;
|
||||||
|
|
||||||
|
@Description("Идентификатор стикера")
|
||||||
private Integer stickerId;
|
private Integer stickerId;
|
||||||
|
|
||||||
private BoxAnswer() {
|
private BoxAnswer() {
|
||||||
@ -25,27 +42,10 @@ public class BoxAnswer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyBoard getKeyboard() {
|
|
||||||
return keyboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GeoCoordinate getCoordinates() {
|
|
||||||
return coordinates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStickerId() {
|
|
||||||
return stickerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BoxAnswer prototype() {
|
public BoxAnswer prototype() {
|
||||||
return new BoxAnswer(this);
|
return new BoxAnswer(this);
|
||||||
}
|
}
|
||||||
@ -84,29 +84,4 @@ public class BoxAnswer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof BoxAnswer)) return false;
|
|
||||||
BoxAnswer boxAnswer = (BoxAnswer) o;
|
|
||||||
return Objects.equals(message, boxAnswer.message) &&
|
|
||||||
Objects.equals(keyboard, boxAnswer.keyboard) &&
|
|
||||||
Objects.equals(coordinates, boxAnswer.coordinates) &&
|
|
||||||
Objects.equals(stickerId, boxAnswer.stickerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(message, keyboard, coordinates, stickerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BoxAnswer{" +
|
|
||||||
"message='" + message + '\'' +
|
|
||||||
", keyboard=" + keyboard +
|
|
||||||
", coordinates=" + coordinates +
|
|
||||||
", stickerId=" + stickerId +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.sadtech.social.core.domain.content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сообщение от пользователя типа "Комментарий к обсуждению группы".
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public class BoardComment extends Comment {
|
||||||
|
|
||||||
|
public BoardComment() {
|
||||||
|
type = ContentType.BOARD_COMMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.sadtech.social.core.domain.content;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Абстрактная сущность для сообщений от пользователей с привязкой к какому-то контенту (картинка, видео).
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public abstract class Comment extends Message {
|
||||||
|
|
||||||
|
@Description("Идентификатор контента, к которому ставлено сообщение")
|
||||||
|
private Integer contentId;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package org.sadtech.social.core.domain.content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тип сообщения от пользователя {@link Message}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public enum ContentType {
|
||||||
|
|
||||||
|
MAIL, BOARD_COMMENT, EMPTY
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package org.sadtech.social.core.domain.content;
|
||||||
|
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.exception.AppBotException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Заглушка для сообщения от пользователя.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@ToString
|
||||||
|
public class EmptyMessage extends Message {
|
||||||
|
|
||||||
|
public EmptyMessage() {
|
||||||
|
type = ContentType.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setText(String text) {
|
||||||
|
throw new AppBotException(0, "EmptyMessage no setText");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package org.sadtech.social.core.domain.content;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.sadtech.social.core.domain.content.attachment.Attachment;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сообщение от пользователя типа "Личное сообщение".
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class Mail extends Message {
|
||||||
|
|
||||||
|
@Description("Вложения к сообщению")
|
||||||
|
private List<Attachment> attachments;
|
||||||
|
|
||||||
|
public Mail() {
|
||||||
|
type = ContentType.MAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mail(Mail source) {
|
||||||
|
super(source);
|
||||||
|
this.attachments = source.getAttachments();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Mail prototype() {
|
||||||
|
return new Mail(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package org.sadtech.social.core.domain.content;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Аьстрактная сущность - Сообщение от пользователя.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public abstract class Message {
|
||||||
|
|
||||||
|
@Description("Идентификатор сообщения")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Description("Тип сообщения")
|
||||||
|
protected ContentType type;
|
||||||
|
|
||||||
|
@Description("Дата создания")
|
||||||
|
private LocalDateTime createDate;
|
||||||
|
|
||||||
|
@Description("Идентификатор пользователя, отправившего сообщение")
|
||||||
|
private Integer personId;
|
||||||
|
|
||||||
|
@Description("Текстовое сообщение")
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
public Message() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Message(Message source) {
|
||||||
|
this.personId = source.getPersonId();
|
||||||
|
this.text = source.getText();
|
||||||
|
this.createDate = source.getCreateDate();
|
||||||
|
this.id = source.getPersonId();
|
||||||
|
this.type = source.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package org.sadtech.social.core.domain.content.attachment;
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Абстрактная сущность, для всех вложений к сообщениям от пользователей.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public abstract class Attachment {
|
||||||
|
|
||||||
|
@Description("Тип сущности")
|
||||||
|
protected AttachmentType type;
|
||||||
|
|
||||||
|
public AttachmentType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.sadtech.social.core.domain.content.attachment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тип вложения {@link Attachment} к сообщению.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public enum AttachmentType {
|
||||||
|
|
||||||
|
AUDIO_MESSAGE,
|
||||||
|
GEO
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.sadtech.social.core.domain.content.attachment;
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Вложение типа "Аудиосообщение".
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString
|
||||||
|
@Setter
|
||||||
|
public class AudioMessage extends Attachment {
|
||||||
|
|
||||||
|
@Description("Ссылка на аудиозапись в формате odd")
|
||||||
|
private URL linkOdd;
|
||||||
|
|
||||||
|
public AudioMessage() {
|
||||||
|
type = AttachmentType.AUDIO_MESSAGE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package org.sadtech.social.core.domain.content.attachment;
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Вложение типа "Карта".
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString
|
||||||
|
public class Geo extends Attachment {
|
||||||
|
|
||||||
|
@Description("Географические координаты")
|
||||||
|
private GeoCoordinate geoCoordinate;
|
||||||
|
|
||||||
|
@Description("Название страны")
|
||||||
|
private String country;
|
||||||
|
|
||||||
|
@Description("Название города")
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
private Geo() {
|
||||||
|
type = AttachmentType.GEO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Geo().new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Builder {
|
||||||
|
private Builder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder coordinate(Float lat, Float aLong) {
|
||||||
|
Geo.this.geoCoordinate = new GeoCoordinate(lat, aLong);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder country(String countryName) {
|
||||||
|
Geo.this.country = countryName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder city(String cityName) {
|
||||||
|
Geo.this.city = cityName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Geo build() {
|
||||||
|
return Geo.this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package org.sadtech.social.core.domain.content.attachment;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сущность для хранения географических координат.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GeoCoordinate {
|
||||||
|
|
||||||
|
@Description("Широта")
|
||||||
|
private Float latitude;
|
||||||
|
@Description("Долгота")
|
||||||
|
private Float longitude;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Цвета кнопок на клавиатуре {@link KeyBoard}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public enum ButtonColor {
|
||||||
|
|
||||||
|
PRIMARY,
|
||||||
|
DEFAULT,
|
||||||
|
NEGATIVE,
|
||||||
|
POSITIVE
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тип кнопки на клавиатуре {@link KeyBoard}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public enum ButtonType {
|
||||||
|
|
||||||
|
TEXT,
|
||||||
|
ACCOUNT
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Singular;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сущность клавиатуры, для создания меню с вариантами выбора.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString
|
||||||
|
public class KeyBoard {
|
||||||
|
|
||||||
|
@Description("Строки меню")
|
||||||
|
@Singular(value = "lineKeyBoard")
|
||||||
|
private List<KeyBoardLine> keyBoardLines = new ArrayList<>();
|
||||||
|
|
||||||
|
@Description("Скрыть меню после ответа или нет")
|
||||||
|
private boolean oneTime = true;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Абстрактная сущность кнопки для клавиатуры.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString
|
||||||
|
@AllArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
public abstract class KeyBoardButton {
|
||||||
|
|
||||||
|
@Description("Скрытое сообщение, отправляемое по нажатию")
|
||||||
|
protected String payload;
|
||||||
|
|
||||||
|
@Description("Тип кнопки")
|
||||||
|
protected ButtonType type;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Singular;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Строка в меню клавиатуры {@link KeyBoard}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString
|
||||||
|
public class KeyBoardLine {
|
||||||
|
|
||||||
|
@Description("Кнопки в строке")
|
||||||
|
@Singular(value = "buttonKeyBoard")
|
||||||
|
private List<KeyBoardButton> keyBoardButtons = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard.button;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.domain.keyboard.ButtonType;
|
||||||
|
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Кнопка клавиатуры для оплаты счета.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString
|
||||||
|
public class KeyBoardButtonAccount extends KeyBoardButton {
|
||||||
|
|
||||||
|
@Description("Сумма к оплате")
|
||||||
|
private Integer amount;
|
||||||
|
|
||||||
|
@Description("Идентификатор счета")
|
||||||
|
private Integer accountId;
|
||||||
|
|
||||||
|
@Description("Описание")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
private KeyBoardButtonAccount(String payload, Integer amount, Integer accountId, String description) {
|
||||||
|
super(payload, ButtonType.ACCOUNT);
|
||||||
|
this.amount = amount;
|
||||||
|
this.accountId = accountId;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.sadtech.social.core.domain.keyboard.button;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.domain.keyboard.ButtonColor;
|
||||||
|
import org.sadtech.social.core.domain.keyboard.ButtonType;
|
||||||
|
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString
|
||||||
|
public class KeyBoardButtonText extends KeyBoardButton {
|
||||||
|
|
||||||
|
@Description("Надпись на кнопке")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@Description("Цвет кнопки")
|
||||||
|
private ButtonColor color;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
private KeyBoardButtonText(String payload, String label, ButtonColor color) {
|
||||||
|
super(payload, ButtonType.TEXT);
|
||||||
|
this.label = label;
|
||||||
|
this.color = (color != null) ? color : ButtonColor.DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package org.sadtech.social.core.domain.money;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.sadtech.social.core.utils.Description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сущность, которая отвечает за выставленный пользователю счет.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Account {
|
||||||
|
|
||||||
|
@Description("Идентификатор счета")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Description("Сумма к оплате")
|
||||||
|
private Integer totalSum;
|
||||||
|
|
||||||
|
@Description("Идентификатор пользователя, которому выставлен счет")
|
||||||
|
private Integer belongsPersonId;
|
||||||
|
|
||||||
|
@Description("Идентификатор пользователя, который оплатил счет")
|
||||||
|
private Integer extinguishedPersonId;
|
||||||
|
|
||||||
|
@Description("Описание платежа")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Description("Статус оплаты счета")
|
||||||
|
private AccountStatus accountStatus;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.sadtech.social.core.domain.money;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Состояние счета.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public enum AccountStatus {
|
||||||
|
|
||||||
|
EXPOSED,
|
||||||
|
CLOSED,
|
||||||
|
CANCELLED,
|
||||||
|
EXCEPTION
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,10 @@
|
|||||||
package org.sadtech.bot.core.exception;
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ошибка доступа к чему-либо.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class AccessException extends AppBotException {
|
public class AccessException extends AppBotException {
|
||||||
public AccessException(Integer code, String message) {
|
public AccessException(Integer code, String message) {
|
||||||
super(code, message);
|
super(code, message);
|
@ -1,7 +1,12 @@
|
|||||||
package org.sadtech.bot.core.exception;
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Родитель всех исключений библиотеки.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class AppBotException extends RuntimeException {
|
public class AppBotException extends RuntimeException {
|
||||||
|
|
||||||
private static final String TYPE = "ERROR";
|
private static final String TYPE = "ERROR";
|
@ -0,0 +1,12 @@
|
|||||||
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Исключения настройки бота.
|
||||||
|
*
|
||||||
|
* @author upagge [11/07/2019]
|
||||||
|
*/
|
||||||
|
public class ConfigAppException extends AppBotException {
|
||||||
|
public ConfigAppException(Integer code, String message) {
|
||||||
|
super(code, message);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,10 @@
|
|||||||
package org.sadtech.bot.core.exception;
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ошибки при отправке сообщений.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class MailSendException extends AppBotException {
|
public class MailSendException extends AppBotException {
|
||||||
|
|
||||||
public MailSendException() {
|
public MailSendException() {
|
@ -1,5 +1,10 @@
|
|||||||
package org.sadtech.bot.core.exception;
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ошибка, когда что-то не найдено.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class NotFoundException extends AppBotException {
|
public class NotFoundException extends AppBotException {
|
||||||
public NotFoundException(Integer code, String message) {
|
public NotFoundException(Integer code, String message) {
|
||||||
super(code, message);
|
super(code, message);
|
@ -1,5 +1,10 @@
|
|||||||
package org.sadtech.bot.core.exception;
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ошибка оплаты.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class PaymentException extends AppBotException {
|
public class PaymentException extends AppBotException {
|
||||||
|
|
||||||
public PaymentException(Integer code, String message) {
|
public PaymentException(Integer code, String message) {
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.sadtech.social.core.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ошибка таймера.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public class TimerSettingException extends AppBotException {
|
||||||
|
|
||||||
|
public TimerSettingException(String message) {
|
||||||
|
super(54, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.sadtech.social.core.repository;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.money.Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Репозиторий для взаимодействия с хранилищем счетов {@link Account}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface AccountRepository {
|
||||||
|
|
||||||
|
Integer add(Account account);
|
||||||
|
|
||||||
|
void edit(Integer accountId, Account account);
|
||||||
|
|
||||||
|
Account findById(Integer accountId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package org.sadtech.social.core.repository;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфейс взаимодействия со всеми наследниками текстовых запросов пользователей.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface ContentRepository<T extends Message> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Добавить сообщение в хранилище
|
||||||
|
*
|
||||||
|
* @param content Объект сообщени
|
||||||
|
* @return Идентификатор сообщения в хранилище
|
||||||
|
*/
|
||||||
|
Integer add(T content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить все сообщения за определенный временной диапазон
|
||||||
|
*
|
||||||
|
* @param timeFrom Начало временного диапазона
|
||||||
|
* @param timeTo Конец диапазона
|
||||||
|
* @return Список сообщений
|
||||||
|
*/
|
||||||
|
List<T> findByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.sadtech.social.core.repository;
|
||||||
|
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Обработка событий социальной сети.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface EventRepository<T> {
|
||||||
|
|
||||||
|
void add(T dataObject);
|
||||||
|
|
||||||
|
void cleanAll();
|
||||||
|
|
||||||
|
Queue<T> getEventQueue();
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package org.sadtech.bot.core.repository.impl;
|
package org.sadtech.social.core.repository.impl;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.money.Account;
|
import org.sadtech.social.core.domain.money.Account;
|
||||||
import org.sadtech.bot.core.exception.AccessException;
|
import org.sadtech.social.core.exception.AccessException;
|
||||||
import org.sadtech.bot.core.exception.NotFoundException;
|
import org.sadtech.social.core.exception.NotFoundException;
|
||||||
import org.sadtech.bot.core.exception.PaymentException;
|
import org.sadtech.social.core.exception.PaymentException;
|
||||||
import org.sadtech.bot.core.repository.AccountRepository;
|
import org.sadtech.social.core.repository.AccountRepository;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
@ -1,7 +1,7 @@
|
|||||||
package org.sadtech.bot.core.repository.impl;
|
package org.sadtech.social.core.repository.impl;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.BoardComment;
|
import org.sadtech.social.core.domain.content.BoardComment;
|
||||||
import org.sadtech.bot.core.repository.ContentRepository;
|
import org.sadtech.social.core.repository.ContentRepository;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -1,7 +1,7 @@
|
|||||||
package org.sadtech.bot.core.repository.impl;
|
package org.sadtech.social.core.repository.impl;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.sadtech.bot.core.repository.EventRepository;
|
import org.sadtech.social.core.repository.EventRepository;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
@ -1,7 +1,7 @@
|
|||||||
package org.sadtech.bot.core.repository.impl;
|
package org.sadtech.social.core.repository.impl;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.Mail;
|
import org.sadtech.social.core.domain.content.Mail;
|
||||||
import org.sadtech.bot.core.repository.ContentRepository;
|
import org.sadtech.social.core.repository.ContentRepository;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -0,0 +1,32 @@
|
|||||||
|
package org.sadtech.social.core.service;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.money.Account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфейс сервиса по работе с оплатой.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface AccountService {
|
||||||
|
|
||||||
|
Integer add(Account account);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Метод для оплаты счета
|
||||||
|
*
|
||||||
|
* @param accountId Идентификатор счета
|
||||||
|
* @param extinguishedPersonId Идентификатор пользователя, который внес оплату
|
||||||
|
* @param sum Сумма оплаты
|
||||||
|
* @return true - в случае успешной оплаты
|
||||||
|
*/
|
||||||
|
Boolean pay(Integer accountId, Integer extinguishedPersonId, Integer sum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверка оплаты счета
|
||||||
|
*
|
||||||
|
* @param accountId Идентификатор счета
|
||||||
|
* @return true - если счет оплачен
|
||||||
|
*/
|
||||||
|
Boolean paymentVerification(Integer accountId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package org.sadtech.social.core.service;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.content.BoardComment;
|
||||||
|
|
||||||
|
public interface BoardCommentService extends MessageService<BoardComment> {
|
||||||
|
}
|
16
src/main/java/org/sadtech/social/core/service/Filter.java
Normal file
16
src/main/java/org/sadtech/social/core/service/Filter.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package org.sadtech.social.core.service;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфес для изменения запроса пользователя перед тем, как он попадет в подсистему обработки.
|
||||||
|
* Например можно исправить опечатки, перевести сообщение на другой язык и так далее.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Filter<T extends Message> {
|
||||||
|
|
||||||
|
void processing(T content);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package org.sadtech.social.core.service;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.content.Mail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфейс для взаимодействия с личными сообщениями.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface MailService extends MessageService<Mail> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package org.sadtech.social.core.service;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфейс взаимодйствия с наследниками текстовых запросов пользователей.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface MessageService<T extends Message> {
|
||||||
|
|
||||||
|
void add(T event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить список сообщений за заданный временной интервал
|
||||||
|
* @param timeFrom Начало интервала
|
||||||
|
* @param timeTo Конец интервала
|
||||||
|
* @return Список сообщений
|
||||||
|
*/
|
||||||
|
List<T> getByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получить список ПОСЛЕДНИХ сообщений для каждого пользователя за заданных временной интервал
|
||||||
|
* @param timeFrom Начало интервала
|
||||||
|
* @param timeTo Конец интервала
|
||||||
|
* @return Список сообщений
|
||||||
|
*/
|
||||||
|
List<T> getLastEventByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,14 @@
|
|||||||
package org.sadtech.bot.core.service;
|
package org.sadtech.social.core.service;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфейс для взаимодействия с событиями социальной сети.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public interface RawEventService {
|
public interface RawEventService {
|
||||||
|
|
||||||
void cleanAll();
|
void cleanAll();
|
@ -1,10 +1,10 @@
|
|||||||
package org.sadtech.bot.core.service.impl;
|
package org.sadtech.social.core.service.impl;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.money.Account;
|
import org.sadtech.social.core.domain.money.Account;
|
||||||
import org.sadtech.bot.core.domain.money.AccountStatus;
|
import org.sadtech.social.core.domain.money.AccountStatus;
|
||||||
import org.sadtech.bot.core.exception.PaymentException;
|
import org.sadtech.social.core.exception.PaymentException;
|
||||||
import org.sadtech.bot.core.repository.AccountRepository;
|
import org.sadtech.social.core.repository.AccountRepository;
|
||||||
import org.sadtech.bot.core.service.AccountService;
|
import org.sadtech.social.core.service.AccountService;
|
||||||
|
|
||||||
public class AccountServiceImpl implements AccountService {
|
public class AccountServiceImpl implements AccountService {
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package org.sadtech.bot.core.service.impl;
|
package org.sadtech.social.core.service.impl;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.BoardComment;
|
import org.sadtech.social.core.domain.content.BoardComment;
|
||||||
import org.sadtech.bot.core.repository.ContentRepository;
|
import org.sadtech.social.core.repository.ContentRepository;
|
||||||
import org.sadtech.bot.core.service.BoardCommentService;
|
import org.sadtech.social.core.service.BoardCommentService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package org.sadtech.bot.core.service.impl;
|
package org.sadtech.social.core.service.impl;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.content.Mail;
|
import org.sadtech.social.core.domain.content.Mail;
|
||||||
import org.sadtech.bot.core.repository.ContentRepository;
|
import org.sadtech.social.core.repository.ContentRepository;
|
||||||
import org.sadtech.bot.core.service.MailService;
|
import org.sadtech.social.core.service.MailService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package org.sadtech.bot.core.service.impl;
|
package org.sadtech.social.core.service.impl;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.sadtech.bot.core.repository.EventRepository;
|
import org.sadtech.social.core.repository.EventRepository;
|
||||||
import org.sadtech.bot.core.service.RawEventService;
|
import org.sadtech.social.core.service.RawEventService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
package org.sadtech.bot.core.service.sender;
|
package org.sadtech.social.core.service.sender;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.BoxAnswer;
|
import org.sadtech.social.core.domain.BoxAnswer;
|
||||||
import org.sadtech.bot.core.domain.content.Comment;
|
import org.sadtech.social.core.domain.content.Comment;
|
||||||
import org.sadtech.bot.core.domain.content.Message;
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
public class SendBox {
|
public class SendBox {
|
||||||
|
|
||||||
private SendBox() {
|
private SendBox() {
|
||||||
|
throw new IllegalStateException("Утилитный класс");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sent(Message message, BoxAnswer boxAnswer, Sent sent) {
|
public static void sent(Message message, BoxAnswer boxAnswer, Sent sent) {
|
@ -0,0 +1,22 @@
|
|||||||
|
package org.sadtech.social.core.service.sender;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.BoxAnswer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Интерфейс для отправки ответов пользователю.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public interface Sent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Отрпавляет ответ пользователю
|
||||||
|
*
|
||||||
|
* @param personId Идентификатор пользователя
|
||||||
|
* @param boxAnswer Объект с данными, которые необходимо отправить
|
||||||
|
*/
|
||||||
|
void send(Integer personId, BoxAnswer boxAnswer);
|
||||||
|
|
||||||
|
void send(Integer contentId, Integer personId, BoxAnswer boxAnswer);
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.sadtech.bot.core.service.sender.email;
|
package org.sadtech.social.core.service.sender.email;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
@ -1,12 +1,17 @@
|
|||||||
package org.sadtech.bot.core.service.sender.email;
|
package org.sadtech.social.core.service.sender.email;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.BoxAnswer;
|
import org.sadtech.social.core.domain.BoxAnswer;
|
||||||
import org.sadtech.bot.core.exception.MailSendException;
|
import org.sadtech.social.core.exception.MailSendException;
|
||||||
import org.sadtech.bot.core.service.sender.Sent;
|
import org.sadtech.social.core.service.sender.Sent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.mail.*;
|
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.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
21
src/main/java/org/sadtech/social/core/utils/Description.java
Normal file
21
src/main/java/org/sadtech/social/core/utils/Description.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package org.sadtech.social.core.utils;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Используется для описания полей в классах.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface Description {
|
||||||
|
|
||||||
|
String value();
|
||||||
|
|
||||||
|
String example() default "";
|
||||||
|
|
||||||
|
}
|
@ -1,15 +1,27 @@
|
|||||||
package org.sadtech.bot.core.utils;
|
package org.sadtech.social.core.utils;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Класс для вставки слов в текстовую строку вместо подстрок - шаблонов маркеров.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class InsertWords {
|
public class InsertWords {
|
||||||
|
|
||||||
private InsertWords() {
|
private InsertWords() {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException("Утилитный класс");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Заменяет шаблон {n} в строке на слово из списка, где n - это порядковое число.
|
||||||
|
*
|
||||||
|
* @param text Текстовая строка
|
||||||
|
* @param words Список слов, которые необходимо поместить вместо шаблона
|
||||||
|
* @return Модифицированная строка
|
||||||
|
*/
|
||||||
public static String insert(String text, List<String> words) {
|
public static String insert(String text, List<String> words) {
|
||||||
Pattern pattern = Pattern.compile("\\{(\\d+)}");
|
Pattern pattern = Pattern.compile("\\{(\\d+)}");
|
||||||
Matcher m = pattern.matcher(text);
|
Matcher m = pattern.matcher(text);
|
@ -1,19 +1,29 @@
|
|||||||
package org.sadtech.bot.core.utils;
|
package org.sadtech.social.core.utils;
|
||||||
|
|
||||||
import org.sadtech.bot.core.domain.keyboard.ButtonColor;
|
import org.sadtech.social.core.domain.keyboard.ButtonColor;
|
||||||
import org.sadtech.bot.core.domain.keyboard.KeyBoard;
|
import org.sadtech.social.core.domain.keyboard.KeyBoard;
|
||||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
|
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
|
||||||
import org.sadtech.bot.core.domain.keyboard.KeyBoardLine;
|
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
|
||||||
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonText;
|
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Используется для быстрого создания клавиаутр {@link KeyBoard}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
public class KeyBoards {
|
public class KeyBoards {
|
||||||
|
|
||||||
private KeyBoards() {
|
private KeyBoards() {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру формата 1х2, с кнопками "Да | Нет"
|
||||||
|
*
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
public static KeyBoard keyBoardYesNo() {
|
public static KeyBoard keyBoardYesNo() {
|
||||||
KeyBoardButton yesButton = KeyBoardButtonText.builder().color(ButtonColor.POSITIVE).label("Да").payload("{\"button\": \"yes\"}").build();
|
KeyBoardButton yesButton = KeyBoardButtonText.builder().color(ButtonColor.POSITIVE).label("Да").payload("{\"button\": \"yes\"}").build();
|
||||||
KeyBoardButton noButton = KeyBoardButtonText.builder().color(ButtonColor.NEGATIVE).label("Нет").payload("{\"button\": \"no\"}").build();
|
KeyBoardButton noButton = KeyBoardButtonText.builder().color(ButtonColor.NEGATIVE).label("Нет").payload("{\"button\": \"no\"}").build();
|
||||||
@ -21,8 +31,14 @@ public class KeyBoards {
|
|||||||
return KeyBoard.builder().lineKeyBoard(keyBoardLine).oneTime(true).build();
|
return KeyBoard.builder().lineKeyBoard(keyBoardLine).oneTime(true).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру формата 1хN, где N - это количество элементов в переданном списке
|
||||||
|
*
|
||||||
|
* @param labelButtons Список названий для кнопок
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
public static KeyBoard verticalMenuString(List<String> labelButtons) {
|
public static KeyBoard verticalMenuString(List<String> labelButtons) {
|
||||||
KeyBoard.Builder keyBoard = KeyBoard.builder().oneTime(true);
|
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
||||||
for (String labelButton : labelButtons) {
|
for (String labelButton : labelButtons) {
|
||||||
KeyBoardButton keyBoardButton = KeyBoardButtonText.builder().label(labelButton).payload("{\"button\": \"" + labelButton + "\"}").build();
|
KeyBoardButton keyBoardButton = KeyBoardButtonText.builder().label(labelButton).payload("{\"button\": \"" + labelButton + "\"}").build();
|
||||||
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
||||||
@ -30,8 +46,14 @@ public class KeyBoards {
|
|||||||
return keyBoard.build();
|
return keyBoard.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру формата 1хN, где N - это количество элементов в переданном списке
|
||||||
|
*
|
||||||
|
* @param labelButton Список названий для кнопок
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
public static KeyBoard verticalMenuString(String... labelButton) {
|
public static KeyBoard verticalMenuString(String... labelButton) {
|
||||||
KeyBoard.Builder keyBoard = KeyBoard.builder().oneTime(true);
|
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
||||||
for (String label : labelButton) {
|
for (String label : labelButton) {
|
||||||
KeyBoardButton keyBoardButton = KeyBoardButtonText.builder().label(label).payload("{\"button\": \"" + label + "\"}").build();
|
KeyBoardButton keyBoardButton = KeyBoardButtonText.builder().label(label).payload("{\"button\": \"" + label + "\"}").build();
|
||||||
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
||||||
@ -39,10 +61,16 @@ public class KeyBoards {
|
|||||||
return keyBoard.build();
|
return keyBoard.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру формата 2х(N/2), где N - это количество элементов в переданном списке
|
||||||
|
*
|
||||||
|
* @param labelButton Список названий для кнопок
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
public static KeyBoard verticalDuoMenuString(String... labelButton) {
|
public static KeyBoard verticalDuoMenuString(String... labelButton) {
|
||||||
KeyBoard.Builder keyBoard = KeyBoard.builder().oneTime(true);
|
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
KeyBoardLine.Builder keyBoardLine = KeyBoardLine.builder();
|
KeyBoardLine.KeyBoardLineBuilder keyBoardLine = KeyBoardLine.builder();
|
||||||
for (String label : labelButton) {
|
for (String label : labelButton) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
keyBoardLine.buttonKeyBoard(KeyBoardButtonText.builder().label(label).build());
|
keyBoardLine.buttonKeyBoard(KeyBoardButtonText.builder().label(label).build());
|
||||||
@ -57,14 +85,26 @@ public class KeyBoards {
|
|||||||
return keyBoard.build();
|
return keyBoard.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру формата 1xN сформированную из списка кнопок, где N - количество кнопок в списке
|
||||||
|
*
|
||||||
|
* @param keyBoardButtons Список кнопок
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
public static KeyBoard verticalMenuButton(List<KeyBoardButton> keyBoardButtons) {
|
public static KeyBoard verticalMenuButton(List<KeyBoardButton> keyBoardButtons) {
|
||||||
KeyBoard.Builder keyBoard = KeyBoard.builder().oneTime(true);
|
KeyBoard.KeyBoardBuilder keyBoard = KeyBoard.builder().oneTime(true);
|
||||||
for (KeyBoardButton keyBoardButton : keyBoardButtons) {
|
for (KeyBoardButton keyBoardButton : keyBoardButtons) {
|
||||||
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
keyBoard.lineKeyBoard(KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build());
|
||||||
}
|
}
|
||||||
return keyBoard.build();
|
return keyBoard.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Возвращает клавиатуру из одной кнопки
|
||||||
|
*
|
||||||
|
* @param keyBoardButton Кнопка
|
||||||
|
* @return {@link KeyBoard}
|
||||||
|
*/
|
||||||
public static KeyBoard singelton(KeyBoardButton keyBoardButton) {
|
public static KeyBoard singelton(KeyBoardButton keyBoardButton) {
|
||||||
KeyBoardLine line = KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build();
|
KeyBoardLine line = KeyBoardLine.builder().buttonKeyBoard(keyBoardButton).build();
|
||||||
return KeyBoard.builder().lineKeyBoard(line).build();
|
return KeyBoard.builder().lineKeyBoard(line).build();
|
@ -0,0 +1,20 @@
|
|||||||
|
package org.sadtech.social.core.utils;
|
||||||
|
|
||||||
|
import org.sadtech.social.core.domain.content.EmptyMessage;
|
||||||
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Класс для хранения объекта заглушки для {@link Message}.
|
||||||
|
*
|
||||||
|
* @author upagge [08/07/2019]
|
||||||
|
*/
|
||||||
|
public class MessageUtils {
|
||||||
|
|
||||||
|
private MessageUtils() {
|
||||||
|
throw new IllegalStateException("Утилитный класс");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final EmptyMessage EMPTY_MESSAGE = new EmptyMessage();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user