diff --git a/pom.xml b/pom.xml index 0701693..e33e9b0 100644 --- a/pom.xml +++ b/pom.xml @@ -47,9 +47,6 @@ ${bot.core.ver} - - - diff --git a/src/main/java/org/sadtech/vkbot/core/distribution/MailSubscriber.java b/src/main/java/org/sadtech/vkbot/core/distribution/MailSubscriber.java index a88ccd6..b4aeadf 100644 --- a/src/main/java/org/sadtech/vkbot/core/distribution/MailSubscriber.java +++ b/src/main/java/org/sadtech/vkbot/core/distribution/MailSubscriber.java @@ -9,7 +9,7 @@ import org.apache.log4j.Logger; import org.sadtech.bot.core.domain.Mail; import org.sadtech.bot.core.domain.attachment.Attachment; import org.sadtech.bot.core.domain.attachment.AudioMessage; -import org.sadtech.vkbot.core.service.distribution.MailService; +import org.sadtech.bot.core.service.MailService; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java deleted file mode 100644 index 5d1bbe7..0000000 --- a/src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.sadtech.vkbot.core.service.distribution; - -import org.sadtech.bot.core.domain.Mail; -import org.sadtech.bot.core.service.EventService; - -public interface MailService extends EventService { - -} diff --git a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java b/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java deleted file mode 100644 index 8e839c7..0000000 --- a/src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.sadtech.vkbot.core.service.distribution.impl; - -import org.apache.log4j.Logger; -import org.sadtech.bot.core.domain.Mail; -import org.sadtech.bot.core.repository.MailRepository; -import org.sadtech.bot.core.repository.impl.MailRepositoryList; -import org.sadtech.vkbot.core.service.distribution.MailService; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class MailServiceImpl implements MailService { - - private static final Logger log = Logger.getLogger(MailServiceImpl.class); - - private final MailRepository mailRepository; - - public MailServiceImpl() { - this.mailRepository = new MailRepositoryList(); - } - - public MailServiceImpl(MailRepository mailRepository) { - this.mailRepository = mailRepository; - } - - @Override - public void add(Mail mail) { - mailRepository.add(mail); - log.info("Сообщение добавлено в репозиторий"); - log.info(mail); - } - - @Override - public List getFirstEventByTime(LocalDateTime timeFrom, LocalDateTime timeTo) { - log.info("Запрошены сообщения " + timeFrom + " - " + timeTo); - List mails = mailRepository.getMailByTime(timeFrom, timeTo); - Set people = new HashSet<>(); - List returnMails = new ArrayList<>(); - for (int i = mails.size() - 1; i >= 0; i--) { - if (!people.contains(mails.get(i).getPersonId())) { - returnMails.add(mails.get(i)); - people.add(mails.get(i).getPersonId()); - } - } - return returnMails; - } - - @Override - public List getLastEventByTime(LocalDateTime timeFrom, LocalDateTime timeTo) { - List mails = mailRepository.getMailByTime(timeFrom, timeTo); - Set people = new HashSet<>(); - List returnMails = new ArrayList<>(); - for (Mail mail : mails) { - if (!people.contains(mail.getPersonId())) { - returnMails.add(mail); - people.add(mail.getPersonId()); - } - } - return returnMails; - } - - @Override - public List getEvent(LocalDateTime timeFrom, LocalDateTime timeTo) { - log.info("Запрос на получение сообщений в интервале от " + timeFrom + " до " + timeTo); - return mailRepository.getMailByTime(timeFrom, timeTo); - } - -}