package studycave.studycaverestservice.model.user;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import studycave.studycaverestservice.model.studyGroupMember.StudyGroupMember;
import studycave.studycaverestservice.model.userActivity.UserActivity;
import studycave.studycaverestservice.model.userBadge.UserBadge;

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

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

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

    private String name;

    private String surname;

    @Column(name="login",unique=true)
    private String username;

    private String password;

    @Column(unique=true)
    private String email;

    @OneToOne(cascade = CascadeType.ALL)
    private UsosUser usosUser;

    @OneToMany(mappedBy="user",cascade = CascadeType.ALL)
    List<StudyGroupMember> groupMembers = new ArrayList<>();

    @OneToMany(mappedBy = "toUser", cascade = CascadeType.ALL)
    private List<UserActivity> activityTo;

    @OneToMany(mappedBy = "fromUser", cascade = CascadeType.ALL)
    private List<UserActivity> activityFrom;

    @OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
    List<UserBadge> badges = new ArrayList<>();

}
