package studycave.studycaverestservice.model.simpleTest;

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.test.Test;

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

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

    private String title;

    @Column(name="id_owner")
    @JsonProperty("owner")
    private Long 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 SimpleTest(String title,Long idOwner) {
        super();
        this.title = title;
        this.idOwner = idOwner;
    }

    public SimpleTest(Test test) {
        super();
        this.title = test.getTitle();
        this.idOwner = test.getIdOwner();
    }

}
