implemented friendship system

This commit is contained in:
2025-12-16 17:47:13 +01:00
parent c05420099a
commit 38ce235522
19 changed files with 542 additions and 48 deletions
@@ -5,8 +5,14 @@ import jakarta.persistence.*;
import java.time.LocalDateTime;
/**
* For explanation of statuses, also see "getFriendships" in UserController.
*/
@Entity
@Table(name = "friendships")
@Table(
name = "friendships",
uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "friend_id"})
)
public class Friendship {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -30,12 +36,11 @@ public class Friendship {
public Friendship() {
}
public Friendship(Long id, User user, User friend, FriendShipStatus status, LocalDateTime createdAt) {
this.id = id;
public Friendship(User user, User friend, FriendShipStatus status) {
this.user = user;
this.friend = friend;
this.status = status;
this.createdAt = createdAt;
this.createdAt = LocalDateTime.now();
}
public Long getId() {