Leo/InscriptionDesEtudiant #161

Merged
LeoMoulin merged 10 commits from Leo/InscriptionDesEtudiant into master 2024-04-18 21:43:48 +02:00
8 changed files with 162 additions and 98 deletions
Showing only changes of commit c434b28fe3 - Show all commits

View File

@ -6,16 +6,15 @@ 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.Inscription.UnregisterRequestRepository;
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 ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
import javax.swing.text.html.parser.Entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
@ -28,15 +27,16 @@ public class RequestsController {
public final ScholarshipRequestRepository srr;
public final UserRepository userRepository;
public final AuthenticatorService authServ;
public final UninscriptionRequestRepository uninscriptionRequestRepository;
public final UnregisterRequestRepository unregisterRequestRepository;
public final CourseRepository courseRepository;
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UninscriptionRequestRepository uninscriptionRequestRepository, CourseRepository courseRepository) {
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository) {
this.err = err;
this.srr = srr;
this.userRepository = userRepository;
this.authServ = authServ;
this.uninscriptionRequestRepository = uninscriptionRequestRepository;
this.unregisterRequestRepository = unregisterRequestRepository;
this.courseRepository = courseRepository;
}
@ -88,11 +88,11 @@ public class RequestsController {
return new ResponseEntity<>(toReturn, HttpStatus.OK);
}
@PostMapping(value = "/uninscriptionreq")
@PostMapping(value = "/unregister")
public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> 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);
UnregisterRequest ur = new UnregisterRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u.getRegNo(), u.getFirstName(), u.getLastName(), u.getEmail());
unregisterRequestRepository.save(ur);
return new ResponseEntity<>(HttpStatus.OK);
}
@ -116,4 +116,11 @@ public class RequestsController {
ScholarshipRequest toReturn = srr.findById(id);
return new ResponseEntity<>(toReturn, HttpStatus.OK);
}
@GetMapping(value = "/unregister")
public ResponseEntity<ArrayList<UnregisterRequest>> getAllUnregReq(){
ArrayList<UnregisterRequest> toReturn = new ArrayList<>();
unregisterRequestRepository.findAll().forEach(toReturn::add);
return new ResponseEntity<>(toReturn, HttpStatus.OK);
}
}

View File

@ -6,13 +6,11 @@ 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.Repositories.Inscription.UnregisterRequestRepository;
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 ovh.herisson.Clyde.Tables.Inscription.*;
import java.util.ArrayList;
import java.util.Arrays;
@ -40,7 +38,8 @@ public class MockController {
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){
public final UnregisterRequestRepository uninscriptionRequestRepository;
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository, UnregisterRequestRepository unregisterRequestRepository){
this.tokenRepo = tokenRepo;
this.userRepo = userRepo;
this.tokenService = tokenService;
@ -52,6 +51,7 @@ public class MockController {
this.ucr = ucr;
this.minervalRepository = minervalRepository;
this.scholarshipRequestRepository = scholarshipRequestRepository;
this.uninscriptionRequestRepository = unregisterRequestRepository;
}
/** Saves an example of each user type by :
@ -128,6 +128,9 @@ public class MockController {
inscriptionService.save(inscriptionRequest);
UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail());
uninscriptionRequestRepository.save(unregisterRequest);
ExternalCurriculum externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null);
externalCurriculumRepository.save(externalCurriculum);
}

View File

@ -1,7 +0,0 @@
package ovh.herisson.Clyde.Repositories.Inscription;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest;
public interface UninscriptionRequestRepository extends CrudRepository<UninscriptionRequest, Long> {
}

View File

@ -0,0 +1,8 @@
package ovh.herisson.Clyde.Repositories.Inscription;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
public interface UnregisterRequestRepository extends CrudRepository<UnregisterRequest, Long> {
}

View File

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

View File

@ -0,0 +1,99 @@
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 UnregisterRequest {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private RequestState state;
private String reason;
private Date date;
//We store these informations again so if the user is deleted we still have the informations for history
private long regNo;
private String firstName;
private String lastName;
private String email;
public UnregisterRequest(RequestState state, String reason, Date date, long regNo, String firstName, String lastName, String email){
this.state = state;
this.reason = reason;
this.date = date;
this.regNo = regNo;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public UnregisterRequest(){}
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 void setDate(Date date) {
this.date = date;
}
public Date getDate() {
return date;
}
public String getEmail() {
return email;
}
public String getLastName() {
return lastName;
}
public String getFirstName() {
return firstName;
}
public void setEmail(String email) {
this.email = email;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setRegNo(long regNo) {
this.regNo = regNo;
}
public long getRegNo() {
return regNo;
}
}

View File

@ -3,7 +3,7 @@
import {ref} from 'vue'
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
import AboutRequest from "@/Apps/Inscription/AboutRequest.vue";
import {getAllExemptionsRequest, getAllScholarShipsRequest} from "@/rest/requests.js";
import {getAllExemptionsRequest, getAllScholarShipsRequest, getAllUnregisters} from "@/rest/requests.js";
import AboutScholarship from "@/Apps/Inscription/AboutScholarship.vue";
const requests = ref(await getAllRegisters());
@ -22,14 +22,18 @@
}
async function loadRequests(){
if (requestType.value === "inscription"){
requests.value = await getAllRegisters();
}
if (requestType.value === "scholarship"){
requests.value = await getAllScholarShipsRequest();
}
if(requestType.value === "exemption"){
requests.value = await getAllExemptionsRequest();
switch (requestType.value){
case "inscription":
requests.value = await getAllRegisters();
break;
case "scholarship":
requests.value = await getAllScholarShipsRequest();
break;
case "exemption":
requests.value = await getAllExemptionsRequest();
break;
case "unregister":
requests.value = await getAllUnregisters();
}
}
</script>
@ -47,6 +51,7 @@
<option>inscription</option>
<option>scholarship</option>
<option>exemption</option>
<option>unregister</option>
</select>
<span style="margin-left: 5%">
Filter :
@ -90,6 +95,14 @@
<div class="reqState">{{item.state}}</div>
<div class="infos"><button>More infos</button></div>
</div>
<div class="container" v-if="requestType === 'unregister'" style="grid-template-columns:17% 15% 12% 15%;grid-template-areas:'date reqState regno studentfirstname studentlastname infos';">
<div class="date" v-if="item.date != undefined">{{item.date.slice(0,10)}}</div>
<div class="studentfirstname">{{item.firstName}}</div>
<div class="studentlastname">{{item.lastName}}</div>
<div class="regno">id : {{item.regNo}}</div>
<div class="reqState">{{item.state}}</div>
<div class="infos"><button>More infos</button></div>
</div>
</div>
</div>
</div>
@ -158,6 +171,10 @@
align-self:center;
}
.regno{
grid-area: regno;
align-self: center;
}
.state{
grid-area:state;
margin-left:40px;

View File

@ -21,7 +21,7 @@ export async function editEquivalenceState(id, newstate){
}
export async function addUninscReq(userId, reason){
return restPost("/uninscriptionreq", {"userId" : userId, "reason" : reason})
return restPost("/unregister", {"userId" : userId, "reason" : reason})
}
export async function editScholarshipReq(body){
@ -31,3 +31,7 @@ export async function editScholarshipReq(body){
export async function getScholarshipReqById(id){
return restGet("/scholarshipreq/"+id)
}
export async function getAllUnregisters(){
return restGet("/unregister")
}