Исправления в проверке новых сообщений от пользователя
Исправления мапинга для бд Переименование метода findByTime в betweenByTime
This commit is contained in:
parent
18fbf8127f
commit
198bb8599b
5
pom.xml
5
pom.xml
@ -62,6 +62,11 @@
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<developers>
|
||||
|
@ -7,6 +7,7 @@ import org.sadtech.social.core.utils.Description;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
@ -22,7 +23,7 @@ import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Mail extends Message {
|
||||
|
||||
@OneToMany
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@Column(name = "attachment")
|
||||
@Description("Вложения к сообщению")
|
||||
private List<Attachment> attachments;
|
||||
|
@ -1,15 +1,15 @@
|
||||
package org.sadtech.social.core.domain.content;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import lombok.Data;
|
||||
import org.sadtech.social.core.utils.Description;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
||||
* @author upagge [08/07/2019]
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@MappedSuperclass
|
||||
public abstract class Message {
|
||||
|
||||
@Id
|
||||
|
@ -1,13 +1,9 @@
|
||||
package org.sadtech.social.core.domain.money;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.sadtech.social.core.utils.Description;
|
||||
|
||||
import javax.persistence.Column;
|
||||
@ -17,6 +13,7 @@ import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Сущность, которая отвечает за выставленный пользователю счет.
|
||||
@ -24,10 +21,7 @@ import javax.persistence.Table;
|
||||
* @author upagge [08/07/2019]
|
||||
*/
|
||||
@Builder
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
|
@ -27,6 +27,6 @@ public interface ContentRepository<T extends Message> {
|
||||
* @param timeTo Конец диапазона
|
||||
* @return Список сообщений
|
||||
*/
|
||||
List<T> findByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
||||
List<T> betweenByTime(LocalDateTime timeFrom, LocalDateTime timeTo);
|
||||
|
||||
}
|
||||
|
@ -3,18 +3,18 @@ package org.sadtech.social.core.repository.impl.jpa;
|
||||
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.stereotype.Repository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание класса.
|
||||
*
|
||||
* @author upagge [27/07/2019]
|
||||
*/
|
||||
@Repository
|
||||
public class AccountRepositoryJpaImpl implements AccountRepository {
|
||||
|
||||
private final AccountRepositoryJpa accountRepositoryJpa;
|
||||
|
||||
@Autowired
|
||||
public AccountRepositoryJpaImpl(AccountRepositoryJpa accountRepositoryJpa) {
|
||||
this.accountRepositoryJpa = accountRepositoryJpa;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package org.sadtech.social.core.repository.impl.jpa;
|
||||
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.stereotype.Repository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@ -13,11 +13,11 @@ import java.util.List;
|
||||
*
|
||||
* @author upagge [25/07/2019]
|
||||
*/
|
||||
@Repository
|
||||
public class MailRepositoryJpaImpl implements ContentRepository<Mail> {
|
||||
|
||||
private final MailRepositoryJpa mailRepositoryJpa;
|
||||
|
||||
@Autowired
|
||||
public MailRepositoryJpaImpl(MailRepositoryJpa mailRepositoryJpa) {
|
||||
this.mailRepositoryJpa = mailRepositoryJpa;
|
||||
}
|
||||
@ -28,7 +28,7 @@ public class MailRepositoryJpaImpl implements ContentRepository<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mail> findByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
public List<Mail> betweenByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
return mailRepositoryJpa.findByCreateDateBetween(timeFrom, timeTo);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class BoardCommentRepositoryMap implements ContentRepository<BoardComment
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BoardComment> findByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
public List<BoardComment> betweenByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
ArrayList<BoardComment> rezultMails = new ArrayList<>();
|
||||
for (int i = saveMap.size() - 1; i >= 0; i--) {
|
||||
if (!(saveMap.get(i).getCreateDate().isBefore(timeFrom) || saveMap.get(i).getCreateDate().isAfter(timeTo)) && saveMap.get(i).getCreateDate().equals(timeFrom)) {
|
||||
|
@ -24,10 +24,10 @@ public class MailRepositoryList implements ContentRepository<Mail> {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Mail> findByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
public List<Mail> betweenByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
ArrayList<Mail> rezultMails = new ArrayList<>();
|
||||
for (int i = mails.size() - 1; i >= 0; i--) {
|
||||
if (!(mails.get(i).getCreateDate().isBefore(timeFrom) || mails.get(i).getCreateDate().isAfter(timeTo)) && mails.get(i).getCreateDate().equals(timeFrom)) {
|
||||
if (!(mails.get(i).getCreateDate().isBefore(timeFrom) || mails.get(i).getCreateDate().isAfter(timeTo))) {
|
||||
rezultMails.add(this.mails.get(i));
|
||||
} else if (mails.get(i).getCreateDate().isBefore(timeFrom)) {
|
||||
break;
|
||||
|
@ -2,12 +2,14 @@ package org.sadtech.social.core.repository.jpa;
|
||||
|
||||
import org.sadtech.social.core.domain.money.Account;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* TODO: Добавить описание интерфейса.
|
||||
*
|
||||
* @author upagge [27/07/2019]
|
||||
*/
|
||||
@Repository
|
||||
public interface AccountRepositoryJpa extends JpaRepository<Account, Integer> {
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.sadtech.social.core.repository.jpa;
|
||||
|
||||
import org.sadtech.social.core.domain.content.Mail;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@ -12,6 +13,7 @@ import java.util.List;
|
||||
*
|
||||
* @author upagge [27/07/2019]
|
||||
*/
|
||||
@Repository
|
||||
public interface MailRepositoryJpa extends JpaRepository<Mail, Integer> {
|
||||
|
||||
List<Mail> findByCreateDateBetween(LocalDateTime from, LocalDateTime to);
|
||||
|
@ -35,7 +35,7 @@ public class BoardCommentServiceImpl implements BoardCommentService {
|
||||
@Override
|
||||
public List<BoardComment> getLastEventByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
log.info("Запрошены последние комментарии к обсуждению {} - {} ", timeFrom, timeTo);
|
||||
List<BoardComment> mails = commentRepository.findByTime(timeFrom, timeTo);
|
||||
List<BoardComment> mails = commentRepository.betweenByTime(timeFrom, timeTo);
|
||||
Set<Integer> people = new HashSet<>();
|
||||
List<BoardComment> returnMails = new ArrayList<>();
|
||||
for (int i = mails.size() - 1; i >= 0; i--) {
|
||||
|
@ -31,7 +31,7 @@ public class MailServiceImpl implements MailService {
|
||||
@Override
|
||||
public List<Mail> getLastEventByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
log.info("Запрошены последние сообщения {} - {} ", timeFrom, timeTo);
|
||||
List<Mail> mails = mailRepository.findByTime(timeFrom, timeTo);
|
||||
List<Mail> mails = mailRepository.betweenByTime(timeFrom, timeTo);
|
||||
Set<Integer> people = new HashSet<>();
|
||||
List<Mail> returnMails = new ArrayList<>();
|
||||
for (int i = mails.size() - 1; i >= 0; i--) {
|
||||
@ -46,7 +46,7 @@ public class MailServiceImpl implements MailService {
|
||||
@Override
|
||||
public List<Mail> getByTime(LocalDateTime timeFrom, LocalDateTime timeTo) {
|
||||
log.info("Запрошены все сообщения {} - {} ", timeFrom, timeTo);
|
||||
return mailRepository.findByTime(timeFrom, timeTo);
|
||||
return mailRepository.betweenByTime(timeFrom, timeTo);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user