package com.example.demo.entity;

import jakarta.persistence.*;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

@Entity
@Table(name = "recipe_images")
public class Image {

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

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "recipe_id", nullable = false)
	@EqualsAndHashCode.Include
	private Recipe recipe;

	@Column(name = "image_url", nullable = false)
	private String imageUrl;

	@Column(name = "created_at")
	private LocalDateTime createdAt;

	public Image() {
	}

	public Image(Recipe recipe, String imageUrl) {
		this.recipe = recipe;
		this.imageUrl = imageUrl;
		this.createdAt = LocalDateTime.now();
	}

	// Getters and setters
	public Integer getId() {
		return id;
	}

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

	public Recipe getRecipe() {
		return recipe;
	}

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

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public LocalDateTime getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(LocalDateTime createdAt) {
		this.createdAt = createdAt;
	}
}