package studycave.studycaverestservice.model.material;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
import studycave.studycaverestservice.model.userActivity.UserActivity;

import javax.persistence.*;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Material {
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;

    private String title;

    private String path;

    private int owner;

    private String permission;

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

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

    private int grade;

    @Column(name="status")
    private String status;

    @ManyToOne
    @JoinColumn(name="group_id",referencedColumnName="id")
    private StudyGroup group;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "material", cascade = CascadeType.ALL)
    private List<UserActivity> activity = new ArrayList<>();
}
