From 78cc77185211220555956d557cbc70d3ea2730df Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Fri, 9 Dec 2022 22:06:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20SenderStorageService=20=D0=BD=D0=B0=20SenderRepository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../context/repository/SenderRepository.java | 4 ++-- .../context/service/SenderStorageService.java | 13 ------------ .../SenderRepository.java} | 4 ++-- ...eService.java => SenderMapRepository.java} | 4 ++-- ...eService.java => SenderMapRepository.java} | 4 ++-- .../quarkus/sender/TelegramSender.java | 19 +++++++++--------- .../simple/sender/TelegramSender.java | 20 +++++++++---------- 7 files changed, 28 insertions(+), 40 deletions(-) rename telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/SenderStorageService.java => telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/repository/SenderRepository.java (68%) delete mode 100644 telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/SenderStorageService.java rename telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/{service/SenderStorageService.java => repository/SenderRepository.java} (67%) rename telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/{SenderMapStorageService.java => SenderMapRepository.java} (84%) rename telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/{SenderMapStorageService.java => SenderMapRepository.java} (83%) diff --git a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/SenderStorageService.java b/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/repository/SenderRepository.java similarity index 68% rename from telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/SenderStorageService.java rename to telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/repository/SenderRepository.java index 56f05ad..9ce6edf 100644 --- a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/SenderStorageService.java +++ b/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/repository/SenderRepository.java @@ -1,8 +1,8 @@ -package dev.struchkov.godfather.telegram.quarkus.sender; +package dev.struchkov.godfather.telegram.quarkus.context.repository; import io.smallrye.mutiny.Uni; -public interface SenderStorageService { +public interface SenderRepository { Uni getLastSendMessage(String telegramId); diff --git a/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/SenderStorageService.java b/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/SenderStorageService.java deleted file mode 100644 index d55b8d0..0000000 --- a/telegram-context/telegram-context-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/context/service/SenderStorageService.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.struchkov.godfather.telegram.quarkus.context.service; - -import io.smallrye.mutiny.Uni; - -public interface SenderStorageService { - - Uni getLastSendMessage(Long telegramId); - - Uni saveLastSendMessage(Long telegramId, Integer messageId); - - Uni removeLastSendMessage(Long telegramId); - -} diff --git a/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/SenderStorageService.java b/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/repository/SenderRepository.java similarity index 67% rename from telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/SenderStorageService.java rename to telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/repository/SenderRepository.java index 9cd8102..97f6bf2 100644 --- a/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/service/SenderStorageService.java +++ b/telegram-context/telegram-context-simple/src/main/java/dev/struchkov/godfather/telegram/simple/context/repository/SenderRepository.java @@ -1,8 +1,8 @@ -package dev.struchkov.godfather.telegram.simple.context.service; +package dev.struchkov.godfather.telegram.simple.context.repository; import java.util.Optional; -public interface SenderStorageService { +public interface SenderRepository { Optional getLastSendMessage(String telegramId); diff --git a/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/SenderMapStorageService.java b/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/SenderMapRepository.java similarity index 84% rename from telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/SenderMapStorageService.java rename to telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/SenderMapRepository.java index 98af729..75956e7 100644 --- a/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/SenderMapStorageService.java +++ b/telegram-core/telegram-core-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/core/service/SenderMapRepository.java @@ -1,6 +1,6 @@ package dev.struchkov.godfather.telegram.quarkus.core.service; -import dev.struchkov.godfather.telegram.quarkus.context.service.SenderStorageService; +import dev.struchkov.godfather.telegram.quarkus.context.repository.SenderRepository; import io.smallrye.mutiny.Uni; import org.jetbrains.annotations.NotNull; @@ -9,7 +9,7 @@ import java.util.Map; import static dev.struchkov.haiti.utils.Inspector.isNotNull; -public class SenderMapStorageService implements SenderStorageService { +public class SenderMapRepository implements SenderRepository { private final Map lastMessageId = new HashMap<>(); diff --git a/telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/SenderMapStorageService.java b/telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/SenderMapRepository.java similarity index 83% rename from telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/SenderMapStorageService.java rename to telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/SenderMapRepository.java index 8541b9e..ab23c93 100644 --- a/telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/SenderMapStorageService.java +++ b/telegram-core/telegram-core-simple/src/main/java/dev/struchkov/godfather/telegram/simple/core/service/SenderMapRepository.java @@ -1,6 +1,6 @@ package dev.struchkov.godfather.telegram.simple.core.service; -import dev.struchkov.godfather.telegram.simple.context.service.SenderStorageService; +import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository; import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -9,7 +9,7 @@ import java.util.Optional; import static dev.struchkov.haiti.utils.Inspector.isNotNull; -public class SenderMapStorageService implements SenderStorageService { +public class SenderMapRepository implements SenderRepository { private final Map lastMessageId = new HashMap<>(); diff --git a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java b/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java index 8cd6b32..9bb0381 100644 --- a/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java +++ b/telegram-sender/telegram-sender-quarkus/src/main/java/dev/struchkov/godfather/telegram/quarkus/sender/TelegramSender.java @@ -5,6 +5,7 @@ import dev.struchkov.godfather.main.domain.SendType; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.godfather.telegram.main.context.TelegramConnect; import dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert; +import dev.struchkov.godfather.telegram.quarkus.context.repository.SenderRepository; import dev.struchkov.godfather.telegram.quarkus.context.service.TelegramSending; import io.smallrye.mutiny.Uni; import org.jetbrains.annotations.NotNull; @@ -30,23 +31,23 @@ public class TelegramSender implements TelegramSending { private final AbsSender absSender; private SendPreProcessing sendPreProcessing; - private SenderStorageService senderStorageService; + private SenderRepository senderRepository; public TelegramSender(TelegramConnect telegramConnect) { this.absSender = telegramConnect.getAbsSender(); } - public TelegramSender(TelegramConnect telegramConnect, SenderStorageService senderStorageService) { + public TelegramSender(TelegramConnect telegramConnect, SenderRepository senderRepository) { this.absSender = telegramConnect.getAbsSender(); - this.senderStorageService = senderStorageService; + this.senderRepository = senderRepository; } public void setSendPreProcessing(SendPreProcessing sendPreProcessing) { this.sendPreProcessing = sendPreProcessing; } - public void setSenderRepository(SenderStorageService senderStorageService) { - this.senderStorageService = senderStorageService; + public void setSenderRepository(SenderRepository senderStorageService) { + this.senderRepository = senderRepository; } @Override @@ -65,8 +66,8 @@ public class TelegramSender implements TelegramSending { v -> { isNotNull(telegramId, boxAnswer); - if (boxAnswer.isReplace() && checkNotNull(senderStorageService)) { - return senderStorageService.getLastSendMessage(telegramId) + if (boxAnswer.isReplace() && checkNotNull(senderRepository)) { + return senderRepository.getLastSendMessage(telegramId) .onItem().transformToUni( lastId -> { if (checkNotNull(lastId)) { @@ -119,8 +120,8 @@ public class TelegramSender implements TelegramSending { try { final Message execute = absSender.execute(sendMessage); - if (checkNotNull(senderStorageService) && saveMessageId) { - return senderStorageService.saveLastSendMessage(telegramId, execute.getMessageId()); + if (checkNotNull(senderRepository) && saveMessageId) { + return senderRepository.saveLastSendMessage(telegramId, execute.getMessageId()); } } catch (TelegramApiRequestException e) { log.error(e.getApiResponse()); diff --git a/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java b/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java index f588ec6..eb2be75 100644 --- a/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java +++ b/telegram-sender/telegram-sender-simple/src/main/java/dev/struchkov/godfather/telegram/simple/sender/TelegramSender.java @@ -5,7 +5,7 @@ import dev.struchkov.godfather.main.domain.SendType; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.godfather.telegram.main.context.TelegramConnect; import dev.struchkov.godfather.telegram.main.sender.util.KeyBoardConvert; -import dev.struchkov.godfather.telegram.simple.context.service.SenderStorageService; +import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -31,23 +31,23 @@ public class TelegramSender implements TelegramSending { private final AbsSender absSender; private SendPreProcessing sendPreProcessing; - private SenderStorageService senderStorageService; + private SenderRepository senderRepository; public TelegramSender(TelegramConnect telegramConnect) { this.absSender = telegramConnect.getAbsSender(); } - public TelegramSender(TelegramConnect telegramConnect, SenderStorageService senderStorageService) { + public TelegramSender(TelegramConnect telegramConnect, SenderRepository senderRepository) { this.absSender = telegramConnect.getAbsSender(); - this.senderStorageService = senderStorageService; + this.senderRepository = senderRepository; } public void setSendPreProcessing(SendPreProcessing sendPreProcessing) { this.sendPreProcessing = sendPreProcessing; } - public void setSenderRepository(SenderStorageService senderStorageService) { - this.senderStorageService = senderStorageService; + public void setSenderRepository(SenderRepository senderRepository) { + this.senderRepository = senderRepository; } @Override @@ -63,8 +63,8 @@ public class TelegramSender implements TelegramSending { private void sendBoxAnswer(@NotNull String telegramId, @NotNull BoxAnswer boxAnswer, boolean saveMessageId) { isNotNull(telegramId, boxAnswer); try { - if (boxAnswer.isReplace() && checkNotNull(senderStorageService)) { - final Optional optLastId = senderStorageService.getLastSendMessage(telegramId); + if (boxAnswer.isReplace() && checkNotNull(senderRepository)) { + final Optional optLastId = senderRepository.getLastSendMessage(telegramId); if (optLastId.isPresent()) { replaceMessage(telegramId, optLastId.get(), boxAnswer); } else { @@ -105,8 +105,8 @@ public class TelegramSender implements TelegramSending { sendMessage.setReplyMarkup(KeyBoardConvert.convertKeyBoard(boxAnswer.getKeyBoard())); try { final Message execute = absSender.execute(sendMessage); - if (checkNotNull(senderStorageService) && saveMessageId) { - senderStorageService.saveLastSendMessage(telegramId, execute.getMessageId()); + if (checkNotNull(senderRepository) && saveMessageId) { + senderRepository.saveLastSendMessage(telegramId, execute.getMessageId()); } } catch (TelegramApiRequestException e) { log.error(e.getApiResponse());