From 0c04bed7990d4994b35dc82b766536b22543239a Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Wed, 10 Apr 2024 22:00:08 +0200 Subject: [PATCH] this is a test dw --- .../Clyde/EndPoints/CurriculumController.java | 22 ----------------- .../Clyde/Services/UserCurriculumService.java | 24 ------------------- .../Clyde/Tables/ExternalCurriculum.java | 16 +++++++------ frontend/src/Apps/Login.vue | 3 ++- frontend/src/rest/curriculum.js | 14 ----------- frontend/src/rest/externalCurriculum.js | 17 +++++++++++++ 6 files changed, 28 insertions(+), 68 deletions(-) create mode 100644 frontend/src/rest/externalCurriculum.js 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 5f917e4..88a339b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -118,26 +118,4 @@ public class CurriculumController { curriculumServ.delete(toDelete); return new ResponseEntity<>(HttpStatus.OK); } - - @GetMapping("/externalcurriculum/{inscriptionRequestId}") - public ResponseEntity> getInscriptionRequestExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable long inscriptionRequestId){ - if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.Teacher},token)) - return new UnauthorizedResponse<>(null); - - HashMap toReturn = userCurriculumServ.findAllExternalCurriculumByInscriptionRequestId(inscriptionRequestId); - - if (toReturn == null) - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - - return new ResponseEntity<>(toReturn,HttpStatus.OK); - } - - - //Note : everyone can post some externalcurriculums (the validity of the elements is assured by the inscription service) - @PostMapping("/externalcurriculum") - public ResponseEntity postExternalCurriculum(@RequestBody ExternalCurriculum ec){ - ec.setState(RequestState.Pending); - return new ResponseEntity<>(ecr.save(ec), HttpStatus.OK); - } - } 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 7c65e2e..544307b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java @@ -49,28 +49,4 @@ public class UserCurriculumService { } - public HashMap findAllExternalCurriculumByInscriptionRequestId(Long id) { - ArrayList list = externalCurriculumRepo.getExternalCurriculumByInscriptionRequestId(id); - - ArrayList> externalCurriculumList = new ArrayList>(); - - for (int i = 0; i < list.size(); i++) { - HashMap element = new HashMap<>(); - element.put("id", list.get(0).getId()); - element.put("inscriptionRequestId", list.get(0).getInscriptionRequestId()); - element.put("school", list.get(0).getSchool()); - element.put("formation", list.get(0).getFormation()); - element.put("completion", list.get(0).getCompletion()); - element.put("startYear", list.get(0).getStartYear()); - element.put("endYear", list.get(0).getEndYear()); - element.put("justifDocUrl", list.get(0).getJustifdocUrl()); - element.put("state", list.get(0).getState()); - externalCurriculumList.add(element); - } - - HashMap toReturn = new HashMap(); - toReturn.put("externalCurriculumList", externalCurriculumList); - return toReturn; - } - } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java index 5193f22..534a108 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java @@ -10,7 +10,9 @@ public class ExternalCurriculum { @GeneratedValue(strategy = GenerationType.AUTO) private int id; - private Long inscriptionRequestId; + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name="InscriptionRequest") + private InscriptionRequest inscriptionRequest; private String school; @@ -28,8 +30,8 @@ public class ExternalCurriculum { public ExternalCurriculum(){} - public ExternalCurriculum(Long ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){ - this.inscriptionRequestId = ir; + public ExternalCurriculum(InscriptionRequest ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){ + this.inscriptionRequest = ir; this.school = school; this.formation = formation; this.completion = completion; @@ -43,12 +45,12 @@ public class ExternalCurriculum { return id; } - public Long getInscriptionRequestId() { - return inscriptionRequestId; + public InscriptionRequest getInscriptionRequest() { + return inscriptionRequest; } - public void setInscriptionRequest(Long inscriptionRequestId) { - this.inscriptionRequestId = inscriptionRequestId; + public void setInscriptionRequest(InscriptionRequest inscriptionRequest) { + this.inscriptionRequest = inscriptionRequest; } public String getSchool() { diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 5bbf682..af8f89a 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -2,10 +2,11 @@ import {reactive, ref } from 'vue' import i18n from '@/i18n.js' import {login, register, disconnect, isLogged} from '@/rest/Users.js' - import {createExternalCurriculum, getAllCurriculums, getcurriculum} from '@/rest/curriculum.js' + import {getAllCurriculums, getcurriculum} from '@/rest/curriculum.js' import { uploadProfilePicture } from '@/rest/uploads.js' import {toast} from 'vue3-toastify' import 'vue3-toastify/dist/index.css'; + import {createExternalCurriculum} from "@/rest/externalCurriculum.js"; const loginPage= ref(true) const page = ref(0) diff --git a/frontend/src/rest/curriculum.js b/frontend/src/rest/curriculum.js index d468dcf..a34328c 100644 --- a/frontend/src/rest/curriculum.js +++ b/frontend/src/rest/curriculum.js @@ -53,18 +53,4 @@ export async function getSomeonesCurriculumList(user){ return restGet("/onescurriculum/"+user) } -export async function createExternalCurriculum(inscriptionRequestId,school, formation, completion, startYear, endYear, justifdocUrl){ - return restPost("/externalcurriculum", { - inscriptionRequestId: inscriptionRequestId, - school:school, - formation :formation, - completion : completion, - startYear : startYear, - endYear: endYear, - justifdocUrl : justifdocUrl - }) -} -export async function getExternalCurriculumListByInscrReq(inscriptionRequestId){ - return restGet("/externalCurriculum/"+parseInt(inscriptionRequestId)) -} diff --git a/frontend/src/rest/externalCurriculum.js b/frontend/src/rest/externalCurriculum.js new file mode 100644 index 0000000..cda2cf1 --- /dev/null +++ b/frontend/src/rest/externalCurriculum.js @@ -0,0 +1,17 @@ +import {restGet, restPost} from "@/rest/restConsumer.js"; + +export async function createExternalCurriculum(inscriptionRequestId,school, formation, completion, startYear, endYear, justifdocUrl){ + return restPost("/externalcurriculum", { + inscriptionRequestId: inscriptionRequestId, + school:school, + formation :formation, + completion : completion, + startYear : startYear, + endYear: endYear, + justifdocUrl : justifdocUrl + }) +} + +export async function getExternalCurriculumListByInscrReq(inscriptionRequestId){ + return restGet("/externalCurriculum/"+parseInt(inscriptionRequestId)) +} \ No newline at end of file