From a584af0e92133f784942aa0e610b6c5cd71e89d2 Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Fri, 17 May 2019 18:59:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 3 - .../core/distribution/MailSubscriber.java | 2 +- .../service/distribution/MailService.java | 8 --- .../distribution/impl/MailServiceImpl.java | 71 ------------------- 4 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 src/main/java/org/sadtech/vkbot/core/service/distribution/MailService.java delete mode 100644 src/main/java/org/sadtech/vkbot/core/service/distribution/impl/MailServiceImpl.java 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); - } - -}