diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java new file mode 100644 index 0000000..bc83924 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -0,0 +1,70 @@ +package ovh.herisson.Clyde.EndPoints; + + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Services.CurriculumCourseService; +import ovh.herisson.Clyde.Services.CurriculumService; +import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.CurriculumCourse; +import ovh.herisson.Clyde.Tables.Role; +import ovh.herisson.Clyde.Tables.User; + +import java.util.Map; + +@RestController +public class CurriculumController { + + + private final CurriculumService curriculumServ; + private final AuthenticatorService authServ; + + private final CurriculumCourseService curriculumCourseServ; + + public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, CurriculumCourseService curriculumCourseServ){ + this.curriculumServ = curriculumServ; + this.authServ = authServ; + this.curriculumCourseServ = curriculumCourseServ; + } + + @GetMapping("/curriculum/{id}") + public ResponseEntity findById(@PathVariable long id){ + return new ResponseEntity<>(curriculumServ.findById(id), HttpStatus.OK); + } + + @GetMapping("/curriculums") + public ResponseEntity>> findAllindDepth(){ + return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK); + } + + @GetMapping("/curriculum") + public ResponseEntity> findAll(){ + return new ResponseEntity<>(curriculumCourseServ.findAll(),HttpStatus.OK); + } + + /**@PostMapping("/curriculum") + public ResponseEntity postCurriculum(@RequestHeader("Authorization") String token,@RequestBody Curriculum curriculum){ + + if (!isSecretaryOrAdmin(token)){ + return new UnauthorizedResponse<>("you're not allowed to post a Curriculum"); + } + + CurriculumServ.save(Curriculum); + + return new ResponseEntity<>("created !",HttpStatus.CREATED); + }**/ + + + + private boolean isSecretaryOrAdmin(String authorization){ + if (authorization ==null) + return false; + + User poster = authServ.getUserFromToken(authorization); + if (poster == null) return false; + + return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CursusController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CursusController.java deleted file mode 100644 index 670865f..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CursusController.java +++ /dev/null @@ -1,71 +0,0 @@ -package ovh.herisson.Clyde.EndPoints; - - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import ovh.herisson.Clyde.Responses.UnauthorizedResponse; -import ovh.herisson.Clyde.Services.AuthenticatorService; -import ovh.herisson.Clyde.Services.CursusCourseService; -import ovh.herisson.Clyde.Services.CursusService; -import ovh.herisson.Clyde.Tables.Cursus; -import ovh.herisson.Clyde.Tables.CursusCourse; -import ovh.herisson.Clyde.Tables.Role; -import ovh.herisson.Clyde.Tables.User; - -import java.util.Map; - -@RestController -public class CursusController { - - - private final CursusService cursusServ; - private final AuthenticatorService authServ; - - private final CursusCourseService cursusCourseServ; - - public CursusController(CursusService cursusServ, AuthenticatorService authServ, CursusCourseService cursusCourseServ){ - this.cursusServ = cursusServ; - this.authServ = authServ; - this.cursusCourseServ = cursusCourseServ; - } - - @GetMapping("/cursus/{id}") - public ResponseEntity findById(@PathVariable long id){ - return new ResponseEntity<>(cursusServ.findById(id), HttpStatus.OK); - } - - @GetMapping("/curriculums") - public ResponseEntity>> findAllindDepth(){ - return new ResponseEntity<>(cursusCourseServ.getAllDepthCursus(),HttpStatus.OK); - } - - @GetMapping("/curriculum") - public ResponseEntity> findAll(){ - return new ResponseEntity<>(cursusCourseServ.findAll(),HttpStatus.OK); - } - - /**@PostMapping("/cursus") - public ResponseEntity postCursus(@RequestHeader("Authorization") String token,@RequestBody Cursus cursus){ - - if (!isSecretaryOrAdmin(token)){ - return new UnauthorizedResponse<>("you're not allowed to post a cursus"); - } - - cursusServ.save(cursus); - - return new ResponseEntity<>("created !",HttpStatus.CREATED); - }**/ - - - - private boolean isSecretaryOrAdmin(String authorization){ - if (authorization ==null) - return false; - - User poster = authServ.getUserFromToken(authorization); - if (poster == null) return false; - - return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin; - } -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java index 7757242..3347c8e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java @@ -69,7 +69,7 @@ public class InscriptionController { return null; } - private Map requestWithoutPassword(InscriptionRequest inscriptionRequest) { + private Map requestWithoutPassword(InscriptionRequest inscriptionRequest) { Map toReturn = new HashMap<>(); toReturn.put("id", inscriptionRequest.getId()); @@ -78,7 +78,7 @@ public class InscriptionController { toReturn.put("address", inscriptionRequest.getAddress()); toReturn.put("birthDate", inscriptionRequest.getBirthDate()); toReturn.put("country", inscriptionRequest.getCountry()); - toReturn.put("cursus", inscriptionRequest.getCursus()); + toReturn.put("curriculum", inscriptionRequest.getCurriculum()); toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture()); toReturn.put("state", inscriptionRequest.getState()); return toReturn; diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index e254b8c..af837bf 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -20,18 +20,18 @@ public class MockController { public final UserRepository userRepo; public final TokenRepository tokenRepo; public final TokenService tokenService; - public final CursusCourseService cursusCourseService; - public final CursusService cursusService; + public final CurriculumCourseService CurriculumCourseService; + public final CurriculumService curriculumService; public final CourseService courseService; ArrayList mockUsers; - public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CursusCourseService cursusCourseService, CursusService cursusService, CourseService courseService){ + public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService){ this.tokenRepo = tokenRepo; this.userRepo = userRepo; this.tokenService = tokenService; - this.cursusCourseService = cursusCourseService; - this.cursusService = cursusService; + this.CurriculumCourseService = CurriculumCourseService; + this.curriculumService = curriculumService; this.courseService = courseService; } @@ -51,20 +51,20 @@ public class MockController { User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student")); User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Teacher,passwordEncoder.encode("secretary")); User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); - mockUsers = new ArrayList(Arrays.asList(herobrine,joe,meh,joke)); + mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke)); userRepo.saveAll(mockUsers); // Course / Curriculum part - Cursus infoBab1 = new Cursus(1,"info"); - Cursus chemistryBab1 = new Cursus(1,"chemistry"); - Cursus psychologyBab1 = new Cursus(1,"psychology"); + Curriculum infoBab1 = new Curriculum(1,"info"); + Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); + Curriculum psychologyBab1 = new Curriculum(1,"psychology"); - cursusService.save(infoBab1); - cursusService.save(chemistryBab1); - cursusService.save(psychologyBab1); + curriculumService.save(infoBab1); + curriculumService.save(chemistryBab1); + curriculumService.save(psychologyBab1); Course progra1 = new Course(5,"Programmation et algorithimque 1","TODO DELETE"); @@ -78,15 +78,15 @@ public class MockController { courseService.save(commun); - cursusCourseService.save(new CursusCourse(infoBab1,progra1)); - cursusCourseService.save(new CursusCourse(infoBab1,commun)); + CurriculumCourseService.save(new CurriculumCourse(infoBab1,progra1)); + CurriculumCourseService.save(new CurriculumCourse(infoBab1,commun)); - cursusCourseService.save(new CursusCourse(psychologyBab1,psycho1)); - cursusCourseService.save(new CursusCourse(psychologyBab1,commun)); + CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,psycho1)); + CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,commun)); - cursusCourseService.save(new CursusCourse(chemistryBab1,commun)); - cursusCourseService.save(new CursusCourse(chemistryBab1,chemistry1)); + CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun)); + CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1)); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/CurriculumCourseRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/CurriculumCourseRepository.java new file mode 100644 index 0000000..c99f50b --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/CurriculumCourseRepository.java @@ -0,0 +1,17 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Course; +import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.CurriculumCourse; + +public interface CurriculumCourseRepository extends CrudRepository { + + @Query("select distinct cc.course from CurriculumCourse cc where cc.curriculum = ?1") + Iterable findCoursesByCurriculum(Curriculum curriculum); + + + @Query("select distinct cc.curriculum from CurriculumCourse cc") + Iterable findDistinctCurriculums(); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/CurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/CurriculumRepository.java new file mode 100644 index 0000000..441422f --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/CurriculumRepository.java @@ -0,0 +1,8 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Curriculum; + +public interface CurriculumRepository extends CrudRepository { + Curriculum findById(long id); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/CursusCourseRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/CursusCourseRepository.java deleted file mode 100644 index b0cba44..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/CursusCourseRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package ovh.herisson.Clyde.Repositories; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import ovh.herisson.Clyde.Tables.Course; -import ovh.herisson.Clyde.Tables.Cursus; -import ovh.herisson.Clyde.Tables.CursusCourse; - -public interface CursusCourseRepository extends CrudRepository { - - - //todo faire custom query pour trouver tous les cours d'un cursus par un cursusId - - @Query("select distinct cc.course from CursusCourse cc where cc.cursus = ?1") - Iterable findCoursesByCursus(Cursus cursus); - - - @Query("select distinct cc.cursus from CursusCourse cc") - Iterable findDistinctCursuses(); -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/CursusRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/CursusRepository.java deleted file mode 100644 index 0e84688..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/CursusRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package ovh.herisson.Clyde.Repositories; - -import org.springframework.data.repository.CrudRepository; -import ovh.herisson.Clyde.Tables.Cursus; - -public interface CursusRepository extends CrudRepository { - Cursus findById(long id); -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java new file mode 100644 index 0000000..ccf1226 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java @@ -0,0 +1,68 @@ +package ovh.herisson.Clyde.Services; + +import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.CourseRepository; +import ovh.herisson.Clyde.Repositories.CurriculumCourseRepository; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; +import ovh.herisson.Clyde.Tables.Course; +import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.CurriculumCourse; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +@Service +public class CurriculumCourseService { + + private final CurriculumCourseRepository curriculumCourseRepo; + + private final CourseRepository courseRepo; + + private final CurriculumRepository curriculumRepo; + + public CurriculumCourseService(CurriculumCourseRepository curriculumCourseRepository, CourseRepository courseRepo, CurriculumRepository curriculumRepo) { + this.curriculumCourseRepo = curriculumCourseRepository; + this.courseRepo = courseRepo; + this.curriculumRepo = curriculumRepo; + } + + public void save(CurriculumCourse curriculumCourse){ + curriculumCourseRepo.save(curriculumCourse); + } + + public Iterable findAll(){ + return curriculumCourseRepo.findAll(); + } + + + public Map getDepthCurriculum(Curriculum curriculum){ + + HashMap toReturn = new HashMap<>(); + ArrayList courses = new ArrayList<>(); + for (Course c: curriculumCourseRepo.findCoursesByCurriculum(curriculum)){ + courses.add(c); + } + toReturn.put("courses",courses); + toReturn.put("curriculumId", curriculum.getCurriculumId()); + toReturn.put("year", curriculum.getYear()); + toReturn.put("option", curriculum.getOption()); + + + return toReturn; + } + + public Iterable> getAllDepthCurriculum(){ + + ArrayList> toReturn = new ArrayList<>(); + + for (Curriculum curriculum : curriculumCourseRepo.findDistinctCurriculums()){ + toReturn.add(getDepthCurriculum(curriculum)); + } + return toReturn; + } + + + + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java new file mode 100644 index 0000000..6f6d89b --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java @@ -0,0 +1,32 @@ +package ovh.herisson.Clyde.Services; + +import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.CourseRepository; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; +import ovh.herisson.Clyde.Tables.Curriculum; + +@Service +public class CurriculumService { + + private final CurriculumRepository curriculumRepo; + + private final CourseRepository courseRepo; + + public CurriculumService(CurriculumRepository curriculumRepo, CourseRepository courseRepo){ + this.curriculumRepo = curriculumRepo; + this.courseRepo = courseRepo; + } + + + public void save(Curriculum curriculum){ + curriculumRepo.save(curriculum); + } + + public Curriculum findById(long id){ + return curriculumRepo.findById(id); + } + + public Iterable findAll(){ + return curriculumRepo.findAll(); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CursusCourseService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CursusCourseService.java deleted file mode 100644 index 95b31de..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/CursusCourseService.java +++ /dev/null @@ -1,68 +0,0 @@ -package ovh.herisson.Clyde.Services; - -import org.springframework.stereotype.Service; -import ovh.herisson.Clyde.Repositories.CourseRepository; -import ovh.herisson.Clyde.Repositories.CursusCourseRepository; -import ovh.herisson.Clyde.Repositories.CursusRepository; -import ovh.herisson.Clyde.Tables.Course; -import ovh.herisson.Clyde.Tables.Cursus; -import ovh.herisson.Clyde.Tables.CursusCourse; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -@Service -public class CursusCourseService { - - private final CursusCourseRepository cursusCourseRepo; - - private final CourseRepository courseRepo; - - private final CursusRepository cursusRepo; - - public CursusCourseService(CursusCourseRepository cursusCourseRepo, CourseRepository courseRepo, CursusRepository cursusRepo) { - this.cursusCourseRepo = cursusCourseRepo; - this.courseRepo = courseRepo; - this.cursusRepo = cursusRepo; - } - - public void save(CursusCourse cursusCourse){ - cursusCourseRepo.save(cursusCourse); - } - - public Iterable findAll(){ - return cursusCourseRepo.findAll(); - } - - - public Map getDepthCursus(Cursus cursus){ - - HashMap toReturn = new HashMap<>(); - ArrayList courses = new ArrayList<>(); - for (Course c: cursusCourseRepo.findCoursesByCursus(cursus)){ - courses.add(c); - } - toReturn.put("courses",courses); - toReturn.put("cursusId",cursus.getCursusId()); - toReturn.put("year",cursus.getYear()); - toReturn.put("option",cursus.getOption()); - - - return toReturn; - } - - public Iterable> getAllDepthCursus(){ - - ArrayList> toReturn = new ArrayList<>(); - - for (Cursus cursus : cursusCourseRepo.findDistinctCursuses()){ - toReturn.add(getDepthCursus(cursus)); - } - return toReturn; - } - - - - -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CursusService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CursusService.java deleted file mode 100644 index 0258ec8..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/CursusService.java +++ /dev/null @@ -1,36 +0,0 @@ -package ovh.herisson.Clyde.Services; - -import org.springframework.stereotype.Service; -import ovh.herisson.Clyde.Repositories.CourseRepository; -import ovh.herisson.Clyde.Repositories.CursusRepository; -import ovh.herisson.Clyde.Tables.Cursus; - -import java.util.HashMap; -import java.util.Map; - -@Service -public class CursusService { - - - private final CursusRepository cursusRepo; - - private final CourseRepository courseRepo; - - public CursusService(CursusRepository cursusRepo, CourseRepository courseRepo){ - this.cursusRepo = cursusRepo; - this.courseRepo = courseRepo; - } - - - public void save(Cursus cursus){ - cursusRepo.save(cursus); - } - - public Cursus findById(long id){ - return cursusRepo.findById(id); - } - - public Iterable findAll(){ - return cursusRepo.findAll(); - } -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java similarity index 76% rename from backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java rename to backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java index d124179..67075d1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java @@ -6,21 +6,21 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; @Entity -public class Cursus { +public class Curriculum { @Id @GeneratedValue(strategy = GenerationType.AUTO) - private int cursusId; + private int curriculumId; private int year; private String option; - public Cursus(int year, String option){ + public Curriculum(int year, String option){ this.year = year; this.option = option; } - public Cursus() {} + public Curriculum() {} - public int getCursusId(){ - return this.cursusId; + public int getCurriculumId(){ + return this.curriculumId; } public int getYear(){ diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CurriculumCourse.java similarity index 57% rename from backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java rename to backend/src/main/java/ovh/herisson/Clyde/Tables/CurriculumCourse.java index 111cb78..8202e8d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CurriculumCourse.java @@ -3,25 +3,25 @@ package ovh.herisson.Clyde.Tables; import jakarta.persistence.*; @Entity -public class CursusCourse { +public class CurriculumCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "Cursus") - private Cursus cursus; + @JoinColumn(name = "Curriculum") + private Curriculum curriculum; @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "Course") private Course course; - public CursusCourse(Cursus cursus, Course course){ - this.cursus = cursus; + public CurriculumCourse(Curriculum curriculum, Course course){ + this.curriculum = curriculum; this.course = course; } - public CursusCourse() {} + public CurriculumCourse() {} public int getId() { return id; @@ -35,11 +35,11 @@ public class CursusCourse { this.course = course; } - public Cursus getCursus() { - return cursus; + public Curriculum getCurriculum() { + return curriculum; } - public void setCursus(Cursus cursus) { - this.cursus = cursus; + public void setCurriculum(Curriculum curriculum) { + this.curriculum = curriculum; } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java index aecebe2..dfbf7ed 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java @@ -18,8 +18,8 @@ public class InscriptionRequest { private Date birthDate; @ManyToOne - @JoinColumn(name="Cursus") - private Cursus cursus; + @JoinColumn(name="Curriculum") + private Curriculum curriculum; private RequestState state; private String profilePicture; @@ -89,12 +89,12 @@ public class InscriptionRequest { this.birthDate = birthDate; } - public Cursus getCursus() { - return cursus; + public Curriculum getCurriculum() { + return curriculum; } - public void setCursus(Cursus cursus) { - this.cursus = cursus; + public void setCurriculum(Curriculum curriculum) { + this.curriculum = curriculum; } public RequestState getState() { diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ReinscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ReinscriptionRequest.java index 69c80e6..57ad53c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ReinscriptionRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ReinscriptionRequest.java @@ -13,26 +13,26 @@ public class ReinscriptionRequest { private User user; @ManyToOne - @JoinColumn(name = "Cursus") - private Cursus newCursus; + @JoinColumn(name = "Curriculum") + private Curriculum newCurriculum; private RequestState state; - //Permet de différencier les demandes de changement et une réinscription dans le même cursus + //Permet de différencier les demandes de changement et une réinscription dans le même Curriculum //Pour la réinscription on va le mettre a 0 private boolean type = false; public ReinscriptionRequest(){} - public ReinscriptionRequest(User user, Cursus newCursus, RequestState state, boolean type){ + public ReinscriptionRequest(User user, Curriculum newCurriculum, RequestState state, boolean type){ this.user = user; - this.newCursus = newCursus; + this.newCurriculum = newCurriculum; this.state = state; this.type = type; } - public ReinscriptionRequest(User user, Cursus newCursus, RequestState state){ + public ReinscriptionRequest(User user, Curriculum newCurriculum, RequestState state){ this.user = user; - this.newCursus = newCursus; + this.newCurriculum = newCurriculum; this.state = state; } @@ -48,12 +48,12 @@ public class ReinscriptionRequest { this.user = user; } - public Cursus getNewCursus() { - return newCursus; + public Curriculum getNewCurriculum() { + return newCurriculum; } - public void setNewCursus(Cursus newCursus) { - this.newCursus = newCursus; + public void setNewCurriculum(Curriculum newCurriculum) { + this.newCurriculum = newCurriculum; } public RequestState getState() { diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java similarity index 53% rename from backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java rename to backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java index 6590b2d..2202763 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java @@ -3,26 +3,26 @@ package ovh.herisson.Clyde.Tables; import jakarta.persistence.*; @Entity -public class UserCursus { +public class UserCurriculum { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - //Un étudiant peut avoir plusieurs cursus + //Un étudiant peut avoir plusieurs curriculums @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "Users") private User user; @OneToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "Cursus") - private Cursus cursus; + @JoinColumn(name = "Curriculum") + private Curriculum curriculum; - public UserCursus(User user, Cursus cursus){ + public UserCurriculum(User user, Curriculum curriculum){ this.user = user; - this.cursus = cursus; + this.curriculum = curriculum; } - public UserCursus() {} + public UserCurriculum() {} public int getId() { return id; @@ -36,11 +36,11 @@ public class UserCursus { this.user = user; } - public Cursus getCursus() { - return cursus; + public Curriculum getCurriculum() { + return curriculum; } - public void setCursus(Cursus cursus) { - this.cursus = cursus; + public void setCurriculum(Curriculum curriculum) { + this.curriculum = curriculum; } } diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 5004577..fbe4bea 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -19,7 +19,7 @@ const email=ref("") const address=ref("") const country=ref("") - const cursus=ref("") + const curriculum=ref("") const imageSaved = ref(false) const ppData = ref(false) @@ -92,7 +92,6 @@

{{i18n("login.guest.confirm")}} {{i18n("login.guest.password")}}

-
@@ -122,14 +121,14 @@

{{i18n("curriculum").toUpperCase()}}

-
-
diff --git a/frontend/src/Apps/ManageCourses.vue b/frontend/src/Apps/ManageCourses.vue index 5827e52..0a3fe27 100644 --- a/frontend/src/Apps/ManageCourses.vue +++ b/frontend/src/Apps/ManageCourses.vue @@ -1,7 +1,7 @@ @@ -130,7 +130,7 @@ const cursus=[
{{i18n("courses.toDelete")}} :
@@ -147,7 +147,7 @@ const cursus=[
-
+
+ v-for="item in user.curriculum">
{{item.name}}
{{item.teacher}}
diff --git a/frontend/src/Apps/Request.vue b/frontend/src/Apps/Request.vue index 12d27f6..b1c7f30 100644 --- a/frontend/src/Apps/Request.vue +++ b/frontend/src/Apps/Request.vue @@ -8,7 +8,7 @@ address: String, country: String, birthDate: String, - cursus:String, + curriculum:String, degree:String,}); diff --git a/frontend/src/rest/ServiceInscription.js b/frontend/src/rest/ServiceInscription.js index 5068217..1f75123 100644 --- a/frontend/src/rest/ServiceInscription.js +++ b/frontend/src/rest/ServiceInscription.js @@ -24,7 +24,7 @@ export async function createRegister(){ * - country * - birthdate * - email - * - cursus + * - curriculum * - degree */ export async function getRegisters(id){ diff --git a/frontend/src/rest/Users.js b/frontend/src/rest/Users.js index b786f0d..17420b5 100644 --- a/frontend/src/rest/Users.js +++ b/frontend/src/rest/Users.js @@ -14,10 +14,10 @@ export async function login(user, pass, exp){ * @param mail * @param address * @param country - * @param cursus + * @param curriculum * @param imageId id of the image in database returned when uploaded */ -export async function register(firstname, lastname, birthDate, password, email, address, country, cursus, imageId){ +export async function register(firstname, lastname, birthDate, password, email, address, country, curriculum, imageId){ return restPost("/register", { firstname: firstname, lastname: lastname, @@ -26,7 +26,7 @@ export async function register(firstname, lastname, birthDate, password, email, email: email, address: address, country: country, - cursus: cursus + curriculum: curriculum }); } diff --git a/frontend/src/rest/curriculum.js b/frontend/src/rest/curriculum.js new file mode 100644 index 0000000..4aa6d8f --- /dev/null +++ b/frontend/src/rest/curriculum.js @@ -0,0 +1,41 @@ +/** + * curriculum API + */ + +import { restGet, restPostn, restDelete, restPatch } from './restConsumer.js' + +/** + * Create a new curriculum (bundle of courses) + * @param courses list of courses + */ +export async function createcurriculum(courses){ + return restPost("/curriculum", {courses: courses} ); +} + +/** + * Delete the specified curriculum + */ +export async function deletecurriculum(id){ + return restDelete("/curriculum/" + id); +} + +/** + * Get informations on a particular curriculum + * + * @param id identification of the curriculum + * + * @return list of courses + */ +export async function getcurriculum(id){ + return restGet("/curriculum/" + id); +} + +/** + * Modify the courses of a curriculum + * + * @param id the id of the curriculum + * @param courses list of new courses + */ +export async function altercurriculum(id, courses){ + return restPatch("/curriculum/" + id, courses); +} diff --git a/frontend/src/rest/cursus.js b/frontend/src/rest/cursus.js deleted file mode 100644 index 5aad5be..0000000 --- a/frontend/src/rest/cursus.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * cursus API - */ - -import { restGet, restPostn, restDelete, restPatch } from './restConsumer.js' - -/** - * Create a new cursus (bundle of courses) - * @param courses list of courses - */ -export async function createCursus(courses){ - return restPost("/cursus", {courses: courses} ); -} - -/** - * Delete the specified cursus - */ -export async function deleteCursus(id){ - return restDelete("/cursus/" + id); -} - -/** - * Get informations on a particular cursus - * - * @param id identification of the cursus - * - * @return list of courses - */ -export async function getCursus(id){ - return restGet("/cursus/" + id); -} - -/** - * Modify the courses of a cursus - * - * @param id the id of the cursus - * @param courses list of new courses - */ -export async function alterCursus(id, courses){ - return restPatch("/cursus/" + id, courses); -}