Re-wrote part of object classes
This commit is contained in:
@@ -14,21 +14,13 @@ import jakarta.persistence.Entity;
|
||||
@Getter @Setter @NoArgsConstructor
|
||||
@Access(AccessType.FIELD)
|
||||
|
||||
public class Admin {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
private String name;
|
||||
|
||||
@OneToOne(mappedBy = "admin")
|
||||
private User user;
|
||||
public class Admin extends User{
|
||||
|
||||
public Admin(String name){
|
||||
this.name = name;
|
||||
super(name);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Admin [id=" + id + " , name=" + name + "]";
|
||||
return "Admin [id=" + super.getId() + " , name=" + super.getName() + "]";
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,8 @@ import jakarta.persistence.Entity;
|
||||
@Data @NoArgsConstructor
|
||||
@Access(AccessType.FIELD)
|
||||
|
||||
public class Athlete {
|
||||
public class Athlete extends User{
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String categorie;
|
||||
private String niveau;
|
||||
@ElementCollection
|
||||
@@ -32,15 +28,12 @@ public class Athlete {
|
||||
@ManyToMany(mappedBy = "athletes")
|
||||
private List<Session> sessions = new ArrayList<>(); // plusieurs sessions sont possibles
|
||||
|
||||
@OneToOne(mappedBy = "athlete")
|
||||
private User user;
|
||||
|
||||
public Athlete(String name){
|
||||
this.name = name;
|
||||
super(name);
|
||||
}
|
||||
|
||||
public Athlete(String name, String categorie, String niveau, List<String> groupe){
|
||||
this.name = name;
|
||||
super(name);
|
||||
this.categorie = categorie;
|
||||
this.niveau = niveau;
|
||||
this.groupe = groupe;
|
||||
@@ -48,6 +41,6 @@ public class Athlete {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Athlete [id=" + id + " , name=" + name + "]";
|
||||
return "Athlete [id=" + super.getId() + " , name=" + super.getName() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,24 +17,16 @@ import jakarta.persistence.Entity;
|
||||
@Getter @Setter @NoArgsConstructor
|
||||
@Access(AccessType.FIELD)
|
||||
|
||||
public class Coach {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
private String name;
|
||||
public class Coach extends User{
|
||||
|
||||
@OneToMany(mappedBy = "coach")
|
||||
private List<Session> sessions = new ArrayList<>(); // Un coach peut avoir plusieurs sessions
|
||||
|
||||
@OneToOne(mappedBy = "coach")
|
||||
private User user;
|
||||
|
||||
public Coach(String name){
|
||||
this.name = name;
|
||||
super(name);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Coach [id=" + id + " , name=" + name + "]";
|
||||
return "Coach [id=" + super.getId() + " , name=" + super.getName() + "]";
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class Session {
|
||||
private String groupe;
|
||||
|
||||
@ManyToOne
|
||||
private Coach coach; // un coach par session
|
||||
private User coach; // un coach par session
|
||||
|
||||
@ManyToMany
|
||||
private List<Athlete> athletes = new ArrayList<>(); // plusieurs athlètes par session
|
||||
|
||||
@@ -26,8 +26,11 @@ public class User implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(unique = true, nullable = false)
|
||||
private Integer id;
|
||||
@Column(unique = true, nullable = false) // pas possible d'avoir le même nom
|
||||
@Column(nullable = false, unique = true)
|
||||
private String id_keycloak;
|
||||
|
||||
private String name;
|
||||
@Column(nullable = false)
|
||||
private String motDePasse;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package hackathon.FrisbYEE.jpa.metier;
|
||||
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "utilisateur_role")
|
||||
public class UserRole {
|
||||
|
||||
@EmbeddedId
|
||||
private UserRoleId id;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("utilisateurId")
|
||||
private User utilisateur;
|
||||
|
||||
@ManyToOne
|
||||
@MapsId("roleId")
|
||||
private Role role;
|
||||
|
||||
// getters/setters
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package hackathon.FrisbYEE.jpa.metier;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class UserRoleId implements Serializable {
|
||||
|
||||
private Long utilisateurId;
|
||||
private Long roleId;
|
||||
|
||||
// equals() & hashCode() OBLIGATOIRES
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package hackathon.FrisbYEE.jpa.metier;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Inheritance;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = jakarta.persistence.InheritanceType.JOINED)
|
||||
@Table(name = "utilisateur_role_details")
|
||||
public abstract class UtilisateurRoleDetails {
|
||||
|
||||
@Id
|
||||
private Long utilisateurId;
|
||||
|
||||
@OneToOne
|
||||
@MapsId
|
||||
@JoinColumn(name = "utilisateur_id")
|
||||
private User utilisateur;
|
||||
}
|
||||
Reference in New Issue
Block a user