package studycave.studycaverestservice.model.simpleSet;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import studycave.studycaverestservice.model.flashcardset.Set;

import javax.persistence.*;
import java.sql.Date;

@Entity
@Table(name = "flashcardset")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class SimpleSet {
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;

    private String name;

    private String category;

    @Column(name="id_owner")
    @JsonProperty("owner")
    private int idOwner;

    @Column(name="add_date")
    @JsonProperty("add_date")
    private Date addDate;

    @Column(name="edit_date")
    @JsonProperty("edit_date")
    private Date editDate;

    private int grade;

    private String permission;

    @Column(name="group_id")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer groupId;


    public SimpleSet(String name, String category, int idOwner) {
        super();
        this.name = name;
        this.category = category;
        this.idOwner = idOwner;
    }

    public SimpleSet(Set set) {
        super();
        this.name = set.getName();
        this.category = set.getCategory();
        this.idOwner = set.getIdOwner();
    }
}
