Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
User.java 1.64 KiB
package com.projet.projetIndu.entities;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "users")
@Getter
@Setter
@NoArgsConstructor
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "role", discriminatorType = DiscriminatorType.STRING)
abstract class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String firstName;
@Column(nullable = false)
private String lastName;
private String phoneNumber;
@Column(unique = true, nullable = false)
private String email;
private String address;
@Column(nullable = false, unique = true)
private String username;
@Column(nullable = false)
private String password;
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Role role;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
private List<Notification> notificationList = new ArrayList<>();
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt = LocalDateTime.now();
protected User(String firstName, String lastName, String phoneNumber, String email, String address, String username, String password, Role role) {
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.email = email;
this.address = address;
this.username = username;
this.password = password;
this.role = role;
}
}