package studycave.studycaverestservice.model.userActivity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import studycave.studycaverestservice.model.flashcardset.Set;
import studycave.studycaverestservice.model.material.Material;
import studycave.studycaverestservice.model.studyGroup.StudyGroup;
import studycave.studycaverestservice.model.test.Test;
import studycave.studycaverestservice.model.user.User;

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

@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class UserActivity {

    @Id
    @Column(name="id")
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;

    private String type;

    private int points;

    private String comment;

    private Timestamp date;

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

    @ManyToOne
    @JoinColumn(name = "material_id")
    private Material material;

    @ManyToOne
    @JoinColumn(name = "set_id")
    private Set set;

    @ManyToOne
    private Test test;

    @ManyToOne
    @JoinColumn(name = "toUser_id")
    private User toUser;

    @ManyToOne
    @JoinColumn(name = "fromUser_id")
    private User fromUser;

    public void setDate() {
        this.date = new java.sql.Timestamp(new java.util.Date().getTime());
    }
}
