Max/Backend/CoursesEndpoints #129
| @ -68,10 +68,10 @@ public class MockController { | |||||||
|         curriculumService.save(psychologyBab1); |         curriculumService.save(psychologyBab1); | ||||||
|  |  | ||||||
|  |  | ||||||
|         Course progra1 = new Course(5,"Programmation et algorithimque 1"); |         Course progra1 = new Course(5,"Programmation et algorithimque 1",joke); | ||||||
|         Course chemistry1 = new Course(12, "Thermochimie"); |         Course chemistry1 = new Course(12, "Thermochimie",joke); | ||||||
|         Course psycho1 = new Course(21, "rien faire t'as cru c'est psycho"); |         Course psycho1 = new Course(21, "rien faire t'as cru c'est psycho",joke); | ||||||
|         Course commun = new Course(2, "cours commun"); |         Course commun = new Course(2, "cours commun",joke); | ||||||
|  |  | ||||||
|         courseService.save(progra1); |         courseService.save(progra1); | ||||||
|         courseService.save(chemistry1); |         courseService.save(chemistry1); | ||||||
|  | |||||||
| @ -1,9 +1,6 @@ | |||||||
| package ovh.herisson.Clyde.Tables; | package ovh.herisson.Clyde.Tables; | ||||||
|  |  | ||||||
| import jakarta.persistence.Entity; | import jakarta.persistence.*; | ||||||
| import jakarta.persistence.GeneratedValue; |  | ||||||
| import jakarta.persistence.GenerationType; |  | ||||||
| import jakarta.persistence.Id; |  | ||||||
|  |  | ||||||
| @Entity | @Entity | ||||||
| public class Course { | public class Course { | ||||||
| @ -13,9 +10,14 @@ public class Course { | |||||||
|     private int credits; |     private int credits; | ||||||
|     private String title; |     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.credits = credits; | ||||||
|         this.title = title; |         this.title = title; | ||||||
|  |         this.owner = owner; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Course() {} |     public Course() {} | ||||||
| @ -39,4 +41,12 @@ public class Course { | |||||||
|     public void setTitle(String title){ |     public void setTitle(String title){ | ||||||
|         this.title = title; |         this.title = title; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public User getOwner() { | ||||||
|  |         return owner; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void setOwner(User owner) { | ||||||
|  |         this.owner = owner; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,30 +3,26 @@ package ovh.herisson.Clyde.Tables; | |||||||
| import jakarta.persistence.*; | import jakarta.persistence.*; | ||||||
| 
 | 
 | ||||||
| @Entity | @Entity | ||||||
| public class TeacherGivenCourse { | public class TeacherCourse { | ||||||
|     @Id |     @Id | ||||||
|     @GeneratedValue(strategy = GenerationType.AUTO) |     @GeneratedValue(strategy = GenerationType.AUTO) | ||||||
|     private int id; |     private int id; | ||||||
| 
 | 
 | ||||||
|     @ManyToOne(fetch = FetchType.LAZY) |     @ManyToOne(fetch = FetchType.EAGER) | ||||||
|     @JoinColumn(name = "Users") |     @JoinColumn(name = "Users") | ||||||
|     private User user; |     private User user; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     @ManyToOne(fetch = FetchType.LAZY) |     @ManyToOne(fetch = FetchType.EAGER) | ||||||
|     @JoinColumn(name = "Course") |     @JoinColumn(name = "Course") | ||||||
|     private Course course; |     private Course course; | ||||||
| 
 | 
 | ||||||
|     //This flag helps make the difference between an assistant or a Teacher (who owns the course) |     public TeacherCourse(User user, Course course){ | ||||||
|     private boolean owned; |  | ||||||
| 
 |  | ||||||
|     public TeacherGivenCourse(User user, Course course, boolean owned){ |  | ||||||
|         this.user = user; |         this.user = user; | ||||||
|         this.course = course; |         this.course = course; | ||||||
|         this.owned = owned; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public TeacherGivenCourse() {} |     public TeacherCourse() {} | ||||||
| 
 | 
 | ||||||
|     public int getId() { |     public int getId() { | ||||||
|         return id; |         return id; | ||||||
| @ -48,11 +44,4 @@ public class TeacherGivenCourse { | |||||||
|         this.course = course; |         this.course = course; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public boolean isOwned() { |  | ||||||
|         return owned; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setOwned(boolean owned) { |  | ||||||
|         this.owned = owned; |  | ||||||
|     } |  | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user