Рефакторинг

This commit is contained in:
Mark Struchkov 2019-07-12 12:05:57 +03:00
parent a94238ee23
commit e2ed76abbe
11 changed files with 49 additions and 44 deletions

10
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>org.sadtech.vkbot</groupId>
<artifactId>vkbot-core</artifactId>
<version>0.2.1-RELEASE</version>
<version>0.2.2-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
@ -23,7 +23,7 @@
</build>
<properties>
<bot.core.ver>0.6.2-RELEASE</bot.core.ver>
<social.core.ver>0.6.3-SNAPSHOT</social.core.ver>
<vksdk.ver>0.5.13-FORK</vksdk.ver>
<log4j.ver>1.2.17</log4j.ver>
@ -43,9 +43,9 @@
</dependency>
<dependency>
<groupId>org.sadtech.bot</groupId>
<artifactId>bot-core</artifactId>
<version>${bot.core.ver}</version>
<groupId>org.sadtech.social</groupId>
<artifactId>social-core</artifactId>
<version>${social.core.ver}</version>
</dependency>
</dependencies>

View File

@ -1,12 +1,16 @@
package org.sadtech.vkbot.core.convert;
import com.vk.api.sdk.objects.messages.*;
import org.sadtech.bot.core.domain.keyboard.ButtonColor;
import org.sadtech.bot.core.domain.keyboard.KeyBoard;
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
import org.sadtech.bot.core.domain.keyboard.KeyBoardLine;
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonAccount;
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonText;
import com.vk.api.sdk.objects.messages.Keyboard;
import com.vk.api.sdk.objects.messages.KeyboardButton;
import com.vk.api.sdk.objects.messages.KeyboardButtonAction;
import com.vk.api.sdk.objects.messages.KeyboardButtonActionType;
import com.vk.api.sdk.objects.messages.KeyboardButtonColor;
import org.sadtech.social.core.domain.keyboard.ButtonColor;
import org.sadtech.social.core.domain.keyboard.KeyBoard;
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonAccount;
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
import org.sadtech.vkbot.core.config.VkConnect;
import java.util.ArrayList;

View File

@ -2,10 +2,10 @@ package org.sadtech.vkbot.core.convert;
import com.vk.api.sdk.objects.messages.Message;
import com.vk.api.sdk.objects.messages.MessageAttachment;
import org.sadtech.bot.core.domain.content.Mail;
import org.sadtech.bot.core.domain.content.attachment.Attachment;
import org.sadtech.bot.core.domain.content.attachment.AudioMessage;
import org.sadtech.bot.core.domain.content.attachment.Geo;
import org.sadtech.social.core.domain.content.Mail;
import org.sadtech.social.core.domain.content.attachment.Attachment;
import org.sadtech.social.core.domain.content.attachment.AudioMessage;
import org.sadtech.social.core.domain.content.attachment.Geo;
import java.time.Instant;
import java.time.LocalDateTime;
@ -17,7 +17,7 @@ public class MessageMailConvert implements Convert<Message, Mail> {
@Override
public Mail converting(Message message) {
Mail mail = new Mail();
mail.setMessage(message.getText());
mail.setText(message.getText());
mail.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(message.getDate()), TimeZone.getDefault().toZoneId()));
mail.setId(message.getId());
mail.setPersonId(message.getPeerId());

View File

@ -1,7 +1,7 @@
package org.sadtech.vkbot.core.convert;
import com.vk.api.sdk.objects.board.TopicComment;
import org.sadtech.bot.core.domain.content.BoardComment;
import org.sadtech.social.core.domain.content.BoardComment;
import java.time.Instant;
import java.time.LocalDateTime;
@ -13,7 +13,7 @@ public class TopicCommentToBoardComment implements Convert<TopicComment, BoardCo
BoardComment boardComment = new BoardComment();
boardComment.setContentId(target.getTopicId());
boardComment.setCreateDate(LocalDateTime.ofInstant(Instant.ofEpochSecond(target.getDate()), TimeZone.getDefault().toZoneId()));
boardComment.setMessage(target.getText());
boardComment.setText(target.getText());
boardComment.setPersonId(target.getFromId());

View File

@ -2,10 +2,10 @@ package org.sadtech.vkbot.core.distribution;
import com.vk.api.sdk.objects.messages.Message;
import com.vk.api.sdk.objects.messages.MessageAttachmentType;
import org.sadtech.bot.core.domain.BoxAnswer;
import org.sadtech.bot.core.exception.PaymentException;
import org.sadtech.bot.core.service.AccountService;
import org.sadtech.bot.core.service.sender.Sent;
import org.sadtech.social.core.domain.BoxAnswer;
import org.sadtech.social.core.exception.PaymentException;
import org.sadtech.social.core.service.AccountService;
import org.sadtech.social.core.service.sender.Sent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -3,8 +3,8 @@ package org.sadtech.vkbot.core.distribution;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.vk.api.sdk.objects.board.TopicComment;
import org.sadtech.bot.core.domain.content.BoardComment;
import org.sadtech.bot.core.service.BoardCommentService;
import org.sadtech.social.core.domain.content.BoardComment;
import org.sadtech.social.core.service.BoardCommentService;
import org.sadtech.vkbot.core.convert.Convert;
import org.sadtech.vkbot.core.convert.TopicCommentToBoardComment;

View File

@ -2,8 +2,9 @@ package org.sadtech.vkbot.core.distribution;
import com.google.gson.JsonObject;
import org.apache.log4j.Logger;
import org.sadtech.bot.core.service.RawEventService;
import org.sadtech.social.core.service.RawEventService;
// todo [upagge] [12/07/2019]: Рефакторинг - отказаться от наследования
public class EventDistributor extends AbstractBasketSubscribe<JsonObject, JsonObject> implements Runnable {
private static final Logger log = Logger.getLogger(EventDistributor.class);

View File

@ -3,8 +3,8 @@ package org.sadtech.vkbot.core.distribution;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.vk.api.sdk.objects.messages.Message;
import org.sadtech.bot.core.domain.content.Mail;
import org.sadtech.bot.core.service.MailService;
import org.sadtech.social.core.domain.content.Mail;
import org.sadtech.social.core.service.MailService;
import org.sadtech.vkbot.core.convert.Convert;
import org.sadtech.vkbot.core.convert.MessageMailConvert;

View File

@ -8,9 +8,9 @@ import com.vk.api.sdk.exceptions.LongPollServerKeyExpiredException;
import com.vk.api.sdk.objects.callback.longpoll.responses.GetLongPollEventsResponse;
import com.vk.api.sdk.objects.groups.LongPollServer;
import org.apache.log4j.Logger;
import org.sadtech.bot.core.repository.impl.EventRepositoryQueue;
import org.sadtech.bot.core.service.RawEventService;
import org.sadtech.bot.core.service.impl.RawEventServiceImpl;
import org.sadtech.social.core.repository.impl.EventRepositoryQueue;
import org.sadtech.social.core.service.RawEventService;
import org.sadtech.social.core.service.impl.RawEventServiceImpl;
import org.sadtech.vkbot.core.config.VkConnect;
public class EventListenerVk implements Runnable {

View File

@ -5,12 +5,12 @@ import com.vk.api.sdk.client.actors.GroupActor;
import com.vk.api.sdk.client.actors.UserActor;
import com.vk.api.sdk.exceptions.ApiException;
import com.vk.api.sdk.exceptions.ClientException;
import org.sadtech.bot.core.domain.BoxAnswer;
import org.sadtech.bot.core.domain.keyboard.KeyBoardButton;
import org.sadtech.bot.core.domain.keyboard.KeyBoardLine;
import org.sadtech.bot.core.domain.keyboard.button.KeyBoardButtonText;
import org.sadtech.bot.core.exception.MailSendException;
import org.sadtech.bot.core.service.sender.Sent;
import org.sadtech.social.core.domain.BoxAnswer;
import org.sadtech.social.core.domain.keyboard.KeyBoardButton;
import org.sadtech.social.core.domain.keyboard.KeyBoardLine;
import org.sadtech.social.core.domain.keyboard.button.KeyBoardButtonText;
import org.sadtech.social.core.exception.MailSendException;
import org.sadtech.social.core.service.sender.Sent;
import org.sadtech.vkbot.core.config.VkConnect;
import org.sadtech.vkbot.core.utils.VkInsertData;

View File

@ -7,9 +7,9 @@ import com.vk.api.sdk.exceptions.ClientException;
import com.vk.api.sdk.objects.messages.Keyboard;
import com.vk.api.sdk.queries.messages.MessagesSendQuery;
import org.apache.log4j.Logger;
import org.sadtech.bot.core.domain.BoxAnswer;
import org.sadtech.bot.core.domain.keyboard.KeyBoard;
import org.sadtech.bot.core.service.sender.Sent;
import org.sadtech.social.core.domain.BoxAnswer;
import org.sadtech.social.core.domain.keyboard.KeyBoard;
import org.sadtech.social.core.service.sender.Sent;
import org.sadtech.vkbot.core.config.VkConnect;
import org.sadtech.vkbot.core.convert.KeyBoardConvert;
import org.sadtech.vkbot.core.utils.VkInsertData;