Switched from Date to Instant
Was causing issues with json parsing in desktop client
This commit is contained in:
parent
91986d5386
commit
6378f4b225
@ -52,7 +52,7 @@ public class AdminRESTController {
|
||||
public List<ChatMessageDTO> sendNewMessages(@PathVariable String userName,
|
||||
@PathVariable Instant lastMessageTime, Principal principal) {
|
||||
List<ChatMessageDTO> chatMessageDTOs = chatService.getNewMessages(
|
||||
principal.getName(), userName, Date.from(lastMessageTime));
|
||||
principal.getName(), userName, lastMessageTime);
|
||||
return chatMessageDTOs;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package org.ros.chatto.controller;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -91,7 +90,7 @@ public class ChatMessageController {
|
||||
@PathVariable final Instant lastMessageTime,
|
||||
final Principal principal) {
|
||||
final List<ChatMessageDTO> chatMessageDTOs = chatService.getNewMessages(
|
||||
principal.getName(), userName, Date.from(lastMessageTime));
|
||||
principal.getName(), userName, lastMessageTime);
|
||||
return chatMessageDTOs;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.ros.chatto.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.Instant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -18,5 +18,5 @@ public class ChatMessageDTO {
|
||||
@Size(max=15)
|
||||
private String fromUser;
|
||||
private MessageCipherDTO messageCipher;
|
||||
private Date messageTime;
|
||||
private Instant messageTime;
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.time.Instant;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -38,6 +37,5 @@ public class ChatMessage {
|
||||
@JoinColumn(name = "message")
|
||||
private MessageCipher messageCipher;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date messageTime;
|
||||
private Instant messageTime;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.ros.chatto.repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.ros.chatto.model.ChatMessage;
|
||||
@ -8,6 +7,7 @@ import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.time.Instant;
|
||||
|
||||
@Repository
|
||||
public interface ChatMessageRepository extends JpaRepository<ChatMessage, Long> {
|
||||
@ -19,7 +19,7 @@ public interface ChatMessageRepository extends JpaRepository<ChatMessage, Long>
|
||||
@Query("select m from ChatMessage m join fetch m.messageCipher mc join fetch m.toUser tu join fetch m.fromUser fu "
|
||||
+ "where (tu.userName = ?1 or tu.userName = ?2) and "
|
||||
+ "(fu.userName = ?1 or fu.userName = ?2) and (m.messageTime > ?3) order by m.messageTime asc")
|
||||
public List<ChatMessage> getNewMessages(String fromUser, String toUser, Date lastMessageTime);
|
||||
public List<ChatMessage> getNewMessages(String fromUser, String toUser, Instant lastMessageTime);
|
||||
|
||||
@Query("select m from ChatMessage m join fetch m.messageCipher mc join fetch m.toUser tu join fetch m.fromUser fu "
|
||||
+ "where (tu.userName = ?1 or tu.userName = ?2) and "
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.ros.chatto.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.ros.chatto.dto.ChatMessageDTO;
|
||||
import org.ros.chatto.dto.MessageCipherDTO;
|
||||
import org.ros.chatto.dto.ReencryptionDTO;
|
||||
import java.time.Instant;
|
||||
|
||||
public interface ChatService {
|
||||
public ChatMessageDTO createMessage(String fromUser, String toUser,
|
||||
@ -17,7 +17,7 @@ public interface ChatService {
|
||||
int page, int size);
|
||||
|
||||
public List<ChatMessageDTO> getNewMessages(String fromUser, String toUser,
|
||||
Date lastMessageTime);
|
||||
Instant lastMessageTime);
|
||||
|
||||
public void reencryptMessages(List<ReencryptionDTO> reencryptionDTOs);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.ros.chatto.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
@ -87,7 +87,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ChatMessageDTO> getNewMessages(final String fromUser,
|
||||
final String toUser, final Date lastMessageTime) {
|
||||
final String toUser, final Instant lastMessageTime) {
|
||||
final List<ChatMessage> chatMessages = chatMessageRepository
|
||||
.getNewMessages(fromUser, toUser, lastMessageTime);
|
||||
return myConversionService.convertToChatMessageDTOs(chatMessages);
|
||||
|
Loading…
Reference in New Issue
Block a user