1
0
forked from PGL/Clyde

142 lines
3.6 KiB
Java

package ovh.herisson.Clyde.Tables;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.GenericGenerator;
import ovh.herisson.Clyde.Tables.Msg.Discussion;
import ovh.herisson.Clyde.Tables.Msg.Message;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name = "Users")
public class User {
@Id
@GenericGenerator(name = "userGen", type = ovh.herisson.Clyde.Tables.RegNoGenerator.class)
@GeneratedValue(generator = "userGen")
private Long regNo;
private String lastName;
private String firstName;
@Column(unique = true)
private String email;
private String address;
private String country;
private Date birthDate;
private String profilePictureUrl;
private Role role;
@JsonIgnore
private String password;
////// Extension Messagerie /////
@OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
private List<Message> msgs;
/////////////////////////////////
@ManyToMany( mappedBy = "members" )
private List<Discussion> discussions;
public User(String lastName, String firstName, String email, String address,
String country, Date birthDate, String profilePictureUrl, Role role, String password)
{
this.lastName = lastName;
this.firstName = firstName;
this.email = email;
this.address = address;
this.country = country;
this.birthDate = birthDate;
this.profilePictureUrl = profilePictureUrl;
this.role = role;
this.password = password;
}
public User(String lastName, String firstName, String email, String address,
String country, Date birthDate, String profilePictureUrl, String password)
{
this.lastName = lastName;
this.firstName = firstName;
this.email = email;
this.address = address;
this.country = country;
this.birthDate = birthDate;
this.profilePictureUrl = profilePictureUrl;
this.password = password;
this.role = Role.Student;
}
public User() {}
public Long getRegNo(){
return this.regNo;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public String getProfilePictureUrl(){return this.profilePictureUrl;}
public void setProfilePictureUrl(String profilePictureUrl){
this.profilePictureUrl = profilePictureUrl;
}
public ovh.herisson.Clyde.Tables.Role getRole() {
return role;
}
public void setRole(ovh.herisson.Clyde.Tables.Role role) {
this.role = role;
}
public String getPassword(){
return password;
}
public void setPassword(String password) {
this.password = password;
}
}