diff --git a/pom.xml b/pom.xml index f48b5bd..030d9ff 100644 --- a/pom.xml +++ b/pom.xml @@ -24,9 +24,9 @@ 2.8.5 - 1.7.26 + 1.7.29 1.4 - 1.18.8 + 1.18.10 2.1.3.RELEASE 2.2 2.0.1.Final diff --git a/src/main/java/org/sadtech/social/core/domain/BasicEntity.java b/src/main/java/org/sadtech/social/core/domain/BasicEntity.java index b9e9955..1632fce 100644 --- a/src/main/java/org/sadtech/social/core/domain/BasicEntity.java +++ b/src/main/java/org/sadtech/social/core/domain/BasicEntity.java @@ -19,6 +19,6 @@ public class BasicEntity { @Id @GeneratedValue - protected Integer id; + protected Long id; } diff --git a/src/main/java/org/sadtech/social/core/domain/content/Comment.java b/src/main/java/org/sadtech/social/core/domain/content/Comment.java index 612fd0f..db00e88 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/Comment.java +++ b/src/main/java/org/sadtech/social/core/domain/content/Comment.java @@ -14,6 +14,6 @@ import org.sadtech.social.core.utils.Description; public abstract class Comment extends Message { @Description("Идентификатор контента, к которому ставлено сообщение") - private Integer contentId; + private Long contentId; } diff --git a/src/main/java/org/sadtech/social/core/domain/content/EmptyMessage.java b/src/main/java/org/sadtech/social/core/domain/content/EmptyMessage.java index 0dcd3ae..d628827 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/EmptyMessage.java +++ b/src/main/java/org/sadtech/social/core/domain/content/EmptyMessage.java @@ -22,6 +22,6 @@ public class EmptyMessage extends Message { @Override public void setText(String text) { - throw new AppBotException(0, "EmptyMessage no setText"); + throw new AppBotException("EmptyMessage no setText"); } } diff --git a/src/main/java/org/sadtech/social/core/domain/content/Message.java b/src/main/java/org/sadtech/social/core/domain/content/Message.java index 37e030c..eb3a322 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/Message.java +++ b/src/main/java/org/sadtech/social/core/domain/content/Message.java @@ -40,7 +40,7 @@ public abstract class Message extends BasicEntity { @NotNull @Column(name = "person_id") @Description("Идентификатор пользователя, отправившего сообщение") - private Integer personId; + private Long personId; @Column(name = "text") @Description("Текстовое сообщение") diff --git a/src/main/java/org/sadtech/social/core/domain/money/Account.java b/src/main/java/org/sadtech/social/core/domain/money/Account.java index 2e4a5d2..62d8b40 100644 --- a/src/main/java/org/sadtech/social/core/domain/money/Account.java +++ b/src/main/java/org/sadtech/social/core/domain/money/Account.java @@ -40,7 +40,7 @@ public class Account { @Column(name = "belongs_person_id") @Description("Идентификатор пользователя, которому выставлен счет") - private Integer belongsPersonId; + private Long belongsPersonId; @Column(name = "extinguished_person_id") @Description("Идентификатор пользователя, который оплатил счет") diff --git a/src/main/java/org/sadtech/social/core/exception/AccessException.java b/src/main/java/org/sadtech/social/core/exception/AccessException.java index 7bd1fec..ddf55ed 100644 --- a/src/main/java/org/sadtech/social/core/exception/AccessException.java +++ b/src/main/java/org/sadtech/social/core/exception/AccessException.java @@ -6,7 +6,7 @@ package org.sadtech.social.core.exception; * @author upagge [08/07/2019] */ public class AccessException extends AppBotException { - public AccessException(Integer code, String message) { - super(code, message); + public AccessException(String message) { + super(message); } } diff --git a/src/main/java/org/sadtech/social/core/exception/AppBotException.java b/src/main/java/org/sadtech/social/core/exception/AppBotException.java index 32ad753..4e2bb04 100644 --- a/src/main/java/org/sadtech/social/core/exception/AppBotException.java +++ b/src/main/java/org/sadtech/social/core/exception/AppBotException.java @@ -11,12 +11,15 @@ public class AppBotException extends RuntimeException { private static final String TYPE = "ERROR"; private final LocalDateTime timeError = LocalDateTime.now(); - protected final Integer code; - protected final String description; + protected String description; - public AppBotException(Integer code, String message) { - this.description = message; - this.code = code; + public AppBotException(String message) { + super(message); + } + + public AppBotException(String message, String description) { + super(message); + this.description = description; } public String getType() { @@ -27,10 +30,6 @@ public class AppBotException extends RuntimeException { return timeError; } - public Integer getCode() { - return code; - } - public String getDescription() { return description; } diff --git a/src/main/java/org/sadtech/social/core/exception/ConfigAppException.java b/src/main/java/org/sadtech/social/core/exception/ConfigAppException.java index 509709e..e39e11c 100644 --- a/src/main/java/org/sadtech/social/core/exception/ConfigAppException.java +++ b/src/main/java/org/sadtech/social/core/exception/ConfigAppException.java @@ -6,7 +6,7 @@ package org.sadtech.social.core.exception; * @author upagge [11/07/2019] */ public class ConfigAppException extends AppBotException { - public ConfigAppException(Integer code, String message) { - super(code, message); + public ConfigAppException(String message) { + super(message); } } diff --git a/src/main/java/org/sadtech/social/core/exception/MailSendException.java b/src/main/java/org/sadtech/social/core/exception/MailSendException.java index e6a2220..93cc175 100644 --- a/src/main/java/org/sadtech/social/core/exception/MailSendException.java +++ b/src/main/java/org/sadtech/social/core/exception/MailSendException.java @@ -8,7 +8,7 @@ package org.sadtech.social.core.exception; public class MailSendException extends AppBotException { public MailSendException() { - super(1, "Ошибка отправки сообщения"); + super("Ошибка отправки сообщения"); } } diff --git a/src/main/java/org/sadtech/social/core/exception/NotFoundException.java b/src/main/java/org/sadtech/social/core/exception/NotFoundException.java index b7b75a9..a80b38c 100644 --- a/src/main/java/org/sadtech/social/core/exception/NotFoundException.java +++ b/src/main/java/org/sadtech/social/core/exception/NotFoundException.java @@ -6,7 +6,9 @@ package org.sadtech.social.core.exception; * @author upagge [08/07/2019] */ public class NotFoundException extends AppBotException { - public NotFoundException(Integer code, String message) { - super(code, message); + + public NotFoundException(String message) { + super(message); } + } diff --git a/src/main/java/org/sadtech/social/core/exception/PaymentException.java b/src/main/java/org/sadtech/social/core/exception/PaymentException.java index 0bac9bd..5e0ba0a 100644 --- a/src/main/java/org/sadtech/social/core/exception/PaymentException.java +++ b/src/main/java/org/sadtech/social/core/exception/PaymentException.java @@ -7,8 +7,8 @@ package org.sadtech.social.core.exception; */ public class PaymentException extends AppBotException { - public PaymentException(Integer code, String message) { - super(code, message); + public PaymentException(String message) { + super(message); } } diff --git a/src/main/java/org/sadtech/social/core/exception/TimerSettingException.java b/src/main/java/org/sadtech/social/core/exception/TimerSettingException.java index bb43587..acdf137 100644 --- a/src/main/java/org/sadtech/social/core/exception/TimerSettingException.java +++ b/src/main/java/org/sadtech/social/core/exception/TimerSettingException.java @@ -8,7 +8,7 @@ package org.sadtech.social.core.exception; public class TimerSettingException extends AppBotException { public TimerSettingException(String message) { - super(54, message); + super(message); } } diff --git a/src/main/java/org/sadtech/social/core/repository/ContentRepository.java b/src/main/java/org/sadtech/social/core/repository/ContentRepository.java index 73952ef..1cfc585 100644 --- a/src/main/java/org/sadtech/social/core/repository/ContentRepository.java +++ b/src/main/java/org/sadtech/social/core/repository/ContentRepository.java @@ -18,7 +18,7 @@ public interface ContentRepository { * @param content Объект сообщени * @return Идентификатор сообщения в хранилище */ - Integer add(T content); + T add(T content); /** * Получить все сообщения за определенный временной диапазон diff --git a/src/main/java/org/sadtech/social/core/repository/impl/jpa/MailRepositoryJpaImpl.java b/src/main/java/org/sadtech/social/core/repository/impl/jpa/MailRepositoryJpaImpl.java index 138bc42..3379725 100644 --- a/src/main/java/org/sadtech/social/core/repository/impl/jpa/MailRepositoryJpaImpl.java +++ b/src/main/java/org/sadtech/social/core/repository/impl/jpa/MailRepositoryJpaImpl.java @@ -19,8 +19,8 @@ public class MailRepositoryJpaImpl implements ContentRepository { private final MailRepositoryJpa mailRepositoryJpa; @Override - public Integer add(Mail content) { - return mailRepositoryJpa.saveAndFlush(content).getId(); + public Mail add(Mail content) { + return mailRepositoryJpa.saveAndFlush(content); } @Override diff --git a/src/main/java/org/sadtech/social/core/repository/impl/local/AccountRepositoryMap.java b/src/main/java/org/sadtech/social/core/repository/impl/local/AccountRepositoryMap.java index c952737..d495aa6 100644 --- a/src/main/java/org/sadtech/social/core/repository/impl/local/AccountRepositoryMap.java +++ b/src/main/java/org/sadtech/social/core/repository/impl/local/AccountRepositoryMap.java @@ -22,7 +22,7 @@ public class AccountRepositoryMap implements AccountRepository { saveMap.put(id, account); return id++; } else { - throw new AccessException(312, "Счет " + account.getId() + " уже существует"); + throw new AccessException("Счет " + account.getId() + " уже существует"); } } @@ -33,13 +33,13 @@ public class AccountRepositoryMap implements AccountRepository { account.setId(accountId); saveMap.put(accountId, account); } else { - throw new NotFoundException(491, "Счет " + accountId + " не найден"); + throw new NotFoundException("Счет " + accountId + " не найден"); } } @Override public Account findById(Integer accountId) { - return Optional.ofNullable(saveMap.get(accountId)).orElseThrow(() -> new PaymentException(43, "Счет " + accountId + " не найден")); + return Optional.ofNullable(saveMap.get(accountId)).orElseThrow(() -> new PaymentException("Счет " + accountId + " не найден")); } private boolean check(Integer id) { diff --git a/src/main/java/org/sadtech/social/core/repository/impl/local/BoardCommentRepositoryMap.java b/src/main/java/org/sadtech/social/core/repository/impl/local/BoardCommentRepositoryMap.java index fbd8fc6..3a97de7 100644 --- a/src/main/java/org/sadtech/social/core/repository/impl/local/BoardCommentRepositoryMap.java +++ b/src/main/java/org/sadtech/social/core/repository/impl/local/BoardCommentRepositoryMap.java @@ -11,14 +11,14 @@ import java.util.Map; public class BoardCommentRepositoryMap implements ContentRepository { - private final Map saveMap = new HashMap<>(); - private Integer count = 0; + private final Map saveMap = new HashMap<>(); + private Long count = 0L; @Override - public Integer add(BoardComment comment) { + public BoardComment add(BoardComment comment) { comment.setId(count); - saveMap.put(count, comment); - return count++; + saveMap.put(count++, comment); + return comment; } @Override diff --git a/src/main/java/org/sadtech/social/core/repository/impl/local/MailRepositoryList.java b/src/main/java/org/sadtech/social/core/repository/impl/local/MailRepositoryList.java index 512d0bc..b3aaf2f 100644 --- a/src/main/java/org/sadtech/social/core/repository/impl/local/MailRepositoryList.java +++ b/src/main/java/org/sadtech/social/core/repository/impl/local/MailRepositoryList.java @@ -17,13 +17,13 @@ import java.util.List; public class MailRepositoryList implements ContentRepository { private final List mails = new ArrayList<>(); + private Long count = 0L; @Override - public Integer add(Mail mail) { - int id = mails.size(); - mail.setId(id); + public Mail add(Mail mail) { + mail.setId(count++); mails.add(mail); - return id; + return mail; } @Override diff --git a/src/main/java/org/sadtech/social/core/service/MessageService.java b/src/main/java/org/sadtech/social/core/service/MessageService.java index 9ffaf9c..faf5125 100644 --- a/src/main/java/org/sadtech/social/core/service/MessageService.java +++ b/src/main/java/org/sadtech/social/core/service/MessageService.java @@ -35,11 +35,8 @@ public interface MessageService { List getLastEventByAddDateTime(LocalDateTime timeFrom, LocalDateTime timeTo); /** - * Возвращает новые сообщения пользователей по дате добавления в хранилище. - * - * @param now Текущяя дата и время - * @return Последнее сообщение пользователя от последней переданной даты now + * Возвращает новые сообщения от последнего запроса. */ - List getNewMessage(LocalDateTime now); + List getNewMessage(); } diff --git a/src/main/java/org/sadtech/social/core/service/impl/AccountServiceImpl.java b/src/main/java/org/sadtech/social/core/service/impl/AccountServiceImpl.java index 29797d3..0789326 100644 --- a/src/main/java/org/sadtech/social/core/service/impl/AccountServiceImpl.java +++ b/src/main/java/org/sadtech/social/core/service/impl/AccountServiceImpl.java @@ -29,10 +29,10 @@ public class AccountServiceImpl implements AccountService { } else { account.setAccountStatus(AccountStatus.EXCEPTION); accountRepository.edit(accountId, account); - throw new PaymentException(2, "Неверная сумма"); + throw new PaymentException("Неверная сумма"); } } else { - throw new PaymentException(3, "Счет уже оплачен"); + throw new PaymentException("Счет уже оплачен"); } return true; } diff --git a/src/main/java/org/sadtech/social/core/service/impl/BoardCommentServiceImpl.java b/src/main/java/org/sadtech/social/core/service/impl/BoardCommentServiceImpl.java index d0f2fe5..1d98beb 100644 --- a/src/main/java/org/sadtech/social/core/service/impl/BoardCommentServiceImpl.java +++ b/src/main/java/org/sadtech/social/core/service/impl/BoardCommentServiceImpl.java @@ -43,12 +43,12 @@ public class BoardCommentServiceImpl implements BoardCommentService { } @Override - public List getNewMessage(LocalDateTime now) { + public List getNewMessage() { return null; } private List getBoardComments(List mails) { - Set people = new HashSet<>(); + Set people = new HashSet<>(); List returnMails = new ArrayList<>(); for (int i = mails.size() - 1; i >= 0; i--) { if (!people.contains(mails.get(i).getPersonId())) { diff --git a/src/main/java/org/sadtech/social/core/service/impl/MailServiceImpl.java b/src/main/java/org/sadtech/social/core/service/impl/MailServiceImpl.java index 3e9f35f..74ddf72 100644 --- a/src/main/java/org/sadtech/social/core/service/impl/MailServiceImpl.java +++ b/src/main/java/org/sadtech/social/core/service/impl/MailServiceImpl.java @@ -59,18 +59,19 @@ public class MailServiceImpl implements MailService { } @Override - public List getNewMessage(LocalDateTime now) { + public List getNewMessage() { + LocalDateTime newData = LocalDateTime.now(Clock.tickSeconds(ZoneId.systemDefault())).plusNanos(999999999); List lastEventByAddDateTime = Collections.emptyList(); if (newMessage) { - lastEventByAddDateTime = getLastEventByAddDateTime(oldDateTime, now); + lastEventByAddDateTime = getLastEventByAddDateTime(oldDateTime, newData); newMessage = false; + oldDateTime = newData; } - oldDateTime = now; return lastEventByAddDateTime; } private List getReturnMails(List mails) { - Set people = new HashSet<>(); + Set people = new HashSet<>(); List returnMails = new ArrayList<>(); for (int i = mails.size() - 1; i >= 0; i--) { if (!people.contains(mails.get(i).getPersonId())) { diff --git a/src/main/java/org/sadtech/social/core/service/sender/Sending.java b/src/main/java/org/sadtech/social/core/service/sender/Sending.java index 4759320..a3a7501 100644 --- a/src/main/java/org/sadtech/social/core/service/sender/Sending.java +++ b/src/main/java/org/sadtech/social/core/service/sender/Sending.java @@ -1,5 +1,6 @@ package org.sadtech.social.core.service.sender; +import lombok.NonNull; import org.sadtech.social.core.domain.BoxAnswer; /** @@ -15,9 +16,9 @@ public interface Sending { * @param personId Идентификатор пользователя * @param boxAnswer Объект с данными, которые необходимо отправить */ - void send(Integer personId, BoxAnswer boxAnswer); + void send(@NonNull Long personId, @NonNull BoxAnswer boxAnswer); - void send(Integer contentId, Integer personId, BoxAnswer boxAnswer); + void send(@NonNull Long contentId, @NonNull Long personId, @NonNull BoxAnswer boxAnswer); /** * Возвращает тип объекта отправляющего ответ пользователя. В зависимости от типа ответ будет отправлен с помощью diff --git a/src/main/java/org/sadtech/social/core/service/sender/email/EmailSending.java b/src/main/java/org/sadtech/social/core/service/sender/email/EmailSending.java index 550b6a7..324dec2 100644 --- a/src/main/java/org/sadtech/social/core/service/sender/email/EmailSending.java +++ b/src/main/java/org/sadtech/social/core/service/sender/email/EmailSending.java @@ -1,5 +1,6 @@ package org.sadtech.social.core.service.sender.email; +import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.sadtech.social.core.domain.BoxAnswer; @@ -23,7 +24,7 @@ public class EmailSending implements Sending { private final EmailConfig emailConfig; @Override - public void send(Integer personId, BoxAnswer boxAnswer) { + public void send(@NonNull Long personId, @NonNull BoxAnswer boxAnswer) { Session session = Session.getDefaultInstance(emailConfig.getProps(), new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { @@ -44,7 +45,7 @@ public class EmailSending implements Sending { } @Override - public void send(Integer contentId, Integer personId, BoxAnswer boxAnswer) { + public void send(@NonNull Long contentId, @NonNull Long personId, @NonNull BoxAnswer boxAnswer) { throw new MailSendException(); }