1
0
forked from PGL/Clyde

Fix and simplifie the post and get for externalCurriculum

This commit is contained in:
LeoMoulin 2024-04-10 23:09:38 +02:00
parent 0c04bed799
commit 706481ed1a
5 changed files with 56 additions and 8 deletions

View File

@ -118,4 +118,5 @@ public class CurriculumController {
curriculumServ.delete(toDelete);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -0,0 +1,44 @@
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.ExternalCurriculumRepository;
import ovh.herisson.Clyde.Repositories.InscriptionRepository;
import ovh.herisson.Clyde.Tables.ExternalCurriculum;
import ovh.herisson.Clyde.Tables.InscriptionRequest;
import ovh.herisson.Clyde.Tables.RequestState;
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 ExternalCurriculumController(ExternalCurriculumRepository ecr, InscriptionRepository inscriptionRepository) {
this.ecr = ecr;
this.inscriptionRepository = inscriptionRepository;
}
//everyone can post some externalcurriculums (the validity of the elements is assured by the inscription service)
@PostMapping("/externalcurriculum")
public ResponseEntity<ExternalCurriculum> postExternalCurriculum(@RequestBody Map<String, Object> 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"), RequestState.Pending);
return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK);
}
@GetMapping("/externalcurriculum/{inscReqId}")
public ResponseEntity<ArrayList<ExternalCurriculum>> getExternalCurrListByInscrReq(@PathVariable long inscReqId){
InscriptionRequest ir = inscriptionRepository.findById(inscReqId);
ArrayList<ExternalCurriculum> toReturn = ecr.getExternalCurriculumByInscriptionRequest(ir);
return new ResponseEntity<>(toReturn, HttpStatus.OK);
}
}

View File

@ -8,5 +8,5 @@ import ovh.herisson.Clyde.Tables.User;
import java.util.ArrayList;
public interface ExternalCurriculumRepository extends CrudRepository<ExternalCurriculum, Long> {
ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequestId(Long id);
ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequest(InscriptionRequest ir);
}

View File

@ -1,14 +1,16 @@
<script setup>
import i18n from "@/i18n.js"
import {getUser} from '../rest/Users.js'
import {getcurriculum, getExternalCurriculumListByInscrReq, getSomeonesCurriculumList} from "@/rest/curriculum.js";
import {getcurriculum,getSomeonesCurriculumList} from "@/rest/curriculum.js";
import {getRegisters} from "@/rest/ServiceInscription.js";
import {get} from "jsdom/lib/jsdom/named-properties-tracker.js";
import {getExternalCurriculumByInscrReq} from "@/rest/externalCurriculum.js";
const props = defineProps(['target']);
let request = await getRegisters(props.target);
const cursus = await getcurriculum(request.curriculum);
const externalCurriculum = await getExternalCurriculumListByInscrReq(request.id)
const externalCurriculum = await getExternalCurriculumByInscrReq(request.id)
console.log(externalCurriculum)
function getPP(){
if(request.profilePictureUrl === null){

View File

@ -1,4 +1,5 @@
import {restGet, restPost} from "@/rest/restConsumer.js";
import {parseInteger} from "jsdom/lib/jsdom/living/helpers/strings.js";
export async function createExternalCurriculum(inscriptionRequestId,school, formation, completion, startYear, endYear, justifdocUrl){
return restPost("/externalcurriculum", {
@ -6,12 +7,12 @@ export async function createExternalCurriculum(inscriptionRequestId,school, form
school:school,
formation :formation,
completion : completion,
startYear : startYear,
endYear: endYear,
startYear : parseInteger(startYear),
endYear: parseInteger(endYear),
justifdocUrl : justifdocUrl
})
}
export async function getExternalCurriculumListByInscrReq(inscriptionRequestId){
return restGet("/externalCurriculum/"+parseInt(inscriptionRequestId))
}
export async function getExternalCurriculumByInscrReq(inscrReqId){
return restGet("/externalcurriculum/"+inscrReqId);
}