From c27c3ac9fba1dcb8ed4b4adcfdd78ab73cb2604e Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Tue, 5 Mar 2024 14:14:56 +0100 Subject: [PATCH] - Ajout des champs password et salt dans user - Ajout de la table token - Ajout des foreign keys --- .../herisson/Clyde/Tables/CursusCourse.java | 9 ++-- .../ovh/herisson/Clyde/Tables/Secretary.java | 7 ++-- .../Clyde/Tables/TeacherGivenCourse.java | 9 ++-- .../java/ovh/herisson/Clyde/Tables/Token.java | 41 +++++++++++++++++++ .../java/ovh/herisson/Clyde/Tables/User.java | 21 +++++++++- .../ovh/herisson/Clyde/Tables/UserCursus.java | 3 ++ 6 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java index 30fed1c..e48e6a3 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java @@ -1,16 +1,17 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class CursusCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + + @JoinColumn(name = "Cursus") private int cursusId; + + @JoinColumn(name = "Course") private int courseId; public CursusCourse(int cursusId, int courseId){ diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java index ec7a86a..6161952 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java @@ -1,15 +1,14 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class Secretary { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + + @JoinColumn(name = "User") private int regNo; private String faculty; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java index 6e137c5..f2c089a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java @@ -1,16 +1,17 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class TeacherGivenCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + + @JoinColumn(name = "User") private int regNo; + + @JoinColumn(name = "Course") private int courseId; //This flag helps make the difference between an assistant or a Teacher (who owns the course) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java new file mode 100644 index 0000000..0ed6606 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java @@ -0,0 +1,41 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Token { + @GeneratedValue(strategy = GenerationType.AUTO) + @Id + private int id; + private int regNo; + private String data; + + public Token(int regNo, String data){ + this.regNo = regNo; + this.data = data; + } + + public Token(){} + public int getId() { + return id; + } + + public int getRegNo() { + return regNo; + } + + public void setRegNo(int regNo) { + this.regNo = regNo; + } + + public String getData(){ + return data; + } + + public void setData(String data) { + this.data = data; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index 172fd0d..2755eff 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -22,8 +22,8 @@ public class User { private Date birthDate; private ovh.herisson.Clyde.Tables.Role role; private String password; - - public User(String lastName, String firstName, String email, String adress, String country, Date birthDate, Role role){ + private String salt; + public User(String lastName, String firstName, String email, String adress, String country, Date birthDate, Role role, String password, String salt){ this.lastName = lastName; this.firstName = firstName; this.email = email; @@ -31,6 +31,8 @@ public class User { this.country = country; this.birthDate = birthDate; this.role = role; + this.password = password; + this.salt = salt; } public User() {} @@ -93,4 +95,19 @@ public class User { 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; + } + + public String getSalt(){ + return salt; + } + + public void setSalt(String salt) { + this.salt = salt; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java index 2222fdb..9460905 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java @@ -8,7 +8,10 @@ public class UserCursus { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + @JoinColumn(name = "User") private int regNo; + + @JoinColumn(name = "Cursus") private int cursusId; public UserCursus(int regNo, int cursusId){