Переход на String вместо Long для id юзера
This commit is contained in:
parent
eb2e7ba012
commit
eaaca3be6c
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-context</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-context</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -7,12 +7,12 @@ import java.util.Set;
|
||||
|
||||
public interface PersonSettingService {
|
||||
|
||||
Uni<Set<Long>> getAllPersonIdDisableMessages(@NotNull Set<Long> personIds);
|
||||
Uni<Set<String>> getAllPersonIdDisableMessages(@NotNull Set<String> personIds);
|
||||
|
||||
Uni<Boolean> getStateProcessingByPersonId(@NotNull Long personId);
|
||||
Uni<Boolean> getStateProcessingByPersonId(@NotNull String personId);
|
||||
|
||||
Uni<Void> disableMessageProcessing(@NotNull Long personId);
|
||||
Uni<Void> disableMessageProcessing(@NotNull String personId);
|
||||
|
||||
Uni<Void> enableMessageProcessing(@NotNull Long personId);
|
||||
Uni<Void> enableMessageProcessing(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ import java.util.Map;
|
||||
@FunctionalInterface
|
||||
public interface Pusher<D> {
|
||||
|
||||
Uni<Void> push(Long personId, Map<String, D> saveElement);
|
||||
Uni<Void> push(String personId, Map<String, D> saveElement);
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public interface Sending {
|
||||
* @param personId Идентификатор пользователя
|
||||
* @param boxAnswer Объект с данными, которые необходимо отправить
|
||||
*/
|
||||
Uni<Void> send(@NotNull Long personId, @NotNull BoxAnswer boxAnswer);
|
||||
Uni<Void> send(@NotNull String personId, @NotNull BoxAnswer boxAnswer);
|
||||
|
||||
/**
|
||||
* Возвращает тип объекта отправляющего ответ пользователя. В зависимости от типа ответ будет отправлен с помощью
|
||||
|
@ -13,8 +13,8 @@ public interface UnitPointerService {
|
||||
|
||||
Uni<UnitPointer> save(@NotNull UnitPointer unitPointer);
|
||||
|
||||
Uni<String> getUnitNameByPersonId(@NotNull Long personId);
|
||||
Uni<String> getUnitNameByPersonId(@NotNull String personId);
|
||||
|
||||
Uni<Void> removeByPersonId(@NotNull Long personId);
|
||||
Uni<Void> removeByPersonId(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-context</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -7,12 +7,12 @@ import java.util.Set;
|
||||
|
||||
public interface PersonSettingService {
|
||||
|
||||
Set<Long> getAllPersonIdDisableMessages(@NotNull Set<Long> personIds);
|
||||
Set<String> getAllPersonIdDisableMessages(@NotNull Set<String> personIds);
|
||||
|
||||
Optional<Boolean> getStateProcessingByPersonId(@NotNull Long personId);
|
||||
Optional<Boolean> getStateProcessingByPersonId(@NotNull String personId);
|
||||
|
||||
void disableMessageProcessing(@NotNull Long personId);
|
||||
void disableMessageProcessing(@NotNull String personId);
|
||||
|
||||
void enableMessageProcessing(@NotNull Long personId);
|
||||
void enableMessageProcessing(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ import java.util.Map;
|
||||
@FunctionalInterface
|
||||
public interface Pusher<D> {
|
||||
|
||||
void push(Long personId, Map<String, D> saveElement);
|
||||
void push(String personId, Map<String, D> saveElement);
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public interface Sending {
|
||||
* @param personId Идентификатор пользователя
|
||||
* @param boxAnswer Объект с данными, которые необходимо отправить
|
||||
*/
|
||||
void send(@NotNull Long personId, @NotNull BoxAnswer boxAnswer);
|
||||
void send(@NotNull String personId, @NotNull BoxAnswer boxAnswer);
|
||||
|
||||
/**
|
||||
* Возвращает тип объекта отправляющего ответ пользователя. В зависимости от типа ответ будет отправлен с помощью
|
||||
|
@ -14,8 +14,8 @@ public interface UnitPointerService {
|
||||
|
||||
UnitPointer save(@NotNull UnitPointer unitPointer);
|
||||
|
||||
Optional<String> getUnitNameByPersonId(@NotNull Long personId);
|
||||
Optional<String> getUnitNameByPersonId(@NotNull String personId);
|
||||
|
||||
void removeByPersonId(@NotNull Long personId);
|
||||
void removeByPersonId(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>godfather-bot</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bot-context</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class GeneralAutoResponder<M extends Message> {
|
||||
messages -> {
|
||||
if (checkEmpty(newMessages)) return Uni.createFrom().voidItem();
|
||||
|
||||
final Set<Long> personIds = newMessages.stream()
|
||||
final Set<String> personIds = newMessages.stream()
|
||||
.map(Message::getPersonId)
|
||||
.collect(Collectors.toSet());
|
||||
return personSettingService.getAllPersonIdDisableMessages(personIds)
|
||||
|
@ -25,7 +25,7 @@ public class AnswerSaveAction<M extends Message, D> implements ActionUnit<Answer
|
||||
final M message = unitRequest.getMessage();
|
||||
|
||||
final AnswerSavePreservable<D> preservable = answerSave.getPreservable();
|
||||
final Long personId = message.getPersonId();
|
||||
final String personId = message.getPersonId();
|
||||
|
||||
final CheckSave<M> checkSave = answerSave.getCheckSave();
|
||||
if (checkNotNull(checkSave)) {
|
||||
|
@ -17,24 +17,24 @@ public class PersonSettingServiceImpl implements PersonSettingService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Set<Long>> getAllPersonIdDisableMessages(@NotNull Set<Long> personIds) {
|
||||
public Uni<Set<String>> getAllPersonIdDisableMessages(@NotNull Set<String> personIds) {
|
||||
Inspector.isNotNull(personIds);
|
||||
return personSettingRepository.findAllByAllowedProcessing(personIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Boolean> getStateProcessingByPersonId(@NotNull Long personId) {
|
||||
public Uni<Boolean> getStateProcessingByPersonId(@NotNull String personId) {
|
||||
return personSettingRepository.findStateByPersonId(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> disableMessageProcessing(@NotNull Long personId) {
|
||||
public Uni<Void> disableMessageProcessing(@NotNull String personId) {
|
||||
Inspector.isNotNull(personId);
|
||||
return personSettingRepository.disableMessageProcessing(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> enableMessageProcessing(@NotNull Long personId) {
|
||||
public Uni<Void> enableMessageProcessing(@NotNull String personId) {
|
||||
Inspector.isNotNull(personId);
|
||||
return personSettingRepository.enableMessageProcessing(personId);
|
||||
}
|
||||
|
@ -13,15 +13,15 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||
|
||||
public class StorylineContextMapImpl implements StorylineContext {
|
||||
|
||||
private final Map<Long, Map<String, Object>> map = new HashMap<>();
|
||||
private final Map<String, Map<String, Object>> map = new HashMap<>();
|
||||
|
||||
public Uni<Void> save(@NotNull Long personId, @NotNull ContextKey<?> key, Object objectForSave) {
|
||||
public Uni<Void> save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave) {
|
||||
isNotNull(personId, key);
|
||||
map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave);
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
||||
public <T> Uni<T> getByKey(@NotNull Long personId, @NotNull ContextKey<T> key) {
|
||||
public <T> Uni<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key) {
|
||||
isNotNull(personId, key);
|
||||
if (map.containsKey(personId)) {
|
||||
final Map<String, Object> storage = map.get(personId);
|
||||
@ -34,23 +34,23 @@ public class StorylineContextMapImpl implements StorylineContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Uni<T> getByKeyOrThrow(@NotNull Long personId, @NotNull ContextKey<T> key) {
|
||||
public <T> Uni<T> getByKeyOrThrow(@NotNull String personId, @NotNull ContextKey<T> key) {
|
||||
return getByKey(personId, key)
|
||||
.onItem().ifNull().failWith(notFoundException("Не найдено значение ключа {0}, для пользователя {1}", key.getValue(), personId));
|
||||
}
|
||||
|
||||
public Uni<Map<String, Object>> getAllSaveElement(@NotNull Long personId) {
|
||||
public Uni<Map<String, Object>> getAllSaveElement(@NotNull String personId) {
|
||||
isNotNull(personId);
|
||||
return Uni.createFrom().item(map.get(personId));
|
||||
}
|
||||
|
||||
public Uni<Void> removeAll(@NotNull Long personId) {
|
||||
public Uni<Void> removeAll(@NotNull String personId) {
|
||||
isNotNull(personId);
|
||||
map.remove(personId);
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
||||
public Uni<Void> removeByKey(@NotNull Long personId, @NotNull ContextKey<?> key) {
|
||||
public Uni<Void> removeByKey(@NotNull String personId, @NotNull ContextKey<?> key) {
|
||||
isNotNull(personId, key);
|
||||
map.computeIfAbsent(personId, k -> new HashMap<>()).remove(key.getValue());
|
||||
return Uni.createFrom().voidItem();
|
||||
|
@ -47,7 +47,7 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<MainUnit<Mail>> getUnitNameByPersonId(@NotNull Long personId) {
|
||||
public Uni<MainUnit<Mail>> getUnitNameByPersonId(@NotNull String personId) {
|
||||
isNotNull(personId);
|
||||
return unitPointerService.getUnitNameByPersonId(personId)
|
||||
.onItem().transform(
|
||||
@ -62,7 +62,7 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Set<MainUnit<Mail>>> getNextUnitByPersonId(@NotNull Long personId) {
|
||||
public Uni<Set<MainUnit<Mail>>> getNextUnitByPersonId(@NotNull String personId) {
|
||||
return getUnitNameByPersonId(personId)
|
||||
.flatMap(
|
||||
unit -> {
|
||||
@ -86,10 +86,10 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> save(Long personId, String unitName, Mail mail) {
|
||||
public Uni<Void> save(String personId, String unitName, Mail mail) {
|
||||
isNotNull(personId, unitName, mail);
|
||||
return unitPointerService.save(new UnitPointer(personId, unitName))
|
||||
.map(u -> {
|
||||
.onItem().transformToUni(u -> {
|
||||
final StorylineHistory storylineHistory = new StorylineHistory();
|
||||
storylineHistory.setPersonId(personId);
|
||||
storylineHistory.setUnitName(unitName);
|
||||
@ -99,12 +99,12 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<StorylineHistory> replaceUserToBack(long personId, int countUnitsToBack) {
|
||||
public Uni<StorylineHistory> replaceUserToBack(String personId, int countUnitsToBack) {
|
||||
return storylineRepository.findByCountLast(personId, countUnitsToBack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<StorylineHistory> replaceUserToBack(long personId, String unitName) {
|
||||
public Uni<StorylineHistory> replaceUserToBack(String personId, String unitName) {
|
||||
return storylineRepository.findByCountLast(personId, unitName);
|
||||
}
|
||||
|
||||
|
@ -13,15 +13,15 @@ public interface StorylineService<M extends Message> {
|
||||
|
||||
Uni<Void> save(@NotNull StorylineHistory storylineHistory);
|
||||
|
||||
Uni<MainUnit<M>> getUnitNameByPersonId(@NotNull Long personId);
|
||||
Uni<MainUnit<M>> getUnitNameByPersonId(@NotNull String personId);
|
||||
|
||||
Uni<Set<MainUnit<M>>> getNextUnitByPersonId(@NotNull Long personId);
|
||||
Uni<Set<MainUnit<M>>> getNextUnitByPersonId(@NotNull String personId);
|
||||
|
||||
Uni<Void> save(Long personId, String name, M message);
|
||||
Uni<Void> save(String personId, String name, M message);
|
||||
|
||||
Uni<StorylineHistory> replaceUserToBack(long personId, int countUnitsToBack);
|
||||
Uni<StorylineHistory> replaceUserToBack(String personId, int countUnitsToBack);
|
||||
|
||||
Uni<StorylineHistory> replaceUserToBack(long personId, String unitName);
|
||||
Uni<StorylineHistory> replaceUserToBack(String personId, String unitName);
|
||||
|
||||
Optional<MainUnit<M>> getDefaultUnit();
|
||||
|
||||
|
@ -20,12 +20,12 @@ public class UnitPointerServiceImpl implements UnitPointerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<String> getUnitNameByPersonId(@NotNull Long personId) {
|
||||
public Uni<String> getUnitNameByPersonId(@NotNull String personId) {
|
||||
return unitPointerRepository.findUnitNameByPersonId(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> removeByPersonId(@NotNull Long personId) {
|
||||
public Uni<Void> removeByPersonId(@NotNull String personId) {
|
||||
return unitPointerRepository.removeByPersonId(personId);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,6 @@ import java.util.List;
|
||||
@FunctionalInterface
|
||||
public interface Insert {
|
||||
|
||||
Uni<List<String>> insert(Long personId);
|
||||
Uni<List<String>> insert(String personId);
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>bot-core</artifactId>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -89,10 +89,10 @@ public class GeneralAutoResponder<M extends Message> {
|
||||
|
||||
public void processingNewMessages(List<M> newMessages) {
|
||||
if (newMessages != null && !newMessages.isEmpty()) {
|
||||
final Set<Long> personIds = newMessages.stream()
|
||||
final Set<String> personIds = newMessages.stream()
|
||||
.map(Message::getPersonId)
|
||||
.collect(Collectors.toSet());
|
||||
final Set<Long> disableIds = personSettingService.getAllPersonIdDisableMessages(personIds);
|
||||
final Set<String> disableIds = personSettingService.getAllPersonIdDisableMessages(personIds);
|
||||
final List<M> allowedMessages = newMessages.stream()
|
||||
.filter(message -> !disableIds.contains(message.getPersonId()))
|
||||
.toList();
|
||||
|
@ -24,7 +24,7 @@ public class AnswerSaveAction<M extends Message, D> implements ActionUnit<Answer
|
||||
final M message = unitRequest.getMessage();
|
||||
|
||||
final AnswerSavePreservable<D> preservable = answerSave.getPreservable();
|
||||
final Long personId = message.getPersonId();
|
||||
final String personId = message.getPersonId();
|
||||
|
||||
final CheckSave<M> checkSave = answerSave.getCheckSave();
|
||||
if (checkNotNull(checkSave)) {
|
||||
|
@ -9,18 +9,18 @@ import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
||||
|
||||
public class UserSanderPusher implements Pusher<String> {
|
||||
|
||||
private final Long personId;
|
||||
private final String personId;
|
||||
private final String nameForm;
|
||||
private final Sending sending;
|
||||
|
||||
public UserSanderPusher(Long personId, String nameForm, Sending sending) {
|
||||
public UserSanderPusher(String personId, String nameForm, Sending sending) {
|
||||
this.personId = personId;
|
||||
this.nameForm = nameForm;
|
||||
this.sending = sending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void push(Long personId, Map<String, String> saveElement) {
|
||||
public void push(String personId, Map<String, String> saveElement) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("========= ").append(nameForm).append(" =========\n");
|
||||
saveElement.forEach((key, value) -> stringBuilder.append(key).append(": ").append(value).append("\n"));
|
||||
|
@ -17,24 +17,24 @@ public class PersonSettingServiceImpl implements PersonSettingService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getAllPersonIdDisableMessages(@NotNull Set<Long> personIds) {
|
||||
public Set<String> getAllPersonIdDisableMessages(@NotNull Set<String> personIds) {
|
||||
Inspector.isNotNull(personIds);
|
||||
return personSettingRepository.findAllByAllowedProcessing(personIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Boolean> getStateProcessingByPersonId(@NotNull Long personId) {
|
||||
public Optional<Boolean> getStateProcessingByPersonId(@NotNull String personId) {
|
||||
return personSettingRepository.findStateByPersonId(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableMessageProcessing(@NotNull Long personId) {
|
||||
public void disableMessageProcessing(@NotNull String personId) {
|
||||
Inspector.isNotNull(personId);
|
||||
personSettingRepository.disableMessageProcessing(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableMessageProcessing(@NotNull Long personId) {
|
||||
public void enableMessageProcessing(@NotNull String personId) {
|
||||
Inspector.isNotNull(personId);
|
||||
personSettingRepository.enableMessageProcessing(personId);
|
||||
}
|
||||
|
@ -13,14 +13,14 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||
|
||||
public class StorylineContextMapImpl implements StorylineContext {
|
||||
|
||||
private final Map<Long, Map<String, Object>> map = new HashMap<>();
|
||||
private final Map<String, Map<String, Object>> map = new HashMap<>();
|
||||
|
||||
public void save(@NotNull Long personId, @NotNull ContextKey<?> key, Object objectForSave) {
|
||||
public void save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave) {
|
||||
isNotNull(personId, key);
|
||||
map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave);
|
||||
}
|
||||
|
||||
public <T> Optional<T> getByKey(@NotNull Long personId, @NotNull ContextKey<T> key) {
|
||||
public <T> Optional<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key) {
|
||||
isNotNull(personId, key);
|
||||
if (map.containsKey(personId)) {
|
||||
final Map<String, Object> storage = map.get(personId);
|
||||
@ -33,21 +33,21 @@ public class StorylineContextMapImpl implements StorylineContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getByKeyOrThrow(@NotNull Long personId, @NotNull ContextKey<T> key) {
|
||||
public <T> T getByKeyOrThrow(@NotNull String personId, @NotNull ContextKey<T> key) {
|
||||
return getByKey(personId, key).orElseThrow(notFoundException("Не найдено значение ключа {0}, для пользователя {1}", key.getValue(), personId));
|
||||
}
|
||||
|
||||
public Map<String, Object> getAllSaveElement(@NotNull Long personId) {
|
||||
public Map<String, Object> getAllSaveElement(@NotNull String personId) {
|
||||
isNotNull(personId);
|
||||
return map.get(personId);
|
||||
}
|
||||
|
||||
public void removeAll(@NotNull Long personId) {
|
||||
public void removeAll(@NotNull String personId) {
|
||||
isNotNull(personId);
|
||||
map.remove(personId);
|
||||
}
|
||||
|
||||
public void removeByKey(@NotNull Long personId, @NotNull ContextKey<?> key) {
|
||||
public void removeByKey(@NotNull String personId, @NotNull ContextKey<?> key) {
|
||||
isNotNull(personId, key);
|
||||
map.computeIfAbsent(personId, k -> new HashMap<>()).remove(key.getValue());
|
||||
}
|
||||
|
@ -44,14 +44,14 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<MainUnit<Mail>> getUnitNameByPersonId(@NotNull Long personId) {
|
||||
public Optional<MainUnit<Mail>> getUnitNameByPersonId(@NotNull String personId) {
|
||||
isNotNull(personId);
|
||||
return unitPointerService.getUnitNameByPersonId(personId)
|
||||
.flatMap(storyLine::getUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MainUnit<Mail>> getNextUnitByPersonId(@NotNull Long personId) {
|
||||
public Set<MainUnit<Mail>> getNextUnitByPersonId(@NotNull String personId) {
|
||||
final Optional<Set<MainUnit<Mail>>> optMainUnits = getUnitNameByPersonId(personId)
|
||||
.map(Unit::getNextUnits)
|
||||
.filter(mainUnits -> !mainUnits.isEmpty());
|
||||
@ -64,7 +64,7 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Long personId, String unitName, Mail mail) {
|
||||
public void save(String personId, String unitName, Mail mail) {
|
||||
isNotNull(personId, unitName, mail);
|
||||
unitPointerService.save(new UnitPointer(personId, unitName));
|
||||
|
||||
@ -76,12 +76,12 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StorylineHistory> replaceUserToBack(long personId, int countUnitsToBack) {
|
||||
public Optional<StorylineHistory> replaceUserToBack(String personId, int countUnitsToBack) {
|
||||
return storylineRepository.findByCountLast(personId, countUnitsToBack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StorylineHistory> replaceUserToBack(long personId, String unitName) {
|
||||
public Optional<StorylineHistory> replaceUserToBack(String personId, String unitName) {
|
||||
return storylineRepository.findByCountLast(personId, unitName);
|
||||
}
|
||||
|
||||
|
@ -12,15 +12,15 @@ public interface StorylineService<M extends Message> {
|
||||
|
||||
void save(@NotNull StorylineHistory storylineHistory);
|
||||
|
||||
Optional<MainUnit<M>> getUnitNameByPersonId(@NotNull Long personId);
|
||||
Optional<MainUnit<M>> getUnitNameByPersonId(@NotNull String personId);
|
||||
|
||||
Set<MainUnit<M>> getNextUnitByPersonId(@NotNull Long personId);
|
||||
Set<MainUnit<M>> getNextUnitByPersonId(@NotNull String personId);
|
||||
|
||||
void save(Long personId, String name, M message);
|
||||
void save(String personId, String name, M message);
|
||||
|
||||
Optional<StorylineHistory> replaceUserToBack(long personId, int countUnitsToBack);
|
||||
Optional<StorylineHistory> replaceUserToBack(String personId, int countUnitsToBack);
|
||||
|
||||
Optional<StorylineHistory> replaceUserToBack(long personId, String unitName);
|
||||
Optional<StorylineHistory> replaceUserToBack(String personId, String unitName);
|
||||
|
||||
Optional<MainUnit<M>> getDefaultUnit();
|
||||
|
||||
|
@ -21,12 +21,12 @@ public class UnitPointerServiceImpl implements UnitPointerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getUnitNameByPersonId(@NotNull Long personId) {
|
||||
public Optional<String> getUnitNameByPersonId(@NotNull String personId) {
|
||||
return unitPointerRepository.findUnitNameByPersonId(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByPersonId(@NotNull Long personId) {
|
||||
public void removeByPersonId(@NotNull String personId) {
|
||||
unitPointerRepository.removeByPersonId(personId);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,6 @@ import java.util.List;
|
||||
@FunctionalInterface
|
||||
public interface Insert {
|
||||
|
||||
List<String> insert(Long personId);
|
||||
List<String> insert(String personId);
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>godfather-bot</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bot-core</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>bot-data</artifactId>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-data</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -8,16 +8,16 @@ import java.util.Map;
|
||||
|
||||
public interface StorylineContext {
|
||||
|
||||
Uni<Void> save(@NotNull Long telegramId, @NotNull ContextKey<?> key, Object objectForSave);
|
||||
Uni<Void> save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave);
|
||||
|
||||
<T> Uni<T> getByKey(@NotNull Long telegramId, @NotNull ContextKey<T> key);
|
||||
<T> Uni<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key);
|
||||
|
||||
<T> Uni<T> getByKeyOrThrow(@NotNull Long telegramId, @NotNull ContextKey<T> key);
|
||||
<T> Uni<T> getByKeyOrThrow(@NotNull String personId, @NotNull ContextKey<T> key);
|
||||
|
||||
Uni<Map<String, Object>> getAllSaveElement(@NotNull Long telegramId);
|
||||
Uni<Map<String, Object>> getAllSaveElement(@NotNull String personId);
|
||||
|
||||
Uni<Void> removeAll(@NotNull Long telegramId);
|
||||
Uni<Void> removeAll(@NotNull String personId);
|
||||
|
||||
Uni<Void> removeByKey(@NotNull Long telegramId, @NotNull ContextKey<?> key);
|
||||
Uni<Void> removeByKey(@NotNull String personId, @NotNull ContextKey<?> key);
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ public interface AnswerSavePreservable<T> extends Preservable<T> {
|
||||
*
|
||||
* @param personId Идентификатор пользователя
|
||||
*/
|
||||
Uni<Void> push(Long personId, Pusher<T> pusher);
|
||||
Uni<Void> push(String personId, Pusher<T> pusher);
|
||||
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ public interface Preservable<S> {
|
||||
* @param personId Идентификатор пользователя
|
||||
* @param save Объект данных
|
||||
*/
|
||||
Uni<Void> save(Long personId, String key, S save);
|
||||
Uni<Void> save(String personId, String key, S save);
|
||||
|
||||
Uni<S> getByKey(Long personId, String key);
|
||||
Uni<S> getByKey(String personId, String key);
|
||||
|
||||
Uni<Map<String, S>> getAllSaveElement(Long personId);
|
||||
Uni<Map<String, S>> getAllSaveElement(String personId);
|
||||
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import java.util.Set;
|
||||
|
||||
public interface PersonSettingRepository {
|
||||
|
||||
Uni<Set<Long>> findAllByAllowedProcessing(Set<Long> personIds);
|
||||
Uni<Set<String>> findAllByAllowedProcessing(Set<String> personIds);
|
||||
|
||||
Uni<Void> disableMessageProcessing(Long personId);
|
||||
Uni<Void> disableMessageProcessing(String personId);
|
||||
|
||||
Uni<Void> enableMessageProcessing(Long personId);
|
||||
Uni<Void> enableMessageProcessing(String personId);
|
||||
|
||||
Uni<Boolean> findStateByPersonId(Long personId);
|
||||
Uni<Boolean> findStateByPersonId(String personId);
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ public interface StorylineRepository {
|
||||
|
||||
Uni<Void> save(@NotNull StorylineHistory storylineHistory);
|
||||
|
||||
Uni<StorylineHistory> findByCountLast(long personId, int countUnitsToBack);
|
||||
Uni<StorylineHistory> findByCountLast(String personId, int countUnitsToBack);
|
||||
|
||||
Uni<StorylineHistory> findByCountLast(long personId, String unitName);
|
||||
Uni<StorylineHistory> findByCountLast(String personId, String unitName);
|
||||
|
||||
Uni<Void> cleanHistoryByPersonId(@NotNull Long personId);
|
||||
Uni<Void> cleanHistoryByPersonId(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ public interface UnitPointerRepository {
|
||||
|
||||
Uni<UnitPointer> save(@NotNull UnitPointer unitPointer);
|
||||
|
||||
Uni<String> findUnitNameByPersonId(@NotNull Long personId);
|
||||
Uni<String> findUnitNameByPersonId(@NotNull String personId);
|
||||
|
||||
Uni<Void> removeByPersonId(@NotNull Long personId);
|
||||
Uni<Void> removeByPersonId(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -12,16 +12,16 @@ import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
||||
|
||||
public class AnswerSaveMapPreservable<S> implements AnswerSavePreservable<S> {
|
||||
|
||||
private final Map<Long, Map<String, S>> saveMap = new HashMap<>();
|
||||
private final Map<String, Map<String, S>> saveMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Uni<Void> save(Long personId, String key, S save) {
|
||||
public Uni<Void> save(String personId, String key, S save) {
|
||||
saveMap.computeIfAbsent(personId, k -> new HashMap<>()).put(key, save);
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<S> getByKey(Long personId, String key) {
|
||||
public Uni<S> getByKey(String personId, String key) {
|
||||
if (saveMap.containsKey(personId)
|
||||
&& saveMap.get(personId).containsKey(key)) {
|
||||
return Uni.createFrom().item(saveMap.get(personId).get(key));
|
||||
@ -30,12 +30,12 @@ public class AnswerSaveMapPreservable<S> implements AnswerSavePreservable<S> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Map<String, S>> getAllSaveElement(Long personId) {
|
||||
public Uni<Map<String, S>> getAllSaveElement(String personId) {
|
||||
return Uni.createFrom().item(saveMap.get(personId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> push(Long personId, Pusher<S> pusher) {
|
||||
public Uni<Void> push(String personId, Pusher<S> pusher) {
|
||||
if (checkNotNull(pusher)) {
|
||||
return getAllSaveElement(personId).onItem()
|
||||
.transformToUni(
|
||||
|
@ -10,10 +10,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class PersonSettingLocalRepository implements PersonSettingRepository {
|
||||
|
||||
private final Map<Long, Boolean> map = new HashMap<>();
|
||||
private final Map<String, Boolean> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Uni<Set<Long>> findAllByAllowedProcessing(Set<Long> personIds) {
|
||||
public Uni<Set<String>> findAllByAllowedProcessing(Set<String> personIds) {
|
||||
return Uni.createFrom().item(
|
||||
personIds.stream()
|
||||
.filter(map::get)
|
||||
@ -22,19 +22,19 @@ public class PersonSettingLocalRepository implements PersonSettingRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> disableMessageProcessing(Long personId) {
|
||||
public Uni<Void> disableMessageProcessing(String personId) {
|
||||
map.put(personId, false);
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> enableMessageProcessing(Long personId) {
|
||||
public Uni<Void> enableMessageProcessing(String personId) {
|
||||
map.put(personId, true);
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Boolean> findStateByPersonId(Long personId) {
|
||||
public Uni<Boolean> findStateByPersonId(String personId) {
|
||||
return Uni.createFrom().item(map.get(personId));
|
||||
}
|
||||
|
||||
|
@ -13,19 +13,19 @@ import java.util.Stack;
|
||||
|
||||
public class StorylineMapRepository implements StorylineRepository {
|
||||
|
||||
private final Map<Long, Stack<StorylineHistory>> map = new HashMap<>();
|
||||
private final Map<Long, Set<String>> historyUnitName = new HashMap<>();
|
||||
private final Map<String, Stack<StorylineHistory>> map = new HashMap<>();
|
||||
private final Map<String, Set<String>> historyUnitName = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Uni<Void> save(@NotNull StorylineHistory history) {
|
||||
final Long personId = history.getPersonId();
|
||||
final String personId = history.getPersonId();
|
||||
map.computeIfAbsent(personId, k -> new Stack<>()).push(history);
|
||||
historyUnitName.computeIfAbsent(personId, k -> new HashSet<>()).add(history.getUnitName());
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<StorylineHistory> findByCountLast(long personId, int countUnitsToBack) {
|
||||
public Uni<StorylineHistory> findByCountLast(String personId, int countUnitsToBack) {
|
||||
if (map.containsKey(personId)) {
|
||||
final Stack<StorylineHistory> stack = map.get(personId);
|
||||
if (stack.size() < countUnitsToBack) {
|
||||
@ -42,7 +42,7 @@ public class StorylineMapRepository implements StorylineRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<StorylineHistory> findByCountLast(long personId, String unitName) {
|
||||
public Uni<StorylineHistory> findByCountLast(String personId, String unitName) {
|
||||
if (map.containsKey(personId)) {
|
||||
final Stack<StorylineHistory> stack = map.get(personId);
|
||||
StorylineHistory storylineHistory;
|
||||
@ -58,7 +58,7 @@ public class StorylineMapRepository implements StorylineRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> cleanHistoryByPersonId(@NotNull Long personId) {
|
||||
public Uni<Void> cleanHistoryByPersonId(@NotNull String personId) {
|
||||
if (map.containsKey(personId)) {
|
||||
map.get(personId).clear();
|
||||
} else {
|
||||
|
@ -10,7 +10,7 @@ import java.util.Map;
|
||||
|
||||
public class UnitPointLocalRepository implements UnitPointerRepository {
|
||||
|
||||
public final Map<Long, String> map = new HashMap<>();
|
||||
public final Map<String, String> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Uni<UnitPointer> save(@NotNull UnitPointer unitPointer) {
|
||||
@ -19,12 +19,12 @@ public class UnitPointLocalRepository implements UnitPointerRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<String> findUnitNameByPersonId(@NotNull Long personId) {
|
||||
public Uni<String> findUnitNameByPersonId(@NotNull String personId) {
|
||||
return Uni.createFrom().item(map.get(personId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> removeByPersonId(@NotNull Long personId) {
|
||||
public Uni<Void> removeByPersonId(@NotNull String personId) {
|
||||
map.remove(personId);
|
||||
return Uni.createFrom().voidItem();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>bot-data</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -8,16 +8,16 @@ import java.util.Optional;
|
||||
|
||||
public interface StorylineContext {
|
||||
|
||||
void save(@NotNull Long telegramId, @NotNull ContextKey<?> key, Object objectForSave);
|
||||
void save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave);
|
||||
|
||||
<T> Optional<T> getByKey(@NotNull Long telegramId, @NotNull ContextKey<T> key);
|
||||
<T> Optional<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key);
|
||||
|
||||
<T> T getByKeyOrThrow(@NotNull Long telegramId, @NotNull ContextKey<T> key);
|
||||
<T> T getByKeyOrThrow(@NotNull String personId, @NotNull ContextKey<T> key);
|
||||
|
||||
Map<String, Object> getAllSaveElement(@NotNull Long telegramId);
|
||||
Map<String, Object> getAllSaveElement(@NotNull String personId);
|
||||
|
||||
void removeAll(@NotNull Long telegramId);
|
||||
void removeAll(@NotNull String personId);
|
||||
|
||||
void removeByKey(@NotNull Long telegramId, @NotNull ContextKey<?> key);
|
||||
void removeByKey(@NotNull String personId, @NotNull ContextKey<?> key);
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ public interface AnswerSavePreservable<T> extends Preservable<T> {
|
||||
*
|
||||
* @param personId Идентификатор пользователя
|
||||
*/
|
||||
void push(Long personId, Pusher<T> pusher);
|
||||
void push(String personId, Pusher<T> pusher);
|
||||
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ public interface Preservable<S> {
|
||||
* @param personId Идентификатор пользователя
|
||||
* @param save Объект данных
|
||||
*/
|
||||
void save(Long personId, String key, S save);
|
||||
void save(String personId, String key, S save);
|
||||
|
||||
Optional<S> getByKey(Long personId, String key);
|
||||
Optional<S> getByKey(String personId, String key);
|
||||
|
||||
Map<String, S> getAllSaveElement(Long personId);
|
||||
Map<String, S> getAllSaveElement(String personId);
|
||||
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ import java.util.Set;
|
||||
|
||||
public interface PersonSettingRepository {
|
||||
|
||||
Set<Long> findAllByAllowedProcessing(Set<Long> personIds);
|
||||
Set<String> findAllByAllowedProcessing(Set<String> personIds);
|
||||
|
||||
void disableMessageProcessing(Long personId);
|
||||
void disableMessageProcessing(String personId);
|
||||
|
||||
void enableMessageProcessing(Long personId);
|
||||
void enableMessageProcessing(String personId);
|
||||
|
||||
Optional<Boolean> findStateByPersonId(Long personId);
|
||||
Optional<Boolean> findStateByPersonId(String personId);
|
||||
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ public interface StorylineRepository {
|
||||
|
||||
void save(@NotNull StorylineHistory storylineHistory);
|
||||
|
||||
Optional<StorylineHistory> findByCountLast(long personId, int countUnitsToBack);
|
||||
Optional<StorylineHistory> findByCountLast(String personId, int countUnitsToBack);
|
||||
|
||||
Optional<StorylineHistory> findByCountLast(long personId, String unitName);
|
||||
Optional<StorylineHistory> findByCountLast(String personId, String unitName);
|
||||
|
||||
void cleanHistoryByPersonId(@NotNull Long personId);
|
||||
void cleanHistoryByPersonId(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ public interface UnitPointerRepository {
|
||||
|
||||
UnitPointer save(@NotNull UnitPointer unitPointer);
|
||||
|
||||
Optional<String> findUnitNameByPersonId(@NotNull Long personId);
|
||||
Optional<String> findUnitNameByPersonId(@NotNull String personId);
|
||||
|
||||
void removeByPersonId(@NotNull Long personId);
|
||||
void removeByPersonId(@NotNull String personId);
|
||||
|
||||
}
|
||||
|
@ -9,15 +9,15 @@ import java.util.Optional;
|
||||
|
||||
public class AnswerSaveMapPreservable<S> implements AnswerSavePreservable<S> {
|
||||
|
||||
private final Map<Long, Map<String, S>> saveMap = new HashMap<>();
|
||||
private final Map<String, Map<String, S>> saveMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void save(Long personId, String key, S save) {
|
||||
public void save(String personId, String key, S save) {
|
||||
saveMap.computeIfAbsent(personId, k -> new HashMap<>()).put(key, save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<S> getByKey(Long personId, String key) {
|
||||
public Optional<S> getByKey(String personId, String key) {
|
||||
if (saveMap.containsKey(personId)
|
||||
&& saveMap.get(personId).containsKey(key)) {
|
||||
return Optional.of(saveMap.get(personId).get(key));
|
||||
@ -26,12 +26,12 @@ public class AnswerSaveMapPreservable<S> implements AnswerSavePreservable<S> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, S> getAllSaveElement(Long personId) {
|
||||
public Map<String, S> getAllSaveElement(String personId) {
|
||||
return saveMap.get(personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void push(Long personId, Pusher<S> pusher) {
|
||||
public void push(String personId, Pusher<S> pusher) {
|
||||
Optional.ofNullable(pusher).ifPresent(sPusher -> sPusher.push(personId, getAllSaveElement(personId)));
|
||||
}
|
||||
|
||||
|
@ -10,27 +10,27 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class PersonSettingLocalRepository implements PersonSettingRepository {
|
||||
|
||||
private final Map<Long, Boolean> map = new HashMap<>();
|
||||
private final Map<String, Boolean> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Set<Long> findAllByAllowedProcessing(Set<Long> personIds) {
|
||||
public Set<String> findAllByAllowedProcessing(Set<String> personIds) {
|
||||
return personIds.stream()
|
||||
.filter(map::get)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableMessageProcessing(Long personId) {
|
||||
public void disableMessageProcessing(String personId) {
|
||||
map.put(personId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableMessageProcessing(Long personId) {
|
||||
public void enableMessageProcessing(String personId) {
|
||||
map.put(personId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Boolean> findStateByPersonId(Long personId) {
|
||||
public Optional<Boolean> findStateByPersonId(String personId) {
|
||||
return Optional.ofNullable(map.get(personId));
|
||||
}
|
||||
|
||||
|
@ -13,18 +13,18 @@ import java.util.Stack;
|
||||
|
||||
public class StorylineMapRepository implements StorylineRepository {
|
||||
|
||||
private final Map<Long, Stack<StorylineHistory>> map = new HashMap<>();
|
||||
private final Map<Long, Set<String>> historyUnitName = new HashMap<>();
|
||||
private final Map<String, Stack<StorylineHistory>> map = new HashMap<>();
|
||||
private final Map<String, Set<String>> historyUnitName = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void save(@NotNull StorylineHistory history) {
|
||||
final Long personId = history.getPersonId();
|
||||
final String personId = history.getPersonId();
|
||||
map.computeIfAbsent(personId, k -> new Stack<>()).push(history);
|
||||
historyUnitName.computeIfAbsent(personId, k -> new HashSet<>()).add(history.getUnitName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StorylineHistory> findByCountLast(long personId, int countUnitsToBack) {
|
||||
public Optional<StorylineHistory> findByCountLast(String personId, int countUnitsToBack) {
|
||||
if (map.containsKey(personId)) {
|
||||
final Stack<StorylineHistory> stack = map.get(personId);
|
||||
if (stack.size() < countUnitsToBack) {
|
||||
@ -41,7 +41,7 @@ public class StorylineMapRepository implements StorylineRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StorylineHistory> findByCountLast(long personId, String unitName) {
|
||||
public Optional<StorylineHistory> findByCountLast(String personId, String unitName) {
|
||||
if (map.containsKey(personId)) {
|
||||
final Stack<StorylineHistory> stack = map.get(personId);
|
||||
StorylineHistory storylineHistory;
|
||||
@ -57,7 +57,7 @@ public class StorylineMapRepository implements StorylineRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanHistoryByPersonId(@NotNull Long personId) {
|
||||
public void cleanHistoryByPersonId(@NotNull String personId) {
|
||||
if (map.containsKey(personId)) {
|
||||
map.get(personId).clear();
|
||||
} else {
|
||||
|
@ -10,7 +10,7 @@ import java.util.Optional;
|
||||
|
||||
public class UnitPointLocalRepository implements UnitPointerRepository {
|
||||
|
||||
public final Map<Long, String> map = new HashMap<>();
|
||||
public final Map<String, String> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public UnitPointer save(@NotNull UnitPointer unitPointer) {
|
||||
@ -19,12 +19,12 @@ public class UnitPointLocalRepository implements UnitPointerRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> findUnitNameByPersonId(@NotNull Long personId) {
|
||||
public Optional<String> findUnitNameByPersonId(@NotNull String personId) {
|
||||
return Optional.ofNullable(map.get(personId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByPersonId(@NotNull Long personId) {
|
||||
public void removeByPersonId(@NotNull String personId) {
|
||||
map.remove(personId);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>godfather-bot</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>bot-domain</artifactId>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,15 +5,15 @@ import dev.struchkov.godfather.main.domain.content.Message;
|
||||
|
||||
public class StorylineHistory {
|
||||
|
||||
private Long personId;
|
||||
private String personId;
|
||||
private String unitName;
|
||||
private Message message;
|
||||
|
||||
public Long getPersonId() {
|
||||
public String getPersonId() {
|
||||
return personId;
|
||||
}
|
||||
|
||||
public void setPersonId(Long personId) {
|
||||
public void setPersonId(String personId) {
|
||||
this.personId = personId;
|
||||
}
|
||||
|
||||
|
@ -4,15 +4,15 @@ import java.util.Objects;
|
||||
|
||||
public class UnitPointer {
|
||||
|
||||
private Long personId;
|
||||
private String personId;
|
||||
private String unitName;
|
||||
|
||||
public UnitPointer(Long personId, String unitName) {
|
||||
public UnitPointer(String personId, String unitName) {
|
||||
this.personId = personId;
|
||||
this.unitName = unitName;
|
||||
}
|
||||
|
||||
public Long getPersonId() {
|
||||
public String getPersonId() {
|
||||
return personId;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public abstract class Message implements DeliverableText {
|
||||
/**
|
||||
* Идентификатор пользователя, отправившего сообщение.
|
||||
*/
|
||||
private Long personId;
|
||||
private String personId;
|
||||
|
||||
/**
|
||||
* Текстовое сообщение.
|
||||
@ -58,11 +58,11 @@ public abstract class Message implements DeliverableText {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Long getPersonId() {
|
||||
public String getPersonId() {
|
||||
return personId;
|
||||
}
|
||||
|
||||
public void setPersonId(Long personId) {
|
||||
public void setPersonId(String personId) {
|
||||
this.personId = personId;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>godfather-bot</artifactId>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.godfather</groupId>
|
||||
<artifactId>godfather-bot</artifactId>
|
||||
<version>0.0.27</version>
|
||||
<version>0.0.29</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user