package com.example.demo.entity;

import jakarta.persistence.*;

@Entity
@Table(name = "recipe_tags")
public class RecipeTag {

    @EmbeddedId
    private RecipeTagId id;

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

    @ManyToOne
    @MapsId("tagId")
    @JoinColumn(name = "tag_id", nullable = false)
    private Tag tag;

    public RecipeTag() {}

    public RecipeTag(Recipe recipe, Tag tag) {
        this.recipe = recipe;
        this.tag = tag;
        this.id = new RecipeTagId(recipe.getId(), tag.getId());
    }

    public RecipeTagId getId() {
        return id;
    }

    public void setId(RecipeTagId id) {
        this.id = id;
    }

    public Recipe getRecipe() {
        return recipe;
    }

    public Tag getTag() {
        return tag;
    }

    public void setRecipe(Recipe recipe) {
        this.recipe = recipe;
    }

    public void setTag(Tag tag) {
        this.tag = tag;
    }
}