65 lines
1.2 KiB
Java
65 lines
1.2 KiB
Java
package com.example.hangry;
|
|
import jakarta.persistence.*;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
@Entity
|
|
@Table(name = "`likes`")
|
|
public class Like {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne
|
|
@JoinColumn(name = "user_id", nullable = false)
|
|
private User user;
|
|
|
|
@ManyToOne
|
|
@JoinColumn(name = "recipe_id", nullable = false)
|
|
private Recipe recipe;
|
|
|
|
private LocalDateTime createdAt = LocalDateTime.now();
|
|
|
|
// Konstruktoren, Getter & Setter#
|
|
|
|
public Like(){}
|
|
public Like( User user, Recipe recipe) {
|
|
this.user = user;
|
|
this.recipe = recipe;
|
|
this.createdAt=LocalDateTime.now();
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public User getUser() {
|
|
return user;
|
|
}
|
|
|
|
public Recipe getRecipe() {
|
|
return recipe;
|
|
}
|
|
|
|
public LocalDateTime getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public void setId(Long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public void setUser(User user) {
|
|
this.user = user;
|
|
}
|
|
|
|
public void setRecipe(Recipe recipe) {
|
|
this.recipe = recipe;
|
|
}
|
|
|
|
public void setCreatedAt(LocalDateTime createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
}
|
|
|