From ad0e7b3e354ac9d6bed0570ff18ada6432be06a8 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sat, 23 Mar 2024 14:08:03 +0100 Subject: [PATCH 01/21] =?UTF-8?q?-=20Ajoute=20un=20champ=20year=20dans=20U?= =?UTF-8?q?serCurriculum=20pour=20diff=C3=A9rencier=20les=20anciers=20curs?= =?UTF-8?q?us=20de=20l'actuel=20pour=20l'=C3=A9tudiant=20-=20Ajoute=20la?= =?UTF-8?q?=20table=20ExemptionsRequest=20-=20Ajoute=20la=20table=20Schola?= =?UTF-8?q?rshipRequest=20-=20Ajoute=20la=20table=20UninscriptionRequest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clyde/Services/InscriptionService.java | 2 +- .../Clyde/Tables/ExemptionsRequest.java | 66 +++++++++++++++++++ .../Clyde/Tables/ScholarshipRequest.java | 59 +++++++++++++++++ .../Clyde/Tables/UninscriptionRequest.java | 28 ++++++++ .../herisson/Clyde/Tables/UserCurriculum.java | 13 +++- frontend/src/Apps/AboutStudent.vue | 24 +++++++ 6 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java create mode 100644 frontend/src/Apps/AboutStudent.vue diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java index 311dbf2..48e2717 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java @@ -81,7 +81,7 @@ public class InscriptionService { ); userRepo.save(userFromRequest); - userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()))); + userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0)); } inscrRequest.setState(requestState); save(inscrRequest); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java new file mode 100644 index 0000000..1feacc8 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java @@ -0,0 +1,66 @@ +package ovh.herisson.Clyde.Tables; + + +import jakarta.persistence.*; + +@Entity +public class ExemptionsRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name = "Users") + private User user; + + @ManyToOne + @JoinColumn(name = "Course") + private Course course; + private String justifDocument; + + private RequestState state; + + + public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state){ + this.user = user; + this.course = course; + this.justifDocument = justifDocument; + this.state = state; + } + + + public ExemptionsRequest(){} + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Course getCourse() { + return course; + } + + public void setCourse(Course course) { + this.course = course; + } + + public String getJustifDocument() { + return justifDocument; + } + + public void setJustifDocument(String justifDocument) { + this.justifDocument = justifDocument; + } + + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java new file mode 100644 index 0000000..1182911 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java @@ -0,0 +1,59 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + +@Entity +public class ScholarshipRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name = "Users") + private User user; + private RequestState state; + private String requestForm; + private int amount; + + + public ScholarshipRequest(User user, RequestState state, String requestForm, int amount){ + this.user = user; + this.state = state; + this.requestForm = requestForm; + this.amount = amount; + } + + public ScholarshipRequest(){} + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } + + public String getRequestForm() { + return requestForm; + } + + public void setRequestForm(String requestForm) { + this.requestForm = requestForm; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java new file mode 100644 index 0000000..d2cbf73 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java @@ -0,0 +1,28 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class UninscriptionRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private RequestState state; + + public UninscriptionRequest(RequestState state){ + this.state = state; + } + + public UninscriptionRequest(){} + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java index f42e588..b79295b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java @@ -21,9 +21,12 @@ public class UserCurriculum { @OnDelete(action = OnDeleteAction.CASCADE) private Curriculum curriculum; - public UserCurriculum(User user, Curriculum curriculum){ + private int year; + + public UserCurriculum(User user, Curriculum curriculum, int year){ this.user = user; this.curriculum = curriculum; + this.year = year; } public UserCurriculum() {} @@ -47,4 +50,12 @@ public class UserCurriculum { public void setCurriculum(Curriculum curriculum) { this.curriculum = curriculum; } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } } diff --git a/frontend/src/Apps/AboutStudent.vue b/frontend/src/Apps/AboutStudent.vue new file mode 100644 index 0000000..442fd35 --- /dev/null +++ b/frontend/src/Apps/AboutStudent.vue @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file From 67fa630ecfbe0105212a04f8b4f3c8d7b55aacd4 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sat, 23 Mar 2024 18:04:36 +0100 Subject: [PATCH 02/21] e --- frontend/src/Apps/AboutStudent.vue | 84 +++++++++++++++++++++++++----- frontend/src/rest/apps.js | 3 ++ 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/frontend/src/Apps/AboutStudent.vue b/frontend/src/Apps/AboutStudent.vue index 442fd35..aaaeafc 100644 --- a/frontend/src/Apps/AboutStudent.vue +++ b/frontend/src/Apps/AboutStudent.vue @@ -1,24 +1,82 @@ - \ No newline at end of file diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js index 99cbc10..44fb7c4 100644 --- a/frontend/src/rest/apps.js +++ b/frontend/src/rest/apps.js @@ -9,6 +9,7 @@ import Profil from "@/Apps/Profil.vue" import Courses from "@/Apps/ManageCourses.vue" import Users from "@/Apps/UsersList.vue" import Students from "@/Apps/StudentsList.vue" +import AboutStudent from "@/Apps/AboutStudent.vue"; const apps = { '/login': LoginPage, @@ -17,6 +18,7 @@ const apps = { '/manage-courses' : Courses, '/users-list' : Users, '/students-list' : Students, + '/about-students': AboutStudent } const appsList = { @@ -28,6 +30,7 @@ const appsList = { 'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") }, 'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")}, 'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")}, + 'AboutStudent':{ path: '#/about-users', icon: 'fa-users', text:i18n("app.aboutStudent")} } const currentPath = ref(window.location.hash) From eafff6ec2d9c2f605cc414f461e75289fd9add71 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Mon, 25 Mar 2024 09:57:35 +0100 Subject: [PATCH 03/21] =?UTF-8?q?Ajoute=20le=20d=C3=A9tail=20des=20=C3=A9t?= =?UTF-8?q?udiants=20(big=20update)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clyde/EndPoints/CurriculumController.java | 23 +++- .../Clyde/EndPoints/MockController.java | 17 ++- .../UserCurriculumRepository.java | 4 + .../Clyde/Services/CurriculumService.java | 1 - .../Clyde/Services/UserCurriculumService.java | 32 +++++- frontend/src/Apps/AboutStudent.vue | 106 ++++++++++++++++-- frontend/src/Apps/Profil.vue | 1 - frontend/src/Apps/StudentsList.vue | 21 +++- frontend/src/rest/apps.js | 2 - frontend/src/rest/curriculum.js | 4 + 10 files changed, 188 insertions(+), 23 deletions(-) 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 409e269..bef813a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -8,7 +8,9 @@ import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.Role; +import ovh.herisson.Clyde.Tables.User; +import java.util.HashMap; import java.util.Map; @RestController @@ -22,11 +24,14 @@ public class CurriculumController { private final UserCurriculumService userCurriculumServ; private final CurriculumCourseService curriculumCourseServ; - public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){ + private final UserService userServ; + + public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, UserService userServ){ this.curriculumServ = curriculumServ; this.authServ = authServ; this.userCurriculumServ = userCurriculumServ; this.curriculumCourseServ = curriculumCourseServ; + this.userServ = userServ; } @GetMapping("/curriculum/{id}") @@ -52,6 +57,22 @@ public class CurriculumController { return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK); } + + //Return the list of all curicullums of an user + @GetMapping("/onescurriculum/{userId}") + public ResponseEntity> findOnesCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){ + if (authServ.getUserFromToken(token) == null) + return new UnauthorizedResponse<>(null); + + User u = userServ.getUserById(Long.parseLong(userId)); + HashMap toReturn = userCurriculumServ.findAllCurriculumByStudent(u); + + if (toReturn == null) + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + + return new ResponseEntity<>(toReturn,HttpStatus.OK); + } + @GetMapping("/curriculums") public ResponseEntity>> findAllIndDepth(){ return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK); 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 0b7a1b4..76414ed 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -3,6 +3,7 @@ package ovh.herisson.Clyde.EndPoints; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.*; import ovh.herisson.Clyde.Repositories.TokenRepository; +import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Tables.*; @@ -26,8 +27,9 @@ public class MockController { public final InscriptionService inscriptionService; ArrayList mockUsers; + public final UserCurriculumRepository ucr; - public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){ + public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, UserCurriculumRepository ucr){ this.tokenRepo = tokenRepo; this.userRepo = userRepo; this.tokenService = tokenService; @@ -35,6 +37,7 @@ public class MockController { this.curriculumService = curriculumService; this.courseService = courseService; this.inscriptionService = inscriptionService; + this.ucr = ucr; } /** Saves an example of each user type by : @@ -47,15 +50,14 @@ public class MockController { public void postMock(){ // user part - - User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin")); User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student")); User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService")); - mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo)); + User popo = new User("Smith", "Paul", "paulsmith@gmail.com", "306 rue du poulet", "belgique", new Date(0), null, Role.Student, passwordEncoder.encode("jesuispaulleroi")); + mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo, popo)); userRepo.saveAll(mockUsers); @@ -64,11 +66,18 @@ public class MockController { Curriculum infoBab1 = new Curriculum(1,"info"); Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); Curriculum psychologyBab1 = new Curriculum(1,"psychology"); + Curriculum infoBab2 = new Curriculum(2,"info"); curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); + curriculumService.save(infoBab2); + ucr.save(new UserCurriculum(joe, infoBab1, 2022)); + ucr.save(new UserCurriculum(joe, chemistryBab1, 2023)); + ucr.save(new UserCurriculum(joe, psychologyBab1, 2020)); + ucr.save(new UserCurriculum(popo, infoBab1, 2022)); + ucr.save(new UserCurriculum(popo, infoBab2, 2023)); Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); Course chemistry1 = new Course(12, "Thermochimie",joke); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java index 32f207a..2f1c2a3 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java @@ -6,8 +6,12 @@ import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.User; import ovh.herisson.Clyde.Tables.UserCurriculum; +import java.util.ArrayList; + public interface UserCurriculumRepository extends CrudRepository { @Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1") Curriculum findByUser(User student); + + ArrayList findByUserOrderByCurriculum(User student); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java index af04d78..790c51f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java @@ -18,7 +18,6 @@ public class CurriculumService { public Curriculum findById(long id){ return curriculumRepo.findById(id); } - public void delete(Curriculum curriculum) { curriculumRepo.delete(curriculum); } 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 6484e2b..99c4669 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java @@ -1,20 +1,50 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.User; +import ovh.herisson.Clyde.Tables.UserCurriculum; + +import java.util.ArrayList; +import java.util.HashMap; @Service public class UserCurriculumService { private final UserCurriculumRepository userCurriculumRepository; + private final CurriculumRepository curriculumRepo; - public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) { + public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo) { this.userCurriculumRepository = userCurriculumRepository; + this.curriculumRepo = curriculumRepo; } public Curriculum findByUser(User student){ return userCurriculumRepository.findByUser(student); } + + public HashMap findAllCurriculumByStudent(User student) { + ArrayList list = userCurriculumRepository.findByUserOrderByCurriculum(student); + + ArrayList> curriculumlist = new ArrayList>(); + + for (int i = 0; i < list.size(); i++) { + HashMap element = new HashMap<>(); + Curriculum c = list.get(i).getCurriculum(); + + + element.put("curriculumId", c.getCurriculumId()); + element.put("year", c.getYear()); + element.put("option", c.getOption()); + element.put("dateyear", list.get(i).getYear()); + curriculumlist.add(element); + } + + HashMap toReturn = new HashMap(); + toReturn.put("curriculumList", curriculumlist); + return toReturn; + } + } diff --git a/frontend/src/Apps/AboutStudent.vue b/frontend/src/Apps/AboutStudent.vue index aaaeafc..52f0fe1 100644 --- a/frontend/src/Apps/AboutStudent.vue +++ b/frontend/src/Apps/AboutStudent.vue @@ -1,16 +1,29 @@ - \ No newline at end of file diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 3e2eacc..36f926a 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -210,7 +210,6 @@ \ No newline at end of file diff --git a/frontend/src/Apps/Inscription.vue b/frontend/src/Apps/Inscription.vue index 94a1811..b5a5333 100644 --- a/frontend/src/Apps/Inscription.vue +++ b/frontend/src/Apps/Inscription.vue @@ -2,9 +2,13 @@ import i18n from "@/i18n.js" import {ref} from 'vue' import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js' + import AboutRequest from "@/Apps/AboutRequest.vue"; const requests = ref(await getAllRegisters()); - console.log(requests); + let targetId = ""; + + //0 = liste, 1 = détails, 2 = sure? + let windowsState = ref(0); async function upPage(id,review){ await validateRegister(id,review); @@ -15,19 +19,29 @@ -