Compare commits

..

No commits in common. "706481ed1af157d17fd4a738f95fbc2fee089558" and "9d0b3da9d31cbe6102a85e348947cb973336b366" have entirely different histories.

9 changed files with 70 additions and 78 deletions

View File

@ -119,4 +119,25 @@ public class CurriculumController {
return new ResponseEntity<>(HttpStatus.OK); 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

@ -1,44 +0,0 @@
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; import java.util.ArrayList;
public interface ExternalCurriculumRepository extends CrudRepository<ExternalCurriculum, Long> { public interface ExternalCurriculumRepository extends CrudRepository<ExternalCurriculum, Long> {
ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequest(InscriptionRequest ir); ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequestId(Long id);
} }

View File

@ -49,4 +49,28 @@ 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,9 +10,7 @@ public class ExternalCurriculum {
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private int id; private int id;
@ManyToOne(fetch = FetchType.EAGER) private Long inscriptionRequestId;
@JoinColumn(name="InscriptionRequest")
private InscriptionRequest inscriptionRequest;
private String school; private String school;
@ -30,8 +28,8 @@ public class ExternalCurriculum {
public ExternalCurriculum(){} public ExternalCurriculum(){}
public ExternalCurriculum(InscriptionRequest ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){ public ExternalCurriculum(Long ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){
this.inscriptionRequest = ir; this.inscriptionRequestId = ir;
this.school = school; this.school = school;
this.formation = formation; this.formation = formation;
this.completion = completion; this.completion = completion;
@ -45,12 +43,12 @@ public class ExternalCurriculum {
return id; return id;
} }
public InscriptionRequest getInscriptionRequest() { public Long getInscriptionRequestId() {
return inscriptionRequest; return inscriptionRequestId;
} }
public void setInscriptionRequest(InscriptionRequest inscriptionRequest) { public void setInscriptionRequest(Long inscriptionRequestId) {
this.inscriptionRequest = inscriptionRequest; this.inscriptionRequestId = inscriptionRequestId;
} }
public String getSchool() { public String getSchool() {

View File

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

View File

@ -2,11 +2,10 @@
import {reactive, ref } from 'vue' import {reactive, ref } from 'vue'
import i18n from '@/i18n.js' import i18n from '@/i18n.js'
import {login, register, disconnect, isLogged} from '@/rest/Users.js' import {login, register, disconnect, isLogged} from '@/rest/Users.js'
import {getAllCurriculums, getcurriculum} from '@/rest/curriculum.js' import {createExternalCurriculum, getAllCurriculums, getcurriculum} from '@/rest/curriculum.js'
import { uploadProfilePicture } from '@/rest/uploads.js' import { uploadProfilePicture } from '@/rest/uploads.js'
import {toast} from 'vue3-toastify' import {toast} from 'vue3-toastify'
import 'vue3-toastify/dist/index.css'; import 'vue3-toastify/dist/index.css';
import {createExternalCurriculum} from "@/rest/externalCurriculum.js";
const loginPage= ref(true) const loginPage= ref(true)
const page = ref(0) const page = ref(0)

View File

@ -53,4 +53,18 @@ export async function getSomeonesCurriculumList(user){
return restGet("/onescurriculum/"+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

@ -1,18 +0,0 @@
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);
}