package studycave.studycaverestservice.model.flashcard;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import studycave.studycaverestservice.model.flashcardset.Set;

import javax.persistence.*;

@Entity
@Table(name = "flashcard")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Flashcard {
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;
    @Column(name="left_side")
    @JsonProperty("left_side")
    private String leftSide;
    @Column(name="right_side")
    @JsonProperty("right_side")
    private String rightSide;

    @ManyToOne
    @JoinColumn(name="id_set",referencedColumnName="id")
    @ApiModelProperty(hidden = true)
    @JsonBackReference
    private Set flashcardSet;

    public Flashcard(String firstName, String lastName) {
        this.leftSide = firstName;
        this.rightSide = lastName;
    }
}
