package com.toyshop.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;

@Entity
@Table(name = "product_images")
public class ProductImage {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "product_id", nullable = false)
  @JsonIgnore
  private Product product;

  @Column(nullable = false, length = 255)
  private String url;

  @Column(nullable = false)
  private Integer sortOrder = 0;

  public Long getId() { return id; }
  public void setId(Long id) { this.id = id; }
  public Product getProduct() { return product; }
  public void setProduct(Product product) { this.product = product; }
  public String getUrl() { return url; }
  public void setUrl(String url) { this.url = url; }
  public Integer getSortOrder() { return sortOrder; }
  public void setSortOrder(Integer sortOrder) { this.sortOrder = sortOrder; }
}
