changed Course entity

This commit is contained in:
Bartha Maxime 2024-03-16 16:28:34 +01:00
parent 115c050e5e
commit 8128e4c8f8
3 changed files with 24 additions and 25 deletions

View File

@ -68,10 +68,10 @@ public class MockController {
curriculumService.save(psychologyBab1);
Course progra1 = new Course(5,"Programmation et algorithimque 1");
Course chemistry1 = new Course(12, "Thermochimie");
Course psycho1 = new Course(21, "rien faire t'as cru c'est psycho");
Course commun = new Course(2, "cours commun");
Course progra1 = new Course(5,"Programmation et algorithimque 1",joke);
Course chemistry1 = new Course(12, "Thermochimie",joke);
Course psycho1 = new Course(21, "rien faire t'as cru c'est psycho",joke);
Course commun = new Course(2, "cours commun",joke);
courseService.save(progra1);
courseService.save(chemistry1);

View File

@ -1,9 +1,6 @@
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 Course {
@ -13,9 +10,14 @@ public class Course {
private int credits;
private String title;
public Course(int credits, String title){
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "Users")
private User owner;
public Course(int credits, String title, User owner){
this.credits = credits;
this.title = title;
this.owner = owner;
}
public Course() {}
@ -39,4 +41,12 @@ public class Course {
public void setTitle(String title){
this.title = title;
}
public User getOwner() {
return owner;
}
public void setOwner(User owner) {
this.owner = owner;
}
}

View File

@ -3,30 +3,26 @@ package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*;
@Entity
public class TeacherGivenCourse {
public class TeacherCourse {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "Users")
private User user;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "Course")
private Course course;
//This flag helps make the difference between an assistant or a Teacher (who owns the course)
private boolean owned;
public TeacherGivenCourse(User user, Course course, boolean owned){
public TeacherCourse(User user, Course course){
this.user = user;
this.course = course;
this.owned = owned;
}
public TeacherGivenCourse() {}
public TeacherCourse() {}
public int getId() {
return id;
@ -48,11 +44,4 @@ public class TeacherGivenCourse {
this.course = course;
}
public boolean isOwned() {
return owned;
}
public void setOwned(boolean owned) {
this.owned = owned;
}
}