Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/tuvu/hackathon
This commit is contained in:
@@ -14,21 +14,13 @@ import jakarta.persistence.Entity;
|
|||||||
@Getter @Setter @NoArgsConstructor
|
@Getter @Setter @NoArgsConstructor
|
||||||
@Access(AccessType.FIELD)
|
@Access(AccessType.FIELD)
|
||||||
|
|
||||||
public class Admin {
|
public class Admin extends User{
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Integer id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@OneToOne(mappedBy = "admin")
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
public Admin(String name){
|
public Admin(String name){
|
||||||
this.name = name;
|
super(name);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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
|
@Data @NoArgsConstructor
|
||||||
@Access(AccessType.FIELD)
|
@Access(AccessType.FIELD)
|
||||||
|
|
||||||
public class Athlete {
|
public class Athlete extends User{
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Integer id;
|
|
||||||
private String name;
|
|
||||||
private String categorie;
|
private String categorie;
|
||||||
private String niveau;
|
private String niveau;
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
@@ -32,15 +28,12 @@ public class Athlete {
|
|||||||
@ManyToMany(mappedBy = "athletes")
|
@ManyToMany(mappedBy = "athletes")
|
||||||
private List<Session> sessions = new ArrayList<>(); // plusieurs sessions sont possibles
|
private List<Session> sessions = new ArrayList<>(); // plusieurs sessions sont possibles
|
||||||
|
|
||||||
@OneToOne(mappedBy = "athlete")
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
public Athlete(String name){
|
public Athlete(String name){
|
||||||
this.name = name;
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Athlete(String name, String categorie, String niveau, List<String> groupe){
|
public Athlete(String name, String categorie, String niveau, List<String> groupe){
|
||||||
this.name = name;
|
super(name);
|
||||||
this.categorie = categorie;
|
this.categorie = categorie;
|
||||||
this.niveau = niveau;
|
this.niveau = niveau;
|
||||||
this.groupe = groupe;
|
this.groupe = groupe;
|
||||||
@@ -48,6 +41,6 @@ public class Athlete {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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
|
@Getter @Setter @NoArgsConstructor
|
||||||
@Access(AccessType.FIELD)
|
@Access(AccessType.FIELD)
|
||||||
|
|
||||||
public class Coach {
|
public class Coach extends User{
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Integer id;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "coach")
|
@OneToMany(mappedBy = "coach")
|
||||||
private List<Session> sessions = new ArrayList<>(); // Un coach peut avoir plusieurs sessions
|
private List<Session> sessions = new ArrayList<>(); // Un coach peut avoir plusieurs sessions
|
||||||
|
|
||||||
@OneToOne(mappedBy = "coach")
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
public Coach(String name){
|
public Coach(String name){
|
||||||
this.name = name;
|
super(name);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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;
|
private String groupe;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Coach coach; // un coach par session
|
private User coach; // un coach par session
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
private List<Athlete> athletes = new ArrayList<>(); // plusieurs athlètes par session
|
private List<Athlete> athletes = new ArrayList<>(); // plusieurs athlètes par session
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ public class User implements Serializable {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@Column(unique = true, nullable = false)
|
||||||
private Integer id;
|
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;
|
private String name;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String motDePasse;
|
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