Compare commits

...

2 Commits

Author SHA1 Message Date
706481ed1a Fix and simplifie the post and get for externalCurriculum 2024-04-10 23:09:38 +02:00
0c04bed799 this is a test dw 2024-04-10 22:00:08 +02:00
9 changed files with 78 additions and 70 deletions

View File

@ -119,25 +119,4 @@ public class CurriculumController {
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/externalcurriculum/{inscriptionRequestId}")
public ResponseEntity<Map<String,Object>> 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<String,Object> 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<ExternalCurriculum> postExternalCurriculum(@RequestBody ExternalCurriculum ec){
ec.setState(RequestState.Pending);
return new ResponseEntity<>(ecr.save(ec), 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

@ -49,28 +49,4 @@ public class UserCurriculumService {
}
public HashMap<String,Object> findAllExternalCurriculumByInscriptionRequestId(Long id) {
ArrayList<ExternalCurriculum> list = externalCurriculumRepo.getExternalCurriculumByInscriptionRequestId(id);
ArrayList<HashMap<String, Object>> externalCurriculumList = new ArrayList<HashMap<String, Object>>();
for (int i = 0; i < list.size(); i++) {
HashMap<String, Object> 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<String, Object> toReturn = new HashMap<String, Object>();
toReturn.put("externalCurriculumList", externalCurriculumList);
return toReturn;
}
}

View File

@ -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() {

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

@ -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)

View File

@ -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))
}

View File

@ -0,0 +1,18 @@
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", {
inscriptionRequestId: inscriptionRequestId,
school:school,
formation :formation,
completion : completion,
startYear : parseInteger(startYear),
endYear: parseInteger(endYear),
justifdocUrl : justifdocUrl
})
}
export async function getExternalCurriculumByInscrReq(inscrReqId){
return restGet("/externalcurriculum/"+inscrReqId);
}