added chats with another users
This commit is contained in:
@@ -6,6 +6,7 @@ import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.PrePersist;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
@@ -20,16 +21,23 @@ public class Message {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
private User sender;
|
||||
@Column(name = "chat_id", nullable = false)
|
||||
private Long chatId;
|
||||
|
||||
@ManyToOne
|
||||
private User receiver;
|
||||
@Column(name = "sender_id", nullable = false)
|
||||
private Long senderId;
|
||||
|
||||
@Column(length = 2000)
|
||||
@Column(nullable = false, columnDefinition = "TEXT")
|
||||
private String content;
|
||||
|
||||
@Column(name = "is_read", nullable = false)
|
||||
private boolean isRead = false;
|
||||
|
||||
@Column(name = "created_at", nullable = false)
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
private boolean isRead;
|
||||
@PrePersist
|
||||
protected void onCreate() {
|
||||
createdAt = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user