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 8d1f1ca..d4fdaa0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -64,8 +64,8 @@ public class ApplicationsController { if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Secretary,Role.Admin},token)) authorizedApps.add(Applications.ManageCourses); - if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token)){ - authorizedApps.add(Applications.Inscription); + if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin, Role.Teacher},token)){ + authorizedApps.add(Applications.Requests); authorizedApps.add(Applications.StudentsList);} if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){ diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java index d5e87a8..474e2cb 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java @@ -135,4 +135,5 @@ public class CourseController { courseServ.delete(courseServ.findById(id)); return new ResponseEntity<>(HttpStatus.OK); } + } 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..efe34e6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -4,11 +4,13 @@ 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.Repositories.Inscription.ExternalCurriculumRepository; +import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository; 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.*; +import java.util.HashMap; import java.util.Map; @RestController @@ -21,12 +23,18 @@ public class CurriculumController { private final UserCurriculumService userCurriculumServ; private final CurriculumCourseService curriculumCourseServ; + private final InscriptionRepository ir; + private final UserService userServ; - public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){ + private final ExternalCurriculumRepository ecr; + public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, InscriptionRepository ir, UserService userServ, ExternalCurriculumRepository ecr){ this.curriculumServ = curriculumServ; this.authServ = authServ; this.userCurriculumServ = userCurriculumServ; this.curriculumCourseServ = curriculumCourseServ; + this.ir = ir; + this.userServ = userServ; + this.ecr = ecr; } @GetMapping("/curriculum/{id}") @@ -52,6 +60,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); @@ -94,4 +118,5 @@ public class CurriculumController { curriculumServ.delete(toDelete); return new ResponseEntity<>(HttpStatus.OK); } + } 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 new file mode 100644 index 0000000..e88c759 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java @@ -0,0 +1,55 @@ +package ovh.herisson.Clyde.EndPoints.Inscription; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; +import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository; +import ovh.herisson.Clyde.Repositories.UserRepository; +import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; +import ovh.herisson.Clyde.Tables.User; + +import java.util.ArrayList; +import java.util.Map; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +public class ExternalCurriculumController { + + public final ExternalCurriculumRepository ecr; + public final InscriptionRepository inscriptionRepository; + public final UserRepository userRepository; + + public ExternalCurriculumController(ExternalCurriculumRepository ecr, InscriptionRepository inscriptionRepository, UserRepository userRepository) { + this.ecr = ecr; + this.inscriptionRepository = inscriptionRepository; + this.userRepository = userRepository; + } + + //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")); + + 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); + + return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK); + } + + @GetMapping("/externalcurriculum/{inscReqId}") + public ResponseEntity> getExternalCurrListByInscrReq(@PathVariable long inscReqId){ + InscriptionRequest ir = inscriptionRepository.findById(inscReqId); + + ArrayList toReturn = ecr.getExternalCurriculumByInscriptionRequest(ir); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + @GetMapping("/externalcurriculumbyuser/{userId}") + public ResponseEntity> getExternalCurrByUser(@PathVariable long userId){ + User user = userRepository.findById(userId); + + ArrayList toReturn = ecr.getExternalCurriculumByUser(user); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java similarity index 75% rename from backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java rename to backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java index 35c4852..60f4585 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java @@ -1,13 +1,13 @@ -package ovh.herisson.Clyde.EndPoints; +package ovh.herisson.Clyde.EndPoints.Inscription; 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.InscriptionService; +import ovh.herisson.Clyde.Services.Inscription.InscriptionService; import ovh.herisson.Clyde.Services.ProtectionService; -import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.Role; import java.util.Map; @@ -79,4 +79,22 @@ public class InscriptionController { return new ResponseEntity<>(HttpStatus.OK); } + + //Allow teacher or admin to accept or refuse the equivalence + @PatchMapping("/request/registerequiv/{id}/{newstate}") + public ResponseEntity editRegisterEquiv(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newstate){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher}, token)) + return new UnauthorizedResponse<>(null); + + InscriptionRequest toEdit = inscriptionServ.getById(id); + toEdit.setEquivalenceState(newstate); + + inscriptionServ.save(toEdit); + + if (toEdit.getState() == RequestState.Accepted && (toEdit.getEquivalenceState() == RequestState.Accepted || toEdit.getEquivalenceState() == RequestState.Unrequired)) + { + inscriptionServ.createUser(toEdit); + } + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/MinervalController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/MinervalController.java new file mode 100644 index 0000000..737f472 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/MinervalController.java @@ -0,0 +1,55 @@ +package ovh.herisson.Clyde.EndPoints.Inscription; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository; +import ovh.herisson.Clyde.Responses.UnauthorizedResponse; +import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Tables.Inscription.Minerval; +import ovh.herisson.Clyde.Tables.Role; + +import java.util.*; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +public class MinervalController { + private final AuthenticatorService authServ; + private final MinervalRepository mr; + + public MinervalController(AuthenticatorService authServ, MinervalRepository mr) { + this.authServ = authServ; + this.mr = mr; + } + + //A new minerval entry is posted when the inscription service accept a registration request + @PostMapping("/minerval/{studentRegNo}") + public ResponseEntity postMinerval(@RequestHeader("Authorization") String token, @PathVariable long studentRegNo){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + Calendar c = new GregorianCalendar(); + + mr.save(new Minerval(studentRegNo, 0, 835, c.get(Calendar.YEAR))); + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping("/minerval/{studentRegNo}") + public ResponseEntity getCurrentMinervalbyRegNo(@PathVariable long studentRegNo){ + ArrayList mlist = mr.getMinervalsByStudentRegNoOrderByYearDesc(studentRegNo); + + //The list is ordered by year in descending order then the index 0 contains the actual minerval (for this year) + Minerval m = mlist.get(0); + return new ResponseEntity<>(m, HttpStatus.OK); + } + + @PatchMapping("/minerval") + public ResponseEntity updateMinerval(@RequestBody Minerval updatedMinerval){ + Minerval minerval = mr.findById(updatedMinerval.getId()); + + minerval.setPaidAmount(updatedMinerval.getPaidAmount()); + minerval.setToPay(updatedMinerval.getToPay()); + mr.save(minerval); + return new ResponseEntity<>(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 new file mode 100644 index 0000000..b70ad59 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java @@ -0,0 +1,37 @@ +package ovh.herisson.Clyde.EndPoints.Inscription; + + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Repositories.Inscription.PaymentRepository; +import ovh.herisson.Clyde.Tables.Inscription.Payment; + +import java.util.ArrayList; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +public class PaymentController { + + private final PaymentRepository paymentRepository; + + public PaymentController(PaymentRepository paymentRepository){ + this.paymentRepository = paymentRepository; + } + + //Post a payment record + @PostMapping("/payment") + public ResponseEntity postPayment(@RequestBody Payment payment){ + paymentRepository.save(payment); + return new ResponseEntity<>(HttpStatus.OK); + } + + + //Get all payment records of a student + @GetMapping("/payment/{studentRegNo}") + public ResponseEntity> getPaymentsByUser(@PathVariable long studentRegNo){ + ArrayList toReturn = paymentRepository.getPaymentsByStudentRegNo(studentRegNo); + 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 new file mode 100644 index 0000000..61489bf --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java @@ -0,0 +1,97 @@ +package ovh.herisson.Clyde.EndPoints.Inscription; + +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.Inscription.ExemptionsRequestRepository; +import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository; +import ovh.herisson.Clyde.Repositories.Inscription.UninscriptionRequestRepository; +import ovh.herisson.Clyde.Repositories.UserRepository; +import ovh.herisson.Clyde.Responses.UnauthorizedResponse; +import ovh.herisson.Clyde.Services.AuthenticatorService; +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 java.util.ArrayList; +import java.util.Date; +import java.util.Map; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +public class RequestsController { + + public final ExemptionsRequestRepository err; + public final ScholarshipRequestRepository srr; + public final UserRepository userRepository; + public final AuthenticatorService authServ; + public final UninscriptionRequestRepository uninscriptionRequestRepository; + public final CourseRepository courseRepository; + + public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UninscriptionRequestRepository uninscriptionRequestRepository, CourseRepository courseRepository) { + this.err = err; + this.srr = srr; + this.userRepository = userRepository; + this.authServ = authServ; + this.uninscriptionRequestRepository = uninscriptionRequestRepository; + this.courseRepository = courseRepository; + } + + @PostMapping(value="/exemptionreq") + public ResponseEntity createExemptionReq(@RequestBody Map exemptionsRequestInfo){ + User user = userRepository.findById((Integer) exemptionsRequestInfo.get("userRegNo")); + Course course = courseRepository.findById((Integer) exemptionsRequestInfo.get("courseId")); + + ExemptionsRequest exemptionsRequest = new ExemptionsRequest(user, course, (String) exemptionsRequestInfo.get("justifDocument"), RequestState.Pending, new Date()); + + err.save(exemptionsRequest); + + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PostMapping(value="/scholarshipreq") + public ResponseEntity createScholarshipReq(@RequestBody Map scholarshipRequestInfo){ + User user = userRepository.findById((Integer)scholarshipRequestInfo.get("userId")); + ScholarshipRequest toCreate = new ScholarshipRequest(user, RequestState.Pending, 0, new Date(), (String) scholarshipRequestInfo.get("taxDocUrl"), (String) scholarshipRequestInfo.get("residencyDocUrl")); + + srr.save(toCreate); + + return new ResponseEntity<>(HttpStatus.CREATED); + } + + //Get all the exemptions Request + @GetMapping(value = "/exemptionsreq") + public ResponseEntity> getAllExemptionsRequests(@RequestHeader("Authorization") String token){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ArrayList toReturn = new ArrayList<>(); + + err.findAll().forEach(toReturn::add); + + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + //Get all the scholarships requests + @GetMapping(value = "/scholarshipreq") + public ResponseEntity> getAllScholarshipRequests(@RequestHeader("Authorization") String token){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ArrayList toReturn = new ArrayList<>(); + + srr.findAll().forEach(toReturn::add); + + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } + + @PostMapping(value = "/uninscriptionreq") + 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); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java index ef3c559..7ab988d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java @@ -5,10 +5,14 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.AuthenticatorService; import ovh.herisson.Clyde.Services.ProtectionService; -import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; +import ovh.herisson.Clyde.Tables.RequestState; + import java.util.Date; import java.util.Map; @@ -16,7 +20,7 @@ import java.util.Map; @CrossOrigin(originPatterns = "*", allowCredentials = "true") public class LoginController { private final AuthenticatorService authServ; - + private final CurriculumRepository curriculumRepository; static public class RequestLogin{ private final String identifier; private final String password; @@ -29,8 +33,9 @@ public class LoginController { } } - public LoginController(AuthenticatorService authServ){ + public LoginController(AuthenticatorService authServ, CurriculumRepository curriculumRepository){ this.authServ = authServ; + this.curriculumRepository = curriculumRepository; } @PostMapping(value = "/login") @@ -48,9 +53,18 @@ public class LoginController { @PostMapping("/register") public ResponseEntity> register(@RequestBody InscriptionRequest inscriptionRequest){ + //We ensure here that if the targeted cursus year is more than first grade then we need the teacher equivalence approval + Curriculum curr = curriculumRepository.findById(inscriptionRequest.getCurriculumId()); + + if (curr.getYear() > 1){ + inscriptionRequest.setEquivalenceState(RequestState.Pending); + }else{ + inscriptionRequest.setEquivalenceState(RequestState.Unrequired); + } InscriptionRequest returnedInscriptionRequest = authServ.register(inscriptionRequest); + return new ResponseEntity<>(ProtectionService.requestWithoutPassword(returnedInscriptionRequest), HttpStatus.CREATED); } } 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..14fd259 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -2,10 +2,18 @@ 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.UserRepository; +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.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 java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -22,19 +30,28 @@ public class MockController { public final CurriculumCourseService CurriculumCourseService; public final CurriculumService curriculumService; public final CourseService courseService; - + public final ExternalCurriculumRepository externalCurriculumRepository; 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 final MinervalRepository minervalRepository; + + public final ScholarshipRequestRepository scholarshipRequestRepository; + + public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository){ this.tokenRepo = tokenRepo; this.userRepo = userRepo; this.tokenService = tokenService; this.CurriculumCourseService = CurriculumCourseService; this.curriculumService = curriculumService; this.courseService = courseService; + this.externalCurriculumRepository = externalCurriculumRepository; this.inscriptionService = inscriptionService; + this.ucr = ucr; + this.minervalRepository = minervalRepository; + this.scholarshipRequestRepository = scholarshipRequestRepository; } /** Saves an example of each user type by : @@ -47,28 +64,41 @@ 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); + Minerval minerval = new Minerval(joe.getRegNo(), 0, 852, 2023); + minervalRepository.save(minerval); // Course / Curriculum part Curriculum infoBab1 = new Curriculum(1,"info"); Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); Curriculum psychologyBab1 = new Curriculum(1,"psychology"); + Curriculum infoBab2 = new Curriculum(2,"info"); + Curriculum masterinfo1 = new Curriculum(4, "info"); + Curriculum masterinfo2 = new Curriculum(5, "info"); curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); + curriculumService.save(infoBab2); + curriculumService.save(masterinfo1); + curriculumService.save(masterinfo2); + 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)); Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); Course chemistry1 = new Course(12, "Thermochimie",joke); @@ -80,10 +110,12 @@ public class MockController { courseService.save(psycho1); courseService.save(commun); + ScholarshipRequest ssr1 = new ScholarshipRequest(joe, RequestState.Pending, 0, new Date(), "test", "test"); + scholarshipRequestRepository.save(ssr1); CurriculumCourseService.save(new CurriculumCourse(infoBab1,progra1)); CurriculumCourseService.save(new CurriculumCourse(infoBab1,commun)); - + CurriculumCourseService.save(new CurriculumCourse(infoBab1, psycho1)); CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,psycho1)); CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,commun)); @@ -92,10 +124,12 @@ public class MockController { CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1)); - InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Pending,"yes.png","password"); + InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 4,RequestState.Pending,"yes.png","password", null, new Date(), RequestState.Pending); inscriptionService.save(inscriptionRequest); - + + ExternalCurriculum 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/ExemptionsRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExemptionsRequestRepository.java new file mode 100644 index 0000000..3f66e80 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExemptionsRequestRepository.java @@ -0,0 +1,8 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; + +public interface ExemptionsRequestRepository extends CrudRepository { + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExternalCurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExternalCurriculumRepository.java new file mode 100644 index 0000000..7b4ee4e --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExternalCurriculumRepository.java @@ -0,0 +1,15 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; +import ovh.herisson.Clyde.Tables.User; + +import java.util.ArrayList; + +public interface ExternalCurriculumRepository extends CrudRepository { + ArrayList getExternalCurriculumByInscriptionRequest(InscriptionRequest ir); + + ArrayList getExternalCurriculumByUser(User user); + ExternalCurriculum getExternalCurriculumById(long id); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/InscriptionRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/InscriptionRepository.java similarity index 62% rename from backend/src/main/java/ovh/herisson/Clyde/Repositories/InscriptionRepository.java rename to backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/InscriptionRepository.java index 0d83e6b..6564377 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/InscriptionRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/InscriptionRepository.java @@ -1,7 +1,7 @@ -package ovh.herisson.Clyde.Repositories; +package ovh.herisson.Clyde.Repositories.Inscription; import org.springframework.data.repository.CrudRepository; -import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; public interface InscriptionRepository extends CrudRepository { diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/MinervalRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/MinervalRepository.java new file mode 100644 index 0000000..475ac3c --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/MinervalRepository.java @@ -0,0 +1,12 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Inscription.Minerval; + +import java.util.ArrayList; + +public interface MinervalRepository extends CrudRepository { + public ArrayList getMinervalsByStudentRegNoOrderByYearDesc(Long studentRegNo); + + public Minerval findById(long id); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/PaymentRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/PaymentRepository.java new file mode 100644 index 0000000..c479a4e --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/PaymentRepository.java @@ -0,0 +1,10 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Inscription.Payment; + +import java.util.ArrayList; + +public interface PaymentRepository extends CrudRepository { + public ArrayList getPaymentsByStudentRegNo(long regNo); +} 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 new file mode 100644 index 0000000..5550937 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java @@ -0,0 +1,8 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; + +public interface ScholarshipRequestRepository extends CrudRepository { + +} 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 new file mode 100644 index 0000000..6d38b8c --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UninscriptionRequestRepository.java @@ -0,0 +1,7 @@ +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/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/AuthenticatorService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java index 25c127f..9e517b7 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java @@ -1,7 +1,10 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Services.Inscription.InscriptionService; import ovh.herisson.Clyde.Tables.*; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; + import java.util.Date; @Service 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/Inscription/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java new file mode 100644 index 0000000..c80e2d9 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java @@ -0,0 +1,105 @@ +package ovh.herisson.Clyde.Services.Inscription; + +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.*; +import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; +import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository; +import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository; +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 java.util.ArrayList; + +@Service +public class InscriptionService { + + private final InscriptionRepository inscriptionRepo; + + private final UserRepository userRepo; + + private final UserCurriculumRepository userCurriculumRepo; + + private final CurriculumRepository curriculumRepo; + + private final MinervalRepository minervalRepository; + private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + private final ExternalCurriculumRepository externalCurriculumRepository; + + public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo, MinervalRepository minervalRepository, ExternalCurriculumRepository externalCurriculumRepository){ + this.inscriptionRepo = inscriptionRepo; + this.userRepo = userRepo; + this.userCurriculumRepo = userCurriculumRepo; + this.curriculumRepo = curriculumRepo; + this.minervalRepository = minervalRepository; + this.externalCurriculumRepository = externalCurriculumRepository; + } + + public InscriptionRequest save(InscriptionRequest inscriptionRequest){ + inscriptionRequest.setPassword(passwordEncoder.encode(inscriptionRequest.getPassword())); + return inscriptionRepo.save(inscriptionRequest); + } + + public InscriptionRequest getById(long id){ + return inscriptionRepo.findById(id); + } + + public Iterable getAll(){ + return inscriptionRepo.findAll(); + } + + public boolean modifyState(long id, RequestState requestState) { + InscriptionRequest inscrRequest = getById(id); + + if (inscrRequest == null) + return false; + + inscrRequest.setState(requestState); + save(inscrRequest); + + //saves the user from the request if accepted from teacher and inscription services + if (requestState == RequestState.Accepted && (inscrRequest.getEquivalenceState() == RequestState.Accepted || inscrRequest.getEquivalenceState() == RequestState.Unrequired)) + { + return createUser(inscrRequest); + } + return true; + } + + public boolean createUser(InscriptionRequest inscrRequest){ + //We must send an email here + + if (curriculumRepo.findById(inscrRequest.getCurriculumId()) == null) + return false; + + User userFromRequest = new User( + inscrRequest.getLastName(), + inscrRequest.getFirstName(), + inscrRequest.getEmail(), + inscrRequest.getAddress(), + inscrRequest.getCountry(), + inscrRequest.getBirthDate(), + inscrRequest.getProfilePicture(), + inscrRequest.getPassword() + ); + + userRepo.save(userFromRequest); + userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0)); + + //Create a minerval for the new student + Minerval minerval = new Minerval(userFromRequest.getRegNo(), 0, 852, 2023); + minervalRepository.save(minerval); + + //Assign the externals curriculums from the inscription request to newly created student + ArrayList extCurrList = externalCurriculumRepository.getExternalCurriculumByInscriptionRequest(inscrRequest); + for (int i = 0; i < extCurrList.size(); i++){ + extCurrList.get(i).setUser(userFromRequest); + externalCurriculumRepository.save(extCurrList.get(i)); + } + return true; + } + public void delete(InscriptionRequest toDelete) { + inscriptionRepo.delete(toDelete); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java deleted file mode 100644 index 311dbf2..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java +++ /dev/null @@ -1,94 +0,0 @@ -package ovh.herisson.Clyde.Services; - -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.stereotype.Service; -import ovh.herisson.Clyde.Repositories.CurriculumRepository; -import ovh.herisson.Clyde.Repositories.InscriptionRepository; -import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; -import ovh.herisson.Clyde.Repositories.UserRepository; -import ovh.herisson.Clyde.Tables.InscriptionRequest; -import ovh.herisson.Clyde.Tables.RequestState; -import ovh.herisson.Clyde.Tables.User; -import ovh.herisson.Clyde.Tables.UserCurriculum; - -@Service -public class InscriptionService { - - private final InscriptionRepository inscriptionRepo; - - private final UserRepository userRepo; - - private final UserCurriculumRepository userCurriculumRepo; - - private final CurriculumRepository curriculumRepo; - - private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); - - - public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo){ - this.inscriptionRepo = inscriptionRepo; - this.userRepo = userRepo; - this.userCurriculumRepo = userCurriculumRepo; - this.curriculumRepo = curriculumRepo; - } - - public InscriptionRequest save(InscriptionRequest inscriptionRequest){ - inscriptionRequest.setPassword(passwordEncoder.encode(inscriptionRequest.getPassword())); - return inscriptionRepo.save(inscriptionRequest); - } - - public InscriptionRequest getById(long id){ - return inscriptionRepo.findById(id); - } - - public Iterable getAll(){ - return inscriptionRepo.findAll(); - } - - public boolean modifyState(long id, RequestState requestState) { - InscriptionRequest inscrRequest = getById(id); - - if (inscrRequest == null) - return false; - - // if th state is the same we don't send an email - if (requestState == inscrRequest.getState()) - return false; - - /** todo send an email to tell the poster of the inscrRequest (inscrRequest.getEmail()) - * to notify them that the state of their request changed - * FooEmailFormat toSend = (String.format("Your request state changed from %s to %s"), - * inscrRequest.getState(), requestState) - * FooEmailSender.send(toSend, inscrRequest.getEmail()) - */ - - - //saves the user from the request if accepted - if (requestState == RequestState.Accepted) - { - if (curriculumRepo.findById(inscrRequest.getCurriculumId()) == null) - return false; - - User userFromRequest = new User( - inscrRequest.getLastName(), - inscrRequest.getFirstName(), - inscrRequest.getEmail(), - inscrRequest.getAddress(), - inscrRequest.getCountry(), - inscrRequest.getBirthDate(), - inscrRequest.getProfilePicture(), - inscrRequest.getPassword() - ); - - userRepo.save(userFromRequest); - userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()))); - } - inscrRequest.setState(requestState); - save(inscrRequest); - return true; - } - - public void delete(InscriptionRequest toDelete) { - inscriptionRepo.delete(toDelete); - } -} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java index 44e53a7..1c9b944 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java @@ -1,7 +1,7 @@ package ovh.herisson.Clyde.Services; import ovh.herisson.Clyde.Tables.Course; -import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.User; import java.util.ArrayList; @@ -87,7 +87,9 @@ public class ProtectionService { toReturn.put("curriculum", inscriptionRequest.getCurriculumId()); toReturn.put("state", inscriptionRequest.getState()); toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture()); - + toReturn.put("identityCard", inscriptionRequest.getIdentityCard()); + toReturn.put("submissionDate", inscriptionRequest.getSubmissionDate()); + toReturn.put("equivalenceState", inscriptionRequest.getEquivalenceState()); return toReturn; } 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..8b446df 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,52 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; +import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; -import ovh.herisson.Clyde.Tables.Curriculum; -import ovh.herisson.Clyde.Tables.User; +import ovh.herisson.Clyde.Tables.*; + +import java.util.ArrayList; +import java.util.HashMap; @Service public class UserCurriculumService { private final UserCurriculumRepository userCurriculumRepository; + private final CurriculumRepository curriculumRepo; - public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) { + 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){ 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/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java index 3dadcec..5c39891 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -18,6 +18,6 @@ public enum Applications { UsersList, // InscriptionService authorization - Inscription, + Requests, StudentsList } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java index 18ce1be..e7a081b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java @@ -1,8 +1,7 @@ package ovh.herisson.Clyde.Tables; public enum FileType { - ProfilePicture, - - EducationCertificate + EducationCertificate, + JustificationDocument } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java new file mode 100644 index 0000000..75ee926 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java @@ -0,0 +1,83 @@ +package ovh.herisson.Clyde.Tables.Inscription; + + +import jakarta.persistence.*; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import ovh.herisson.Clyde.Tables.Course; +import ovh.herisson.Clyde.Tables.RequestState; +import ovh.herisson.Clyde.Tables.User; + +import java.util.Date; + +@Entity +public class ExemptionsRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @JoinColumn(name = "Users") + @ManyToOne(fetch = FetchType.EAGER) + private User user; + + @JoinColumn(name = "Course") + @ManyToOne(fetch = FetchType.EAGER) + private Course course; + private String justifDocument; + + private RequestState state; + + private Date date; + + public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state, Date date){ + this.user = user; + this.course = course; + this.justifDocument = justifDocument; + this.state = state; + this.date = date; + } + + + 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; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExternalCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExternalCurriculum.java new file mode 100644 index 0000000..893971b --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExternalCurriculum.java @@ -0,0 +1,114 @@ +package ovh.herisson.Clyde.Tables.Inscription; + + +import jakarta.persistence.*; +import ovh.herisson.Clyde.Tables.User; + +//This table stores a student's curriculum from another university +@Entity +public class ExternalCurriculum { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + //An external curriculum is first linked to an inscription request and when it is accepted and the user is created we link it to the user + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name="InscriptionRequest") + private InscriptionRequest inscriptionRequest; + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name="Users") + private User user; + + private String school; + + 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; + + public ExternalCurriculum(){} + + public ExternalCurriculum(InscriptionRequest ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl,User user){ + this.inscriptionRequest = ir; + this.school = school; + this.formation = formation; + this.completion = completion; + this.startYear = startYear; + this.endYear = endYear; + this.justifdocUrl = justifdocUrl; + this.user = user; + } + + public int getId() { + return id; + } + + public InscriptionRequest getInscriptionRequest() { + return inscriptionRequest; + } + + public void setInscriptionRequest(InscriptionRequest inscriptionRequest) { + this.inscriptionRequest = inscriptionRequest; + } + + public String getSchool() { + return school; + } + + public void setSchool(String school) { + this.school = school; + } + + 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 void setUser(User user) { + this.user = user; + } + + public User getUser() { + return user; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java similarity index 72% rename from backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java rename to backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java index 18e20d0..07c720f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java @@ -1,6 +1,8 @@ -package ovh.herisson.Clyde.Tables; +package ovh.herisson.Clyde.Tables.Inscription; import jakarta.persistence.*; +import ovh.herisson.Clyde.Tables.RequestState; + import java.util.Date; @@ -15,14 +17,16 @@ public class InscriptionRequest { private String email; private String country; private Date birthDate; - private Long curriculumId; private RequestState state; private String profilePicture; - private String password; + private String identityCard; + private Date submissionDate; + private RequestState equivalenceState; public InscriptionRequest(){} - public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password){ + + public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState){ this.lastName = lastName; this.firstName = firstName; this.address = address; @@ -33,6 +37,9 @@ public class InscriptionRequest { this.state = state; this.profilePicture = profilePicture; this.password = password; + this.identityCard = identityCard; + this.submissionDate = submissionDate; + this.equivalenceState = equivalenceState; } public int getId() { @@ -118,4 +125,28 @@ public class InscriptionRequest { public void setPassword(String password) { this.password = password; } + + public String getIdentityCard() { + return identityCard; + } + + public void setIdentityCard(String identityCard) { + this.identityCard = identityCard; + } + + public Date getSubmissionDate() { + return submissionDate; + } + + public void setSubmissionDate(Date submissionDate) { + this.submissionDate = submissionDate; + } + + public RequestState getEquivalenceState() { + return equivalenceState; + } + + public void setEquivalenceState(RequestState equivalenceState) { + this.equivalenceState = equivalenceState; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Minerval.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Minerval.java new file mode 100644 index 0000000..dac5799 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Minerval.java @@ -0,0 +1,64 @@ +package ovh.herisson.Clyde.Tables.Inscription; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Minerval { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private long studentRegNo; + private int paidAmount; + private int toPay; + + //If the academic year is 2023-2024 then 2023 will be stored here (we take the lowest year) + private int year; + public Minerval(){} + + public Minerval(long studentRegNo, int paidAmount, int toPay, int year){ + this.studentRegNo = studentRegNo; + this.paidAmount = paidAmount; + this.toPay = toPay; + this.year = year; + } + + public long getStudentRegNo() { + return studentRegNo; + } + + public void setStudentRegNo(long studentRegNo) { + this.studentRegNo = studentRegNo; + } + + public int getPaidAmount() { + return paidAmount; + } + + public void setPaidAmount(int paidAmount) { + this.paidAmount = paidAmount; + } + + public int getToPay() { + return toPay; + } + + public void setToPay(int toPay) { + this.toPay = toPay; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public long 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 new file mode 100644 index 0000000..48626e1 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java @@ -0,0 +1,84 @@ +package ovh.herisson.Clyde.Tables.Inscription; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +import java.util.Date; + +@Entity +public class Payment { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private long studentRegNo; + private String card; + private String client; + private Date expDate; + private int amount; + private Date date; + public Payment(){} + + public Payment(long studentRegNo, String card, String client, Date expDate, int amount, Date date){ + this.studentRegNo = studentRegNo; + this.card = card; + this.client = client; + this.expDate = expDate; + this.amount = amount; + this.date = date; + } + + public long getStudentRegNo() { + return studentRegNo; + } + + public void setStudentRegNo(long studentRegNo) { + this.studentRegNo = studentRegNo; + } + + public String getCard() { + return card; + } + + public void setCard(String card) { + this.card = card; + } + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public Date getExpDate() { + return expDate; + } + + public void setExpDate(Date expDate) { + this.expDate = expDate; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public long getId() { + return id; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ReInscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ReInscriptionRequest.java similarity index 91% rename from backend/src/main/java/ovh/herisson/Clyde/Tables/ReInscriptionRequest.java rename to backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ReInscriptionRequest.java index b96ed42..cafffe6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ReInscriptionRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ReInscriptionRequest.java @@ -1,8 +1,11 @@ -package ovh.herisson.Clyde.Tables; +package ovh.herisson.Clyde.Tables.Inscription; import jakarta.persistence.*; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; +import ovh.herisson.Clyde.Tables.Curriculum; +import ovh.herisson.Clyde.Tables.RequestState; +import ovh.herisson.Clyde.Tables.User; @Entity public class ReInscriptionRequest { 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 new file mode 100644 index 0000000..18ebee6 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java @@ -0,0 +1,88 @@ +package ovh.herisson.Clyde.Tables.Inscription; + +import jakarta.persistence.*; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import ovh.herisson.Clyde.Tables.RequestState; +import ovh.herisson.Clyde.Tables.User; + +import java.util.Date; + +@Entity +public class ScholarshipRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + @JoinColumn(name="Users") + @ManyToOne(fetch = FetchType.EAGER) + private User user; + private RequestState state; + private Date date; + private int amount; + private String taxDocUrl; + private String residencyDocUrl; + + public ScholarshipRequest(User user, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){ + this.user = user; + this.state = state; + this.amount = amount; + this.date = date; + this.taxDocUrl = taxDocUrl; + this.residencyDocUrl = residencyDocUrl; + } + + 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 int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public long getId() { + return id; + } + + public String getResidencyDocUrl() { + return residencyDocUrl; + } + + public void setResidencyDocUrl(String residencyDocUrl) { + this.residencyDocUrl = residencyDocUrl; + } + + public String getTaxDocUrl() { + return taxDocUrl; + } + + public void setTaxDocUrl(String taxDocUrl) { + this.taxDocUrl = taxDocUrl; + } +} 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 new file mode 100644 index 0000000..e7858c6 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UninscriptionRequest.java @@ -0,0 +1,67 @@ +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/RequestState.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java index d52f1c9..fd2eeb0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java @@ -3,5 +3,6 @@ package ovh.herisson.Clyde.Tables; public enum RequestState { Accepted, Refused, - Pending + Pending, + Unrequired } 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/Inscription.vue b/frontend/src/Apps/Inscription.vue deleted file mode 100644 index 95581ce..0000000 --- a/frontend/src/Apps/Inscription.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - diff --git a/frontend/src/Apps/Inscription/AboutRequest.vue b/frontend/src/Apps/Inscription/AboutRequest.vue new file mode 100644 index 0000000..15c72f5 --- /dev/null +++ b/frontend/src/Apps/Inscription/AboutRequest.vue @@ -0,0 +1,132 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/AboutStudent.vue b/frontend/src/Apps/Inscription/AboutStudent.vue new file mode 100644 index 0000000..03368c2 --- /dev/null +++ b/frontend/src/Apps/Inscription/AboutStudent.vue @@ -0,0 +1,192 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/CourseList.vue b/frontend/src/Apps/Inscription/CourseList.vue new file mode 100644 index 0000000..7442076 --- /dev/null +++ b/frontend/src/Apps/Inscription/CourseList.vue @@ -0,0 +1,139 @@ + + + + + + diff --git a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue new file mode 100644 index 0000000..a642840 --- /dev/null +++ b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue @@ -0,0 +1,87 @@ + + + + + + diff --git a/frontend/src/Apps/Inscription/ManageRequests.vue b/frontend/src/Apps/Inscription/ManageRequests.vue new file mode 100644 index 0000000..e45a1a5 --- /dev/null +++ b/frontend/src/Apps/Inscription/ManageRequests.vue @@ -0,0 +1,196 @@ + + + + + + + + + diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 82caa80..5b0a807 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -1,16 +1,16 @@ @@ -116,7 +166,7 @@ {{i18n("login.guest.alregister")}} -
+

{{i18n("login.guest.email")}}

@@ -129,23 +179,30 @@

{{i18n("login.guest.country")}}

-
+

{{i18n("profile.picture").toUpperCase()}}

+
+
+

{{i18n("profile.picture").toUpperCase()}}

+

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

+

+ 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. +

-
@@ -155,10 +212,69 @@ {{i18n("login.guest.alregister")}}
+
+
+ Carte d'identité : +
+ +
+
+

+ Vous avez séléctionné un cursus qui possède des prérequis veuillez ajouter vos formations antérieures + dans l'enseignement supérieur, votre dossier sera vérifié par un membre du service d'inscription. +

+ + +
+
+
+
+

Ecole

+ +
+
+

Formation

+ +
+
+

Cochez la case si vous n'avez terminé cette formation

+ +
+

En quelle année de la formation vous êtes vous arrété (exemple: 3ème) ?

+ +
+
+
+

Année de début

+ +
+
+

Année de fin

+ +
+
+ +
+
+
+
+
+
+ + +
+ +
+
+ +
+
+
+
diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 643cc7d..f0a7c2b 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -1,16 +1,22 @@