diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index d4fdaa0..b2dcd50 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -70,6 +70,9 @@ public class ApplicationsController { if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){ authorizedApps.add(Applications.UsersList);} + + if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.InscriptionService},token)){ + authorizedApps.add(Applications.Payments);} return authorizedApps; } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java index e88c759..a8a87ce 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java @@ -30,9 +30,16 @@ public class ExternalCurriculumController { //everyone can post some externalcurriculums (the validity of the elements is assured by the inscription service) @PostMapping("/externalcurriculum") public ResponseEntity postExternalCurriculum(@RequestBody Map externalCurrInfos){ - InscriptionRequest ir = inscriptionRepository.findById((Integer) externalCurrInfos.get("inscriptionRequestId")); + //An external curriculum can either be linked to an User or to an InscriptionRequest + InscriptionRequest ir = null; + User user = null; + if (externalCurrInfos.get("inscriptionRequestId") != null){ + ir = inscriptionRepository.findById((Integer) externalCurrInfos.get("inscriptionRequestId")); + }else{ + user = userRepository.findById((Integer) externalCurrInfos.get("userRegNo")); + } - ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifDocUrl"), null); + ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifDocUrl"), user); return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java index b70ad59..9a16fb2 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java @@ -34,4 +34,12 @@ public class PaymentController { return new ResponseEntity<>(toReturn, HttpStatus.OK); } + @GetMapping("/payment") + public ResponseEntity> getAllPayments(){ + ArrayList toReturn = new ArrayList(); + + + paymentRepository.findAll().forEach(toReturn::add); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java index 61489bf..f423984 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java @@ -4,18 +4,23 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import ovh.herisson.Clyde.Repositories.CourseRepository; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; +import ovh.herisson.Clyde.Repositories.Inscription.ChangeCurriculumRequestRepository; import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository; import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository; -import ovh.herisson.Clyde.Repositories.Inscription.UninscriptionRequestRepository; +import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository; +import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Services.UserService; import ovh.herisson.Clyde.Tables.*; import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; -import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest; +import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.Map; @@ -27,16 +32,25 @@ public class RequestsController { public final ScholarshipRequestRepository srr; public final UserRepository userRepository; public final AuthenticatorService authServ; - public final UninscriptionRequestRepository uninscriptionRequestRepository; + public final UnregisterRequestRepository unregisterRequestRepository; public final CourseRepository courseRepository; + public final UserService userService; + public final UserCurriculumRepository userCurriculumRepository; + public final CurriculumRepository curriculumRepository; - public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UninscriptionRequestRepository uninscriptionRequestRepository, CourseRepository courseRepository) { + public final ChangeCurriculumRequestRepository changeCurriculumRequestRepository; + + public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) { this.err = err; this.srr = srr; this.userRepository = userRepository; this.authServ = authServ; - this.uninscriptionRequestRepository = uninscriptionRequestRepository; + this.unregisterRequestRepository = unregisterRequestRepository; this.courseRepository = courseRepository; + this.userService = userService; + this.userCurriculumRepository = userCurriculumRepository; + this.curriculumRepository = curriculumRepository; + this.changeCurriculumRequestRepository = changeCurriculumRequestRepository; } @PostMapping(value="/exemptionreq") @@ -87,11 +101,154 @@ public class RequestsController { return new ResponseEntity<>(toReturn, HttpStatus.OK); } - @PostMapping(value = "/uninscriptionreq") + @PostMapping(value = "/unregister") public ResponseEntity postUnregReq(@RequestBody Map uninscr){ User u = userRepository.findById((int) uninscr.get("userId")); - UninscriptionRequest ur = new UninscriptionRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u); - uninscriptionRequestRepository.save(ur); + Curriculum c; + + if (uninscr.get("curriculumId") == null){ + c = null; + }else{ + c = curriculumRepository.findById((Integer) uninscr.get("curriculumId")); + } + + UnregisterRequest ur = new UnregisterRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u.getRegNo(), u.getFirstName(), u.getLastName(), u.getEmail(), c); + unregisterRequestRepository.save(ur); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PatchMapping(value = "/scholarshipreq/") + public ResponseEntity editScholReq(@RequestBody Map infos){ + ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id")); + + if (infos.get("state").equals("Accepted")){ + scholarshipRequest.setState(RequestState.Accepted); + scholarshipRequest.setAmount((int) infos.get("amount")); + }else{ + scholarshipRequest.setState(RequestState.Refused); + } + + srr.save(scholarshipRequest); + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping(value = "/scholarshipreq/{id}") + public ResponseEntity getScholReqbyId(@PathVariable long id){ + ScholarshipRequest toReturn = srr.findById(id); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + @GetMapping(value = "/unregister") + public ResponseEntity> getAllUnregReq(){ + ArrayList toReturn = new ArrayList<>(); + unregisterRequestRepository.findAll().forEach(toReturn::add); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + @GetMapping(value = "/unregister/{id}") + public ResponseEntity getUnregbyId(@PathVariable long id){ + UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id); + return new ResponseEntity<>(unregisterRequest, HttpStatus.OK); + } + + @PatchMapping(value = "/unregister/{id}/{newstate}") + public ResponseEntity pathUnregReq(@PathVariable long id, @PathVariable RequestState newstate){ + UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id); + User u = userRepository.findById(unregisterRequest.getRegNo()); + unregisterRequest.setState(newstate); + + if (newstate == RequestState.Accepted){ + if (unregisterRequest.getCurriculum() == null){ + ArrayList userCurricula = userCurriculumRepository.findByUserOrderByCurriculum(u); + for (int i = 0; i < userCurricula.size(); i++){ + userCurricula.get(i).setActual(false); + } + userCurriculumRepository.saveAll(userCurricula); + }else{ + //This usercurriculum will contain the usercurriculum to set false + UserCurriculum userCurriculum = userCurriculumRepository.findByUserAndCurriculumAndActual(u, unregisterRequest.getCurriculum(), true); + userCurriculum.setActual(false); + userCurriculumRepository.save(userCurriculum); + } + } + + unregisterRequestRepository.save(unregisterRequest); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PostMapping("/changecurriculumreq") + public ResponseEntity addChangeCurrReq(@RequestBody Map reqInfos){ + User user = userRepository.findById((Integer) reqInfos.get("userId")); + + Curriculum actualCurriculum; + + //If null then it means we are in a supplementary cursus case + if (reqInfos.get("actualcursus") == null){ + actualCurriculum = null; + }else{ + actualCurriculum = curriculumRepository.findById((Integer) reqInfos.get("actualcursus")); + } + + Curriculum destinationCurriculum = curriculumRepository.findById((Integer) reqInfos.get("newcursus")); + + ChangeCurriculumRequest changeCurriculumRequest = new ChangeCurriculumRequest(user, actualCurriculum, destinationCurriculum, new Date(), RequestState.Pending); + + changeCurriculumRequestRepository.save(changeCurriculumRequest); + + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping("/changecurriculumreq") + public ResponseEntity> getAllChangeCurrReq(@RequestHeader("Authorization") String token){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ArrayList toReturn = new ArrayList<>(); + + changeCurriculumRequestRepository.findAll().forEach(toReturn::add); + + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + @GetMapping("/changecurriculumreq/{id}") + public ResponseEntity getCCrbyId(@RequestHeader("Authorization") String token, @PathVariable long id){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ChangeCurriculumRequest toReturn = changeCurriculumRequestRepository.findById(id); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + @PatchMapping("/changecurriculumreq/{id}/{newState}") + public ResponseEntity editCCReq(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newState){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ChangeCurriculumRequest toEdit = changeCurriculumRequestRepository.findById(id); + + toEdit.setState(newState); + + if (newState == RequestState.Accepted){ + //If actual curriculum is not null then we need to set that the user doesn't follow it anymore + User u = toEdit.getUser(); + if (toEdit.getActualCurriculum() != null){ + ArrayList listcurr = userCurriculumRepository.findByUserOrderByCurriculum(u); + + for (int i = 0; i < listcurr.size(); i++){ + if (listcurr.get(i).getCurriculum() == toEdit.getActualCurriculum()){ + listcurr.get(i).setActual(false); + } + } + + userCurriculumRepository.saveAll(listcurr); + } + + Calendar c = Calendar.getInstance(); + UserCurriculum userCurriculum = new UserCurriculum(u, toEdit.getDestinationCurriculum(), c.get(Calendar.YEAR), true); + userCurriculumRepository.save(userCurriculum); + } + + changeCurriculumRequestRepository.save(toEdit); return new ResponseEntity<>(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 beb27fe..6ff0707 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -6,13 +6,11 @@ import ovh.herisson.Clyde.Repositories.*; import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository; import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository; +import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository; import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Services.Inscription.InscriptionService; import ovh.herisson.Clyde.Tables.*; -import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; -import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; -import ovh.herisson.Clyde.Tables.Inscription.Minerval; -import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; +import ovh.herisson.Clyde.Tables.Inscription.*; import java.util.ArrayList; import java.util.Arrays; @@ -40,7 +38,8 @@ public class MockController { public final ScholarshipRequestRepository scholarshipRequestRepository; - public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository){ + public final UnregisterRequestRepository uninscriptionRequestRepository; + public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository, UnregisterRequestRepository unregisterRequestRepository){ this.userService = userService; this.tokenRepo = tokenRepo; this.userRepo = userRepo; @@ -53,6 +52,7 @@ public class MockController { this.ucr = ucr; this.minervalRepository = minervalRepository; this.scholarshipRequestRepository = scholarshipRequestRepository; + this.uninscriptionRequestRepository = unregisterRequestRepository; } /** Saves an example of each user type by : @@ -76,6 +76,9 @@ public class MockController { userService.saveAll(mockUsers); + ExternalCurriculum externalCurriculum = new ExternalCurriculum(null, "HEH", "Bachelier en ingénieur", "completed", 2015, 2017, null, joe); + externalCurriculumRepository.save(externalCurriculum); + Minerval minerval = new Minerval(joe.getRegNo(), 0, 852, 2023); minervalRepository.save(minerval); // Course / Curriculum part @@ -86,20 +89,21 @@ public class MockController { Curriculum infoBab2 = new Curriculum(2,"info"); Curriculum masterinfo1 = new Curriculum(4, "info"); Curriculum masterinfo2 = new Curriculum(5, "info"); - + Curriculum chemistryBab2 = new Curriculum(2, "chemistry"); curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); curriculumService.save(infoBab2); curriculumService.save(masterinfo1); curriculumService.save(masterinfo2); + curriculumService.save(chemistryBab2); - ucr.save(new UserCurriculum(joe, infoBab1, 2022)); - ucr.save(new UserCurriculum(joe, chemistryBab1, 2023)); - ucr.save(new UserCurriculum(joe, infoBab1, 2023)); - ucr.save(new UserCurriculum(joe, psychologyBab1, 2020)); - ucr.save(new UserCurriculum(popo, infoBab1, 2022)); - ucr.save(new UserCurriculum(popo, infoBab2, 2023)); + ucr.save(new UserCurriculum(joe, infoBab1, 2022, false)); + ucr.save(new UserCurriculum(joe, chemistryBab1, 2023, true)); + ucr.save(new UserCurriculum(joe, infoBab1, 2023, true)); + ucr.save(new UserCurriculum(joe, psychologyBab1, 2020, false)); + ucr.save(new UserCurriculum(popo, infoBab1, 2022, false)); + ucr.save(new UserCurriculum(popo, infoBab2, 2023, true)); Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); Course chemistry1 = new Course(12, "Thermochimie",joke); @@ -129,7 +133,10 @@ public class MockController { inscriptionService.save(inscriptionRequest); - ExternalCurriculum externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null); + UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail(), null); + uninscriptionRequestRepository.save(unregisterRequest); + + externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null); externalCurriculumRepository.save(externalCurriculum); } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java new file mode 100644 index 0000000..0248e43 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java @@ -0,0 +1,9 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.ChangeCurriculumRequest; + +public interface ChangeCurriculumRequestRepository extends CrudRepository { + ChangeCurriculumRequest findById(long id); +} + diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java index 5550937..c0c1407 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java @@ -4,5 +4,5 @@ import org.springframework.data.repository.CrudRepository; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; public interface ScholarshipRequestRepository extends CrudRepository { - + public ScholarshipRequest findById(long id); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UninscriptionRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UninscriptionRequestRepository.java deleted file mode 100644 index 6d38b8c..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UninscriptionRequestRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package ovh.herisson.Clyde.Repositories.Inscription; - -import org.springframework.data.repository.CrudRepository; -import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest; - -public interface UninscriptionRequestRepository extends CrudRepository { -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java new file mode 100644 index 0000000..f6a4ebc --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java @@ -0,0 +1,8 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest; + +public interface UnregisterRequestRepository extends CrudRepository { + public UnregisterRequest findById(long l); +} 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 2f1c2a3..75922fa 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java @@ -14,4 +14,6 @@ public interface UserCurriculumRepository extends CrudRepository findByUserOrderByCurriculum(User student); + UserCurriculum findByUserAndCurriculumAndActual(User user, Curriculum curriculum, boolean actual); + } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java index b889533..208471d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java @@ -13,6 +13,7 @@ import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.Inscription.Minerval; import java.util.ArrayList; +import java.util.Calendar; @Service public class InscriptionService { @@ -87,7 +88,8 @@ public class InscriptionService { ); userService.save(userFromRequest); - userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0)); + Calendar c = Calendar.getInstance(); + userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),c.get(Calendar.YEAR), true)); //Create a minerval for the new student Minerval minerval = new Minerval(userFromRequest.getRegNo(), 0, 852, 2023); 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 8b446df..2861a6e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java @@ -35,11 +35,12 @@ public class UserCurriculumService { 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()); + element.put("actual", list.get(i).isActual()); + curriculumlist.add(element); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java index 5c39891..77a7074 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -19,5 +19,6 @@ public enum Applications { // InscriptionService authorization Requests, - StudentsList + StudentsList, + Payments } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java new file mode 100644 index 0000000..72feebd --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java @@ -0,0 +1,83 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + +import java.util.Date; + +@Entity +public class ChangeCurriculumRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name="Users") + private User user; + + @ManyToOne + @JoinColumn(name = "ActualCurriculum") + private Curriculum actualCurriculum; + + @ManyToOne + @JoinColumn(name = "DestCurriculum") + private Curriculum destinationCurriculum; + + private Date date; + + private RequestState state; + + public ChangeCurriculumRequest(){} + + public ChangeCurriculumRequest(User user, Curriculum actualCurriculum, Curriculum destinationCurriculum, Date date, RequestState state){ + this.user = user; + this.actualCurriculum = actualCurriculum; + this.destinationCurriculum = destinationCurriculum; + this.date = date; + this.state = state; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + + public Curriculum getActualCurriculum() { + return actualCurriculum; + } + + public void setActualCurriculum(Curriculum actualCurriculum) { + this.actualCurriculum = actualCurriculum; + } + + public Curriculum getDestinationCurriculum() { + return destinationCurriculum; + } + + public void setDestinationCurriculum(Curriculum destinationCurriculum) { + this.destinationCurriculum = destinationCurriculum; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } + + public int getId() { + return id; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java index 48626e1..5f4fbf9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java @@ -12,7 +12,6 @@ public class Payment { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - private long studentRegNo; private String card; private String client; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java index 18ebee6..842bf90 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java @@ -7,15 +7,16 @@ import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.User; import java.util.Date; +import java.util.Map; @Entity public class ScholarshipRequest { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - @JoinColumn(name="Users") @ManyToOne(fetch = FetchType.EAGER) + @OnDelete(action = OnDeleteAction.CASCADE) private User user; private RequestState state; private Date date; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UninscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UninscriptionRequest.java deleted file mode 100644 index e7858c6..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UninscriptionRequest.java +++ /dev/null @@ -1,67 +0,0 @@ -package ovh.herisson.Clyde.Tables.Inscription; - -import jakarta.persistence.*; -import ovh.herisson.Clyde.Tables.RequestState; -import ovh.herisson.Clyde.Tables.User; - -import java.util.Date; - -@Entity -public class UninscriptionRequest { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - private RequestState state; - private String reason; - private Date date; - - @JoinColumn(name = "Users") - @ManyToOne(fetch = FetchType.EAGER) - private User user; - - public UninscriptionRequest(RequestState state,String reason, Date date, User user){ - this.state = state; - this.reason = reason; - this.date = date; - this.user = user; - } - - public UninscriptionRequest(){} - - public RequestState getState() { - return state; - } - - public void setState(RequestState state) { - this.state = state; - } - - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - public long getId() { - return id; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public void setDate(Date date) { - this.date = date; - } - - public Date getDate() { - return date; - } -} - diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java new file mode 100644 index 0000000..9127ecb --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java @@ -0,0 +1,115 @@ +package ovh.herisson.Clyde.Tables.Inscription; + +import jakarta.persistence.*; +import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.RequestState; +import ovh.herisson.Clyde.Tables.User; + +import java.util.Date; + +@Entity +public class UnregisterRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + private RequestState state; + private String reason; + private Date date; + + //We store these informations again so if the user is deleted we still have the informations for history + private long regNo; + + private String firstName; + + private String lastName; + + private String email; + + //Null if the user unregister for the academic year, contains a curriculum if the user wants to unregister from a specific curriculum + @ManyToOne + @JoinColumn(name = "Curriculum") + private Curriculum curriculum; + + public UnregisterRequest(RequestState state, String reason, Date date, long regNo, String firstName, String lastName, String email, Curriculum curriculum){ + this.state = state; + this.reason = reason; + this.date = date; + this.regNo = regNo; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.curriculum = curriculum; + } + + public UnregisterRequest(){} + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public long getId() { + return id; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public String getEmail() { + return email; + } + + public String getLastName() { + return lastName; + } + + public String getFirstName() { + return firstName; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public void setRegNo(long regNo) { + this.regNo = regNo; + } + + public long getRegNo() { + return regNo; + } + + public void setCurriculum(Curriculum curriculum) { + this.curriculum = curriculum; + } + + public Curriculum getCurriculum() { + return curriculum; + } + +} + diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index ea3f8d6..b21738e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -1,6 +1,9 @@ package ovh.herisson.Clyde.Tables; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.GenericGenerator; import ovh.herisson.Clyde.Tables.Msg.Discussion; import ovh.herisson.Clyde.Tables.Msg.Message; @@ -8,9 +11,6 @@ import ovh.herisson.Clyde.Tables.Msg.Message; import java.util.Date; import java.util.List; -import com.fasterxml.jackson.annotation.JsonIgnore; - - @Entity @Table(name = "Users") public class User { @@ -27,6 +27,7 @@ public class User { private Date birthDate; private String profilePictureUrl; private Role role; + @JsonIgnore private String password; 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 b79295b..395eca7 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java @@ -23,10 +23,14 @@ public class UserCurriculum { private int year; - public UserCurriculum(User user, Curriculum curriculum, int year){ + //True if the user has that curriculum at the moment false if not + private boolean actual; + + public UserCurriculum(User user, Curriculum curriculum, int year, boolean actual){ this.user = user; this.curriculum = curriculum; this.year = year; + this.actual = actual; } public UserCurriculum() {} @@ -58,4 +62,12 @@ public class UserCurriculum { public void setYear(int year) { this.year = year; } + + public void setActual(boolean actual) { + this.actual = actual; + } + + public boolean isActual() { + return actual; + } } diff --git a/frontend/public/i18n/EN.txt b/frontend/public/i18n/EN.txt index e79a8a1..2e860ac 100644 --- a/frontend/public/i18n/EN.txt +++ b/frontend/public/i18n/EN.txt @@ -28,6 +28,7 @@ app.language=Language app.manage.profile=Manage profile app.studentList=Students List app.users=Users +app.payments = Payments request.moreInfos=More Infos request.accept=Accept request.refuse=Refuse diff --git a/frontend/public/i18n/FR.txt b/frontend/public/i18n/FR.txt index c5f3ebf..de9af13 100644 --- a/frontend/public/i18n/FR.txt +++ b/frontend/public/i18n/FR.txt @@ -28,6 +28,7 @@ app.language=Langue app.manage.profile=Gérer le profil app.studentList=Liste des étudiants app.users=Utilisateurs +app.payments = Payements request.moreInfos=Plus d'Infos request.accept=Accepter request.refuse=Refuser @@ -52,3 +53,4 @@ Curriculum=Cursus Credits=Credits InscriptionService=S.I. faculty=Faculté + diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 40fbbc6..0ab750a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -25,7 +25,6 @@ window.addEventListener('hashchange', () => { const login=ref(i18n("app.login")) const active=ref(false) - const apps = ref([]) appList().then(e => apps.value = e) @@ -33,7 +32,6 @@ window.addEventListener('hashchange', () => { diff --git a/frontend/src/Apps/Inscription/AboutUnregister.vue b/frontend/src/Apps/Inscription/AboutUnregister.vue new file mode 100644 index 0000000..fe8f001 --- /dev/null +++ b/frontend/src/Apps/Inscription/AboutUnregister.vue @@ -0,0 +1,109 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue index a642840..eba1cdf 100644 --- a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue +++ b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue @@ -1,25 +1,91 @@ diff --git a/frontend/src/Apps/Inscription/ManageRequests.vue b/frontend/src/Apps/Inscription/ManageRequests.vue index e45a1a5..cb8345e 100644 --- a/frontend/src/Apps/Inscription/ManageRequests.vue +++ b/frontend/src/Apps/Inscription/ManageRequests.vue @@ -3,7 +3,15 @@ import {ref} from 'vue' import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js' import AboutRequest from "@/Apps/Inscription/AboutRequest.vue"; - import {getAllExemptionsRequest, getAllScholarShipsRequest} from "@/rest/requests.js"; + import { + getAllChangeCurrReq, + getAllExemptionsRequest, + getAllScholarShipsRequest, + getAllUnregisters + } from "@/rest/requests.js"; + import AboutScholarship from "@/Apps/Inscription/AboutScholarship.vue"; + import AboutUnregister from "@/Apps/Inscription/AboutUnregister.vue"; + import AboutChangeCurriculum from "@/Apps/Inscription/AboutChangeCurriculum.vue"; const requests = ref(await getAllRegisters()); let targetId = ""; @@ -11,7 +19,7 @@ const requestType = ref("inscription"); const filterType = ref("None"); - //0 = liste, 1 = détails, 2 = sure? + //0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship, 4 manage unregister, 5 = manage curriculum change let windowsState = ref(0); async function upPage(id,review){ @@ -21,14 +29,21 @@ } async function loadRequests(){ - if (requestType.value === "inscription"){ - requests.value = await getAllRegisters(); - } - if (requestType.value === "scholarship"){ - requests.value = await getAllScholarShipsRequest(); - } - if(requestType.value === "exemption"){ - requests.value = await getAllExemptionsRequest(); + switch (requestType.value){ + case "inscription": + requests.value = await getAllRegisters(); + break; + case "scholarship": + requests.value = await getAllScholarShipsRequest(); + break; + case "exemption": + requests.value = await getAllExemptionsRequest(); + break; + case "unregister": + requests.value = await getAllUnregisters(); + break; + case "curriculum change": + requests.value = await getAllChangeCurrReq(); } } @@ -46,6 +61,8 @@ + + Filter : @@ -79,7 +96,7 @@
{{item.user.firstName}}
{{item.user.lastName}}
{{item.state}}
-
+
{{item.date.slice(0,10)}}
@@ -89,6 +106,21 @@
{{item.state}}
+
+
{{item.date.slice(0,10)}}
+
{{item.firstName}}
+
{{item.lastName}}
+
id : {{item.regNo}}
+
{{item.state}}
+
+
+
+
{{item.date.slice(0,10)}}
+
{{item.user.firstName}}
+
{{item.user.lastName}}
+
{{item.state}}
+
+
@@ -97,6 +129,18 @@ +
+ +
+ +
+
+
+ +
+
+ +
+ diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 5b0a807..705012f 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -53,7 +53,7 @@ setTimeout(() => { window.location.href="#/home"; }, "500"); - } + } function verifyInputs(pass){ if(pass==passwordConfirm.value){ page.value++; @@ -83,13 +83,6 @@ } } - async function getCurriculumYear(curriculumId){ - const curriculum = await getcurriculum(curriculumId); - return parseInt(curriculum.year); - } - - - //Post the register request and return the id of the newly created request and also post the external curriculum list in the database async function postRegisterReq(){ const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData, null, new Date(), outputs.equivalenceState); @@ -107,7 +100,7 @@