added chats with another users

This commit is contained in:
SlimusMinus
2026-06-22 01:08:47 +03:00
parent 194b7efb8a
commit 236d00f2f9
19 changed files with 433 additions and 177 deletions

View File

@@ -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();
}
}