package app.mealsmadeeasy.api.recipe.comment;

import app.mealsmadeeasy.api.recipe.Recipe;
import app.mealsmadeeasy.api.user.User;
import jakarta.persistence.*;
import lombok.Data;
import org.jetbrains.annotations.Nullable;

import java.time.OffsetDateTime;

@Entity
@Table(name = "recipe_comment")
@Data
public final class RecipeComment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    private Integer id;

    @Column(nullable = false, updatable = false)
    private OffsetDateTime created = OffsetDateTime.now();

    private OffsetDateTime modified;

    @Column(columnDefinition = "TEXT", nullable = false)
    private String rawText;

    @Column(columnDefinition = "TEXT")
    @Nullable
    private String cachedRenderedText;

    @ManyToOne
    @JoinColumn(name = "owner_id", nullable = false, updatable = false)
    private User owner;

    @ManyToOne
    @JoinColumn(name = "recipe_id", nullable = false, updatable = false)
    private Recipe recipe;

}
