Новая система выборки новых сообщений
Ломбок
This commit is contained in:
parent
198bb8599b
commit
8d1532b561
12
pom.xml
12
pom.xml
@ -26,6 +26,10 @@
|
||||
<gson.ver>2.8.5</gson.ver>
|
||||
<slf4j.ver>1.7.26</slf4j.ver>
|
||||
<mail.ver>1.4</mail.ver>
|
||||
<lombok.ver>1.18.8</lombok.ver>
|
||||
<spring.data.jpa.ver>2.1.3.RELEASE</spring.data.jpa.ver>
|
||||
<javax.persistence.api.ver>2.2</javax.persistence.api.ver>
|
||||
<validation.api.ver>2.0.1.Final</validation.api.ver>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -50,22 +54,22 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.8</version>
|
||||
<version>${lombok.ver}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jpa</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<version>${spring.data.jpa.ver}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>${javax.persistence.api.ver}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
<version>${validation.api.ver}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
package org.sadtech.social.core.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
* Основная сущность для сокрытия id у других сущностей.
|
||||
*
|
||||
* @author upagge [28/07/2019]
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@MappedSuperclass
|
||||
public class BasicEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
protected Integer id;
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package org.sadtech.social.core.domain.content;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.sadtech.social.core.domain.content.attachment.Attachment;
|
||||
import org.sadtech.social.core.utils.Description;
|
||||
|
||||
@ -21,6 +22,7 @@ import java.util.List;
|
||||
@Entity
|
||||
@Table(name = "mail")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class Mail extends Message {
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
|
@ -1,13 +1,13 @@
|
||||
package org.sadtech.social.core.domain.content;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.sadtech.social.core.domain.BasicEntity;
|
||||
import org.sadtech.social.core.utils.Description;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
@ -17,14 +17,11 @@ import java.time.LocalDateTime;
|
||||
*
|
||||
* @author upagge [08/07/2019]
|
||||
*/
|
||||
@Data
|
||||
@MappedSuperclass
|
||||
public abstract class Message {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Description("Идентификатор сообщения")
|
||||
private Integer id;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@MappedSuperclass
|
||||
public abstract class Message extends BasicEntity {
|
||||
|
||||
@Column(name = "type")
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
|
@ -0,0 +1,30 @@
|
||||
package org.sadtech.social.core.domain.jpa;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.social.core.domain.BasicEntity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
||||
*
|
||||
* @author upagge [28/07/2019]
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Entity
|
||||
@Table(name = "event")
|
||||
public class JsonObjectId extends BasicEntity {
|
||||
|
||||
@Column(name = "json")
|
||||
@NonNull
|
||||
private JsonObject jsonObject;
|
||||
|
||||
}
|
@ -1,24 +1,20 @@
|
||||
package org.sadtech.social.core.repository.impl.jpa;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.social.core.domain.money.Account;
|
||||
import org.sadtech.social.core.repository.AccountRepository;
|
||||
import org.sadtech.social.core.repository.jpa.AccountRepositoryJpa;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
||||
*
|
||||
* @author upagge [27/07/2019]
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class AccountRepositoryJpaImpl implements AccountRepository {
|
||||
|
||||
private final AccountRepositoryJpa accountRepositoryJpa;
|
||||
|
||||
@Autowired
|
||||
public AccountRepositoryJpaImpl(AccountRepositoryJpa accountRepositoryJpa) {
|
||||
this.accountRepositoryJpa = accountRepositoryJpa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer add(Account account) {
|
||||
return accountRepositoryJpa.saveAndFlush(account).getId();
|
||||
|
@ -0,0 +1,42 @@
|
||||
package org.sadtech.social.core.repository.impl.jpa;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.sadtech.social.core.domain.jpa.JsonObjectId;
|
||||
import org.sadtech.social.core.repository.EventRepository;
|
||||
import org.sadtech.social.core.repository.jpa.EventRepositoryJpa;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
||||
*
|
||||
* @author upagge [28/07/2019]
|
||||
*/
|
||||
public class EventRepositoryJpaImpl implements EventRepository<JsonObject> {
|
||||
|
||||
private final EventRepositoryJpa eventRepositoryJpa;
|
||||
|
||||
public EventRepositoryJpaImpl(EventRepositoryJpa eventRepositoryJpa) {
|
||||
this.eventRepositoryJpa = eventRepositoryJpa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(JsonObject dataObject) {
|
||||
eventRepositoryJpa.saveAndFlush(new JsonObjectId(dataObject));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanAll() {
|
||||
eventRepositoryJpa.deleteAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Queue<JsonObject> getEventQueue() {
|
||||
List<JsonObjectId> allEvent = eventRepositoryJpa.findAll();
|
||||
eventRepositoryJpa.deleteAll(allEvent);
|
||||
return allEvent.stream().map(JsonObjectId::getJsonObject).collect(Collectors.toCollection(ConcurrentLinkedQueue::new));
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package org.sadtech.social.core.repository.impl.jpa;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.sadtech.social.core.repository.ContentRepository;
|
||||
import org.sadtech.social.core.repository.jpa.MailRepositoryJpa;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@ -13,15 +13,11 @@ import java.util.List;
|
||||
*
|
||||
* @author upagge [25/07/2019]
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class MailRepositoryJpaImpl implements ContentRepository<Mail> {
|
||||
|
||||
private final MailRepositoryJpa mailRepositoryJpa;
|
||||
|
||||
@Autowired
|
||||
public MailRepositoryJpaImpl(MailRepositoryJpa mailRepositoryJpa) {
|
||||
this.mailRepositoryJpa = mailRepositoryJpa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer add(Mail content) {
|
||||
return mailRepositoryJpa.saveAndFlush(content).getId();
|
||||
|
@ -0,0 +1,15 @@
|
||||
package org.sadtech.social.core.repository.jpa;
|
||||
|
||||
import org.sadtech.social.core.domain.jpa.JsonObjectId;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание интерфейса.
|
||||
*
|
||||
* @author upagge [28/07/2019]
|
||||
*/
|
||||
@Repository
|
||||
public interface EventRepositoryJpa extends JpaRepository<JsonObjectId, Integer> {
|
||||
|
||||
}
|
@ -1,19 +1,17 @@
|
||||
package org.sadtech.social.core.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.social.core.domain.money.Account;
|
||||
import org.sadtech.social.core.domain.money.AccountStatus;
|
||||
import org.sadtech.social.core.exception.PaymentException;
|
||||
import org.sadtech.social.core.repository.AccountRepository;
|
||||
import org.sadtech.social.core.service.AccountService;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class AccountServiceImpl implements AccountService {
|
||||
|
||||
private final AccountRepository accountRepository;
|
||||
|
||||
public AccountServiceImpl(AccountRepository accountRepository) {
|
||||
this.accountRepository = accountRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer add(Account account) {
|
||||
account.setAccountStatus(AccountStatus.EXPOSED);
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.sadtech.social.core.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.sadtech.social.core.domain.content.BoardComment;
|
||||
import org.sadtech.social.core.repository.ContentRepository;
|
||||
import org.sadtech.social.core.service.BoardCommentService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@ -12,16 +12,12 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class BoardCommentServiceImpl implements BoardCommentService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BoardCommentServiceImpl.class);
|
||||
|
||||
private final ContentRepository<BoardComment> commentRepository;
|
||||
|
||||
public BoardCommentServiceImpl(ContentRepository<BoardComment> commentRepository) {
|
||||
this.commentRepository = commentRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(BoardComment event) {
|
||||
commentRepository.add(event);
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.sadtech.social.core.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.sadtech.social.core.repository.ContentRepository;
|
||||
import org.sadtech.social.core.service.MailService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@ -12,16 +12,12 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class MailServiceImpl implements MailService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MailServiceImpl.class);
|
||||
|
||||
private final ContentRepository<Mail> mailRepository;
|
||||
|
||||
public MailServiceImpl(ContentRepository<Mail> mailRepository) {
|
||||
this.mailRepository = mailRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Mail mail) {
|
||||
mailRepository.add(mail);
|
||||
|
@ -1,23 +1,19 @@
|
||||
package org.sadtech.social.core.service.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.sadtech.social.core.repository.EventRepository;
|
||||
import org.sadtech.social.core.service.RawEventService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class RawEventServiceImpl implements RawEventService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RawEventServiceImpl.class);
|
||||
|
||||
private final EventRepository<JsonObject> eventRepository;
|
||||
|
||||
public RawEventServiceImpl(EventRepository<JsonObject> eventRepository) {
|
||||
this.eventRepository = eventRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanAll() {
|
||||
eventRepository.cleanAll();
|
||||
|
@ -1,7 +1,10 @@
|
||||
package org.sadtech.social.core.service.sender.email;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Getter
|
||||
public class EmailConfig {
|
||||
|
||||
private Properties props = new Properties();
|
||||
@ -12,18 +15,6 @@ public class EmailConfig {
|
||||
|
||||
}
|
||||
|
||||
public Properties getProps() {
|
||||
return props;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new EmailConfig().new Builder();
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.sadtech.social.core.service.sender.email;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.sadtech.social.core.domain.BoxAnswer;
|
||||
import org.sadtech.social.core.exception.MailSendException;
|
||||
import org.sadtech.social.core.service.sender.Sent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.Message;
|
||||
@ -15,16 +15,12 @@ import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class EmailSent implements Sent {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Sent.class);
|
||||
|
||||
private final EmailConfig emailConfig;
|
||||
|
||||
public EmailSent(EmailConfig emailConfig) {
|
||||
this.emailConfig = emailConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Integer personId, BoxAnswer boxAnswer) {
|
||||
Session session = Session.getDefaultInstance(emailConfig.getProps(), new Authenticator() {
|
||||
|
Loading…
Reference in New Issue
Block a user