diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java index bef813a..3c6dc37 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -115,4 +115,20 @@ public class CurriculumController { curriculumServ.delete(toDelete); return new ResponseEntity<>(HttpStatus.OK); } + + @GetMapping("/externalcurriculum/{userId}") + public ResponseEntity> getStudentsExternalCursus(@RequestHeader("Authorization") String token, @PathVariable String userId){ + if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.Teacher},token)) + return new UnauthorizedResponse<>(null); + + User u = userServ.getUserById(Long.parseLong(userId)); + HashMap toReturn = userCurriculumServ.findAllExternalCurriculumByStudent(u); + + if (toReturn == null) + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + + return new ResponseEntity<>(toReturn,HttpStatus.OK); + } + + } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java new file mode 100644 index 0000000..32346a4 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java @@ -0,0 +1,11 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.ExternalCurriculum; +import ovh.herisson.Clyde.Tables.User; + +import java.util.ArrayList; + +public interface ExternalCurriculumRepository extends CrudRepository { + ArrayList getExternalCurriculumByUser(User user); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java index 99c4669..0b0cebf 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java @@ -2,8 +2,10 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; import ovh.herisson.Clyde.Repositories.CurriculumRepository; +import ovh.herisson.Clyde.Repositories.ExternalCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.ExternalCurriculum; import ovh.herisson.Clyde.Tables.User; import ovh.herisson.Clyde.Tables.UserCurriculum; @@ -16,9 +18,11 @@ public class UserCurriculumService { private final UserCurriculumRepository userCurriculumRepository; private final CurriculumRepository curriculumRepo; - public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo) { + private final ExternalCurriculumRepository externalCurriculumRepo; + public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo, ExternalCurriculumRepository externalCurriculumRepo) { this.userCurriculumRepository = userCurriculumRepository; this.curriculumRepo = curriculumRepo; + this.externalCurriculumRepo = externalCurriculumRepo; } public Curriculum findByUser(User student){ @@ -47,4 +51,29 @@ public class UserCurriculumService { return toReturn; } + + public HashMap findAllExternalCurriculumByStudent(User student) { + ArrayList list = externalCurriculumRepo.getExternalCurriculumByUser(student); + + ArrayList> externalCurriculumList = new ArrayList>(); + + for (int i = 0; i < list.size(); i++) { + HashMap element = new HashMap<>(); + element.put("id", list.get(0).getId()); + element.put("user", list.get(0).getUser()); + element.put("university", list.get(0).getUniversity()); + element.put("formation", list.get(0).getFormation()); + element.put("completion", list.get(0).getCompletion()); + element.put("startYear", list.get(0).getStartYear()); + element.put("endYear", list.get(0).getEndYear()); + element.put("justifDocUrl", list.get(0).getJustifdocUrl()); + element.put("state", list.get(0).getState()); + externalCurriculumList.add(element); + } + + HashMap toReturn = new HashMap(); + toReturn.put("externalCurriculumList", externalCurriculumList); + return toReturn; + } + } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java new file mode 100644 index 0000000..6e0d90f --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java @@ -0,0 +1,113 @@ +package ovh.herisson.Clyde.Tables; + + +import jakarta.persistence.*; + +//This table stores a student's curriculum from another university +@Entity +public class ExternalCurriculum { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name="Users") + private User user; + + @ManyToOne + @JoinColumn(name="University") + private University university; + + private String formation; + + //This string denotes the completion of the external formation or the last year completed by the student in this formation + private String completion; + + private int startYear; + private int endYear; + private String justifdocUrl; + + //Accepted if the document justifies the claimed formation + private RequestState state; + + public ExternalCurriculum(){} + + public ExternalCurriculum(User user, University university, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){ + this.user = user; + this.university = university; + this.formation = formation; + this.completion = completion; + this.startYear = startYear; + this.endYear = endYear; + this.justifdocUrl = justifdocUrl; + this.state = state; + } + + public int getId() { + return id; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public University getUniversity() { + return university; + } + + public void setUniversity(University university) { + this.university = university; + } + + public String getFormation() { + return formation; + } + + public void setFormation(String formation) { + this.formation = formation; + } + + public String getCompletion(){ + return completion; + } + + public void setCompletion(String completion) { + this.completion = completion; + } + + public int getStartYear() { + return startYear; + } + + public void setStartYear(int startYear) { + this.startYear = startYear; + } + + public int getEndYear() { + return endYear; + } + + public void setEndYear(int endYear) { + this.endYear = endYear; + } + + public void setJustifdocUrl(String justifdocUrl) { + this.justifdocUrl = justifdocUrl; + } + + public String getJustifdocUrl() { + return justifdocUrl; + } + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/University.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/University.java new file mode 100644 index 0000000..7a60db1 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/University.java @@ -0,0 +1,27 @@ +package ovh.herisson.Clyde.Tables; + + +import jakarta.persistence.*; + +@Entity +public class University { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String name; + + public University(){} + + public University(String name){ + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 036b6fb..590e3ea 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -27,7 +27,6 @@ //Allows to display MA or BAB for years let yearprefix = ""; - const imageSaved = ref(false) let ppData = ""; @@ -154,6 +153,11 @@ +

+ Si vous êtes déja inscrits dans cette université veuillez vous connecter a votre compte et utilisez les fonctions + changer de cursus/réinscription sinon continuez ici. +

+