package ru.kayashov.bar.model.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.List;

@Entity
@Table(name = "cocktail")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CocktailEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String image;
    private String video;

    @Column(columnDefinition = "text")
    private String instructions;

    @Enumerated(EnumType.STRING)
    private Category category;

    @Enumerated(EnumType.STRING)
    private Alcoholic alcoholic;

    @Enumerated(EnumType.STRING)
    private Glass glass;

    private Integer rating;

    @Column(name = "favourite")
    private Boolean isFavorite;

    @OneToMany(mappedBy = "cocktail", cascade = CascadeType.REMOVE)
    private List<ReceiptEntity> receipt;

    @Override
    public String toString() {
        return id + "-" + name + "-" + alcoholic.getValue();
    }
}
