Compare commits
6 Commits
master
...
Leo/Backen
Author | SHA1 | Date | |
---|---|---|---|
c0890ac76a | |||
49b99e14c9 | |||
9328601d2d | |||
79f4b84b70 | |||
0c73f6f44d | |||
a1bdae9e83 |
@ -18,3 +18,15 @@ jobs:
|
||||
- uses: gradle/gradle-build-action@v3
|
||||
- name: building
|
||||
run: ./gradlew backend:build -x test
|
||||
# Test-backend:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4
|
||||
# - uses: actions/setup-java@v3
|
||||
# with:
|
||||
# java-version: '21'
|
||||
# distribution: 'temurin'
|
||||
# - run: curl -fsSL https://get.docker.com | sh
|
||||
# - uses: gradle/gradle-build-action@v3
|
||||
# - name: testing
|
||||
# run: ./gradlew backend:test
|
||||
|
@ -39,6 +39,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
- uses: gradle/gradle-build-action@v3
|
||||
- name: building
|
||||
run: ./gradlew backend:build -x test
|
||||
- name: pushing to the server
|
||||
run: |
|
||||
echo "${{ secrets.SSH_KEY }}" > key
|
||||
@ -46,5 +53,5 @@ jobs:
|
||||
scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/
|
||||
- name: restarting the backend
|
||||
run: |
|
||||
ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd api/ && sed -i compose.yaml -e "s/8080:8080/4001:8080/" -e "s/8000:8080/4000:8080/" && docker-compose up --force-recreate --build -d'
|
||||
ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d -u $(id -u clyde):$(id -g clyde) -v /var/run/postgresql:/var/run/postgresql --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f'
|
||||
- run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api"
|
||||
|
29
README.md
29
README.md
@ -9,33 +9,10 @@ Projet du groupe 01:
|
||||
- William Karpinski: Extension gestion des horaires
|
||||
- Léo Moulin: Extension inscription des étudiants
|
||||
|
||||
## Running
|
||||
|
||||
Le projet peut être lancé grace à docker compose.
|
||||
|
||||
```sh
|
||||
$ docker compose up
|
||||
```
|
||||
|
||||
Dans le cas ou vous modifiers des fichiers, pour éviter que les images de docker soient recrées avec les changement
|
||||
|
||||
```sh
|
||||
$ docker compose up --force-recreate --build
|
||||
```
|
||||
|
||||
## Dévelopement
|
||||
|
||||
Dans le cas ou vous êtes dans une phase de développement, il est plus simple d'utiliser gradle pour lancer le backend et frontend dans un mode de développement.
|
||||
**Attention**: Ce mode n'est pas fait pour être utilisé en production!
|
||||
|
||||
```sh
|
||||
$ ./gradlew run --parallel
|
||||
```
|
||||
$ ./gradlew backend:run frontend:run --parallel
|
||||
```
|
||||
|
||||
permet de lancer le frontend sur [http://localhost:5173](http://localhost:5173) ansi que le frontend sur [http://localhost:8080](http://localhost:8080)
|
||||
|
||||
Ceci requière également docker pour lancer une instance de postgresql pris en charge par spring.
|
||||
|
||||
Il est possible de se passer entièrement de docker en supprimant la dépendance dans le fichier `backend/build.gradle.kts`: ~~`developmentOnly("org.springframework.boot:spring-boot-docker-compose")`~~
|
||||
Il est alors nécéssaire d'avoir une instance de postgresql tournant sur `localhost:5432` avec une table `clyde`, utilisateur: `devel` et password: `devel`
|
||||
(cette configuration peut également être changée dans le fichier resources/application.properties de spring)
|
||||
|
||||
|
@ -1,15 +1,6 @@
|
||||
## Building phase
|
||||
FROM gradle:jdk21-alpine AS BUILD
|
||||
WORKDIR /backend
|
||||
|
||||
COPY . .
|
||||
RUN gradle build -x test
|
||||
|
||||
## Running Phase
|
||||
FROM eclipse-temurin:21-jdk-alpine
|
||||
WORKDIR /backend
|
||||
VOLUME /tmp
|
||||
VOLUME /cdn
|
||||
# ENV SPRING_PROFILES_ACTIVE=prod
|
||||
COPY --from=BUILD /backend/build/libs/Clyde-0.0.1-SNAPSHOT.jar /backend/app.jar
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java", "-jar", "/backend/app.jar"]
|
||||
ENV SPRING_PROFILES_ACTIVE=prod
|
||||
COPY build/libs/backend-0.0.1-SNAPSHOT.jar /app.jar
|
||||
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
||||
|
@ -16,8 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
annotationProcessor("org.projectlombok:lombok")
|
||||
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
implementation("org.springframework.boot:spring-boot-starter-mail")
|
||||
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.6/userguide/multi_project_builds.html in the Gradle documentation.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
// Apply the foojay-resolver plugin to allow automatic download of JDKs
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
||||
}
|
||||
|
||||
rootProject.name = "Clyde"
|
@ -1,34 +0,0 @@
|
||||
package ovh.herisson.Clyde.DTO.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file DiscussionDTO.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* File to format a discussion using messageDTO
|
||||
******************************************************/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Discussion;
|
||||
import ovh.herisson.Clyde.DTO.Msg.MessagesDTO;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DiscussionDTO {
|
||||
private long id;
|
||||
private String name;
|
||||
private List<User> members;
|
||||
private List<MessagesDTO> msgs;
|
||||
|
||||
public static DiscussionDTO construct(Discussion d, User u){
|
||||
List<MessagesDTO> msgsdto = new ArrayList<>();
|
||||
d.getMsgs().forEach(x -> msgsdto.add(MessagesDTO.construct(x, u)));
|
||||
return new DiscussionDTO(d.getId(), d.getName(), d.getMembers(), msgsdto);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package ovh.herisson.Clyde.DTO.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file MessagesDTO.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* File to Format the response adding the sender field
|
||||
******************************************************/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Message;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MessagesDTO {
|
||||
private long id;
|
||||
private String content;
|
||||
private User author;
|
||||
private boolean sender;
|
||||
private Date created;
|
||||
//TODO: Attachment
|
||||
|
||||
public static MessagesDTO construct(Message m, User user){
|
||||
boolean sender = false;
|
||||
if(m.getAuthor().equals(user))
|
||||
sender = true;
|
||||
return new MessagesDTO(m.getId(), m.getContent(), m.getAuthor(), sender, m.getCreated());
|
||||
}
|
||||
}
|
@ -47,7 +47,6 @@ public class ApplicationsController {
|
||||
|
||||
//if unAuthed
|
||||
authorizedApps.add(Applications.Login);
|
||||
authorizedApps.add(Applications.Schedule);
|
||||
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null)
|
||||
@ -61,23 +60,16 @@ public class ApplicationsController {
|
||||
authorizedApps.add(Applications.Rdv);
|
||||
}
|
||||
|
||||
if(!authServ.isNotIn(new Role[]{Role.Teacher,Role.Admin},token))
|
||||
authorizedApps.add(Applications.ManageOwnedLessons);
|
||||
//if Teacher or Secretary or Admin add ManageCourses App
|
||||
if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Secretary,Role.Admin},token))
|
||||
authorizedApps.add(Applications.ManageCourses);
|
||||
|
||||
if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin, Role.Teacher},token)){
|
||||
authorizedApps.add(Applications.Requests);
|
||||
if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token)){
|
||||
authorizedApps.add(Applications.Inscription);
|
||||
authorizedApps.add(Applications.StudentsList);}
|
||||
|
||||
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){
|
||||
authorizedApps.add(Applications.UsersList);
|
||||
authorizedApps.add(Applications.ManageSchedules);
|
||||
authorizedApps.add(Applications.LessonRequests);}
|
||||
|
||||
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.InscriptionService},token)){
|
||||
authorizedApps.add(Applications.Payments);}
|
||||
authorizedApps.add(Applications.UsersList);}
|
||||
return authorizedApps;
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,15 @@ 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.CurriculumCourseRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.*;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.CourseService;
|
||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Services.TeacherCourseService;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.UserCurriculum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@ -26,20 +24,10 @@ public class CourseController {
|
||||
|
||||
private final AuthenticatorService authServ;
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final UserCurriculumService userCurriculumService;
|
||||
|
||||
private final CurriculumCourseRepository curriculumCourseRepository;
|
||||
private final CurriculumCourseService curriculumCourseService;
|
||||
public CourseController(CourseService courseServ, TeacherCourseService teacherCourseServ, AuthenticatorService authServ, UserService userService, UserCurriculumService userCurriculumService, CurriculumCourseRepository curriculumCourseRepository, CurriculumCourseService curriculumCourseService) {
|
||||
public CourseController(CourseService courseServ, TeacherCourseService teacherCourseServ, AuthenticatorService authServ) {
|
||||
this.courseServ = courseServ;
|
||||
this.teacherCourseServ = teacherCourseServ;
|
||||
this.authServ = authServ;
|
||||
this.userService = userService;
|
||||
this.userCurriculumService = userCurriculumService;
|
||||
this.curriculumCourseRepository = curriculumCourseRepository;
|
||||
this.curriculumCourseService = curriculumCourseService;
|
||||
}
|
||||
|
||||
@GetMapping("/course/{id}")
|
||||
@ -86,8 +74,11 @@ public class CourseController {
|
||||
public ResponseEntity<Map<String ,Object>> postCourse(@RequestHeader("Authorization") String token,
|
||||
@RequestBody Course course)
|
||||
{
|
||||
System.out.println(course);
|
||||
System.out.println(token);
|
||||
if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Course createdCourse = courseServ.save(course);
|
||||
if (createdCourse == null)
|
||||
return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
|
||||
@ -144,29 +135,4 @@ public class CourseController {
|
||||
courseServ.delete(courseServ.findById(id));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
//Get all the courses followed by an user
|
||||
@GetMapping("/usercourses")
|
||||
public ResponseEntity<List<Course>> getAllUserCourses(@RequestHeader("Authorization") String token){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
|
||||
//We get all the actual curriculums of the user
|
||||
List<UserCurriculum> userCurricula = userCurriculumService.findByStudentAndActual(u, true);
|
||||
List<Course> toReturn = new ArrayList<>();
|
||||
|
||||
//We iterate through all the curriculums and we extract the courses
|
||||
for (int i = 0; i < userCurricula.size(); i++){
|
||||
curriculumCourseRepository.findCoursesByCurriculum(userCurricula.get(i).getCurriculum()).forEach((item) -> {
|
||||
//We need this to eliminate clones because a course can belong to several curriculums
|
||||
if(!toReturn.contains(item)){
|
||||
toReturn.add(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,13 +4,11 @@ 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.Inscription.ExternalCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.*;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@ -23,18 +21,12 @@ public class CurriculumController {
|
||||
|
||||
private final UserCurriculumService userCurriculumServ;
|
||||
private final CurriculumCourseService curriculumCourseServ;
|
||||
private final InscriptionRepository ir;
|
||||
private final UserService userServ;
|
||||
|
||||
private final ExternalCurriculumRepository ecr;
|
||||
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, InscriptionRepository ir, UserService userServ, ExternalCurriculumRepository ecr){
|
||||
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){
|
||||
this.curriculumServ = curriculumServ;
|
||||
this.authServ = authServ;
|
||||
this.userCurriculumServ = userCurriculumServ;
|
||||
this.curriculumCourseServ = curriculumCourseServ;
|
||||
this.ir = ir;
|
||||
this.userServ = userServ;
|
||||
this.ecr = ecr;
|
||||
}
|
||||
|
||||
@GetMapping("/curriculum/{id}")
|
||||
@ -60,22 +52,6 @@ public class CurriculumController {
|
||||
return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
//Return the list of all curicullums of an user
|
||||
@GetMapping("/onescurriculum/{userId}")
|
||||
public ResponseEntity<Map<String ,Object>> findOnesCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){
|
||||
if (authServ.getUserFromToken(token) == null)
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
User u = userServ.getUserById(Long.parseLong(userId));
|
||||
HashMap<String,Object> toReturn = userCurriculumServ.findAllCurriculumByStudent(u);
|
||||
|
||||
if (toReturn == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
|
||||
return new ResponseEntity<>(toReturn,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/curriculums")
|
||||
public ResponseEntity<Iterable<Map<String, Object>>> findAllIndDepth(){
|
||||
return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK);
|
||||
@ -118,5 +94,4 @@ public class CurriculumController {
|
||||
curriculumServ.delete(toDelete);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Inscription;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
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 final UserRepository userRepository;
|
||||
|
||||
public ExternalCurriculumController(ExternalCurriculumRepository ecr, InscriptionRepository inscriptionRepository, UserRepository userRepository) {
|
||||
this.ecr = ecr;
|
||||
this.inscriptionRepository = inscriptionRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
//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){
|
||||
//An external curriculum can either be linked to an User or to an InscriptionRequest
|
||||
InscriptionRequest ir = null;
|
||||
User user = null;
|
||||
if (externalCurrInfos.get("inscriptionRequestId") != null){
|
||||
ir = inscriptionRepository.findById((Integer) externalCurrInfos.get("inscriptionRequestId"));
|
||||
}else{
|
||||
user = userRepository.findById((Integer) externalCurrInfos.get("userRegNo"));
|
||||
}
|
||||
|
||||
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"), user);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@GetMapping("/externalcurriculumbyuser/{userId}")
|
||||
public ResponseEntity<ArrayList<ExternalCurriculum>> getExternalCurrByUser(@PathVariable long userId){
|
||||
User user = userRepository.findById(userId);
|
||||
|
||||
ArrayList<ExternalCurriculum> toReturn = ecr.getExternalCurriculumByUser(user);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Inscription;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.Minerval;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class MinervalController {
|
||||
private final AuthenticatorService authServ;
|
||||
private final MinervalRepository mr;
|
||||
|
||||
public MinervalController(AuthenticatorService authServ, MinervalRepository mr) {
|
||||
this.authServ = authServ;
|
||||
this.mr = mr;
|
||||
}
|
||||
|
||||
//A new minerval entry is posted when the inscription service accept a registration request
|
||||
@PostMapping("/minerval/{studentRegNo}")
|
||||
public ResponseEntity<Object> postMinerval(@RequestHeader("Authorization") String token, @PathVariable long studentRegNo){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Calendar c = new GregorianCalendar();
|
||||
|
||||
mr.save(new Minerval(studentRegNo, 0, 835, c.get(Calendar.YEAR)));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/minerval/{studentRegNo}")
|
||||
public ResponseEntity<Minerval> getCurrentMinervalbyRegNo(@PathVariable long studentRegNo){
|
||||
ArrayList<Minerval> mlist = mr.getMinervalsByStudentRegNoOrderByYearDesc(studentRegNo);
|
||||
|
||||
//The list is ordered by year in descending order then the index 0 contains the actual minerval (for this year)
|
||||
Minerval m = mlist.get(0);
|
||||
return new ResponseEntity<>(m, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/minerval")
|
||||
public ResponseEntity<Object> updateMinerval(@RequestBody Minerval updatedMinerval){
|
||||
Minerval minerval = mr.findById(updatedMinerval.getId());
|
||||
|
||||
minerval.setPaidAmount(updatedMinerval.getPaidAmount());
|
||||
minerval.setToPay(updatedMinerval.getToPay());
|
||||
mr.save(minerval);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Inscription;
|
||||
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.PaymentRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.Payment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class PaymentController {
|
||||
|
||||
private final PaymentRepository paymentRepository;
|
||||
|
||||
public PaymentController(PaymentRepository paymentRepository){
|
||||
this.paymentRepository = paymentRepository;
|
||||
}
|
||||
|
||||
//Post a payment record
|
||||
@PostMapping("/payment")
|
||||
public ResponseEntity<Object> postPayment(@RequestBody Payment payment){
|
||||
paymentRepository.save(payment);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
//Get all payment records of a student
|
||||
@GetMapping("/payment/{studentRegNo}")
|
||||
public ResponseEntity<ArrayList<Payment>> getPaymentsByUser(@PathVariable long studentRegNo){
|
||||
ArrayList<Payment> toReturn = paymentRepository.getPaymentsByStudentRegNo(studentRegNo);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/payment")
|
||||
public ResponseEntity<ArrayList<Payment>> getAllPayments(){
|
||||
ArrayList<Payment> toReturn = new ArrayList<Payment>();
|
||||
|
||||
|
||||
paymentRepository.findAll().forEach(toReturn::add);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,373 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Inscription;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.*;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.TokenService;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.Minerval;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class RequestsController {
|
||||
|
||||
public final TokenService tokenService;
|
||||
public final ExemptionsRequestRepository err;
|
||||
public final ScholarshipRequestRepository srr;
|
||||
public final UserRepository userRepository;
|
||||
public final AuthenticatorService authServ;
|
||||
public final UnregisterRequestRepository unregisterRequestRepository;
|
||||
public final CourseRepository courseRepository;
|
||||
public final UserService userService;
|
||||
public final UserCurriculumRepository userCurriculumRepository;
|
||||
public final CurriculumRepository curriculumRepository;
|
||||
public final MinervalRepository minervalRepository;
|
||||
public final ChangeCurriculumRequestRepository changeCurriculumRequestRepository;
|
||||
|
||||
public RequestsController(TokenService tokenService, ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, MinervalRepository minervalRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) {
|
||||
this.tokenService = tokenService;
|
||||
this.err = err;
|
||||
this.srr = srr;
|
||||
this.userRepository = userRepository;
|
||||
this.authServ = authServ;
|
||||
this.unregisterRequestRepository = unregisterRequestRepository;
|
||||
this.courseRepository = courseRepository;
|
||||
this.userService = userService;
|
||||
this.userCurriculumRepository = userCurriculumRepository;
|
||||
this.curriculumRepository = curriculumRepository;
|
||||
this.minervalRepository = minervalRepository;
|
||||
this.changeCurriculumRequestRepository = changeCurriculumRequestRepository;
|
||||
}
|
||||
|
||||
@PostMapping(value="/exemptionreq")
|
||||
public ResponseEntity<String> createExemptionReq(@RequestBody Map<String, Object> exemptionsRequestInfo){
|
||||
User user = userRepository.findById((Integer) exemptionsRequestInfo.get("userRegNo"));
|
||||
Course course = courseRepository.findById((Integer) exemptionsRequestInfo.get("courseId"));
|
||||
|
||||
ExemptionsRequest exemptionsRequest = new ExemptionsRequest(user, course, (String) exemptionsRequestInfo.get("justifDocument"), RequestState.Pending, new Date());
|
||||
|
||||
err.save(exemptionsRequest);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping(value="/scholarshipreq")
|
||||
public ResponseEntity<String> createScholarshipReq(@RequestBody Map<String, Object> scholarshipRequestInfo){
|
||||
User user = userRepository.findById((Integer)scholarshipRequestInfo.get("userId"));
|
||||
ScholarshipRequest toCreate = new ScholarshipRequest(user, RequestState.Pending, 0, new Date(), (String) scholarshipRequestInfo.get("taxDocUrl"), (String) scholarshipRequestInfo.get("residencyDocUrl"));
|
||||
|
||||
srr.save(toCreate);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
//Get all the exemptions Request
|
||||
@GetMapping(value = "/exemptionsreq")
|
||||
public ResponseEntity<ArrayList<ExemptionsRequest>> getAllExemptionsRequests(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService, Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<ExemptionsRequest> toReturn = new ArrayList<>();
|
||||
|
||||
err.findAll().forEach(toReturn::add);
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/exemptionsreq/{id}")
|
||||
public ResponseEntity<ExemptionsRequest> getExemptionRequestbyId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ExemptionsRequest exemptionsRequest = err.findById(id);
|
||||
|
||||
return new ResponseEntity<>(exemptionsRequest, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping(value = "/exemptionsreq/{id}/{newstate}")
|
||||
public ResponseEntity<String> changeExemptionReqState(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newstate){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ExemptionsRequest exemptionsRequest = err.findById(id);
|
||||
|
||||
if (exemptionsRequest.getState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
exemptionsRequest.setState(newstate);
|
||||
err.save(exemptionsRequest);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
//Get all the scholarships requests
|
||||
@GetMapping(value = "/scholarshipreq")
|
||||
public ResponseEntity<ArrayList<ScholarshipRequest>> getAllScholarshipRequests(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<ScholarshipRequest> toReturn = new ArrayList<>();
|
||||
|
||||
srr.findAll().forEach(toReturn::add);
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/unregister")
|
||||
public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> uninscr){
|
||||
User u = userRepository.findById((int) uninscr.get("userId"));
|
||||
Curriculum c;
|
||||
|
||||
if (uninscr.get("curriculumId") == null){
|
||||
c = null;
|
||||
}else{
|
||||
c = curriculumRepository.findById((Integer) uninscr.get("curriculumId"));
|
||||
}
|
||||
|
||||
UnregisterRequest ur = new UnregisterRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u.getRegNo(), u.getFirstName(), u.getLastName(), u.getEmail(), c);
|
||||
unregisterRequestRepository.save(ur);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping(value = "/scholarshipreq/")
|
||||
public ResponseEntity<String> editScholReq(@RequestHeader("Authorization") String token, @RequestBody Map<String,Object> infos){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id"));
|
||||
|
||||
User u = scholarshipRequest.getUser();
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (scholarshipRequest.getState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
if (infos.get("state").equals("Accepted")){
|
||||
scholarshipRequest.setState(RequestState.Accepted);
|
||||
scholarshipRequest.setAmount((int) infos.get("amount"));
|
||||
|
||||
//We then deduce then amount from the minerval
|
||||
ArrayList<Minerval> minerval = minervalRepository.getMinervalsByStudentRegNoOrderByYearDesc(u.getRegNo());
|
||||
minerval.get(0).setPaidAmount(minerval.get(0).getPaidAmount() + scholarshipRequest.getAmount());
|
||||
minerval.get(0).setToPay(minerval.get(0).getToPay() - scholarshipRequest.getAmount());
|
||||
minervalRepository.save(minerval.get(0));
|
||||
}else{
|
||||
scholarshipRequest.setState(RequestState.Refused);
|
||||
}
|
||||
|
||||
srr.save(scholarshipRequest);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/scholarshipreq/{id}")
|
||||
public ResponseEntity<ScholarshipRequest> getScholReqbyId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin, Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ScholarshipRequest toReturn = srr.findById(id);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/unregister")
|
||||
public ResponseEntity<ArrayList<UnregisterRequest>> getAllUnregReq(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<UnregisterRequest> toReturn = new ArrayList<>();
|
||||
unregisterRequestRepository.findAll().forEach(toReturn::add);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/unregister/{id}")
|
||||
public ResponseEntity<UnregisterRequest> getUnregbyId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id);
|
||||
return new ResponseEntity<>(unregisterRequest, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping(value = "/unregister/{id}/{newstate}")
|
||||
public ResponseEntity<String> pathUnregReq(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newstate){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id);
|
||||
User u = userRepository.findById(unregisterRequest.getRegNo());
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (unregisterRequest.getState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
unregisterRequest.setState(newstate);
|
||||
unregisterRequestRepository.save(unregisterRequest);
|
||||
if (newstate == RequestState.Accepted){
|
||||
if (unregisterRequest.getCurriculum() == null){
|
||||
ArrayList<UserCurriculum> userCurricula = userCurriculumRepository.findByUserOrderByCurriculum(u);
|
||||
for (int i = 0; i < userCurricula.size(); i++){
|
||||
userCurricula.get(i).setActual(false);
|
||||
}
|
||||
userCurriculumRepository.saveAll(userCurricula);
|
||||
}else{
|
||||
//This usercurriculum will contain the usercurriculum to set false
|
||||
UserCurriculum userCurriculum = userCurriculumRepository.findByUserAndCurriculumAndActual(u, unregisterRequest.getCurriculum(), true);
|
||||
userCurriculum.setActual(false);
|
||||
userCurriculumRepository.save(userCurriculum);
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
//We look in the usercursus table if the student has already the previous year of a curriculum
|
||||
public boolean studentHasPrevYear(Curriculum curriculum, User user){
|
||||
ArrayList<UserCurriculum> userCurrList = userCurriculumRepository.findByUserOrderByCurriculum(user);
|
||||
for (int i = 0; i < userCurrList.size(); i++){
|
||||
if (userCurrList.get(i).getCurriculum().getOption().equals(curriculum.getOption()) && userCurrList.get(i).getCurriculum().getYear() == curriculum.getYear()-1){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@PostMapping("/changecurriculumreq")
|
||||
public ResponseEntity<String> addChangeCurrReq(@RequestBody Map<String,Object> reqInfos){
|
||||
User user = userRepository.findById((Integer) reqInfos.get("userId"));
|
||||
|
||||
Curriculum actualCurriculum;
|
||||
|
||||
//If null then it means we are in a supplementary cursus case
|
||||
if (reqInfos.get("actualcursus") == null){
|
||||
actualCurriculum = null;
|
||||
}else{
|
||||
actualCurriculum = curriculumRepository.findById((Integer) reqInfos.get("actualcursus"));
|
||||
}
|
||||
|
||||
Curriculum destinationCurriculum = curriculumRepository.findById((Integer) reqInfos.get("newcursus"));
|
||||
|
||||
ChangeCurriculumRequest changeCurriculumRequest = new ChangeCurriculumRequest(user, actualCurriculum, destinationCurriculum, new Date(), RequestState.Pending, RequestState.Unrequired);
|
||||
|
||||
//Si l'année du cursus est plus grande que 1 et que l'étudiant n'a pas dans sa liste de cursus l'année d'en dessous alors on demande l'accord du prof
|
||||
if (destinationCurriculum.getYear() > 1 && !studentHasPrevYear(destinationCurriculum, user)){
|
||||
changeCurriculumRequest.setTeacherApprovalState(RequestState.Pending);
|
||||
}
|
||||
changeCurriculumRequestRepository.save(changeCurriculumRequest);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/changecurriculumreq")
|
||||
public ResponseEntity<ArrayList <ChangeCurriculumRequest>> getAllChangeCurrReq(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService, Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<ChangeCurriculumRequest> toReturn = new ArrayList<>();
|
||||
|
||||
changeCurriculumRequestRepository.findAll().forEach(toReturn::add);
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/changecurriculumreq/{id}")
|
||||
public ResponseEntity<ChangeCurriculumRequest> getCCrbyId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ChangeCurriculumRequest toReturn = changeCurriculumRequestRepository.findById(id);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/changecurriculumreq/{id}/{newState}")
|
||||
public ResponseEntity<String> editCCReq(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newState){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ChangeCurriculumRequest toEdit = changeCurriculumRequestRepository.findById(id);
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (toEdit.getState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
toEdit.setState(newState);
|
||||
changeCurriculumRequestRepository.save(toEdit);
|
||||
if (newState == RequestState.Accepted && (toEdit.getTeacherApprovalState() == RequestState.Accepted || toEdit.getTeacherApprovalState() == RequestState.Unrequired)){
|
||||
//If actual curriculum is not null then we need to set that the user doesn't follow it anymore
|
||||
acceptProcedure(toEdit);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/changecurriculumreqteacher/{id}/{newteacherstate}")
|
||||
public ResponseEntity<String> editCCReqTeacherState(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newteacherstate){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ChangeCurriculumRequest toEdit = changeCurriculumRequestRepository.findById(id);
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (toEdit.getTeacherApprovalState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
toEdit.setState(newteacherstate);
|
||||
changeCurriculumRequestRepository.save(toEdit);
|
||||
|
||||
if (newteacherstate == RequestState.Accepted && toEdit.getState() == RequestState.Accepted){
|
||||
//If actual curriculum is not null then we need to set that the user doesn't follow it anymore
|
||||
acceptProcedure(toEdit);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
private void acceptProcedure(ChangeCurriculumRequest toEdit) {
|
||||
User u = toEdit.getUser();
|
||||
if (toEdit.getActualCurriculum() != null){
|
||||
ArrayList<UserCurriculum> listcurr = userCurriculumRepository.findByUserOrderByCurriculum(u);
|
||||
|
||||
for (int i = 0; i < listcurr.size(); i++){
|
||||
if (listcurr.get(i).getCurriculum() == toEdit.getActualCurriculum()){
|
||||
listcurr.get(i).setActual(false);
|
||||
}
|
||||
}
|
||||
|
||||
userCurriculumRepository.saveAll(listcurr);
|
||||
}
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
UserCurriculum userCurriculum = new UserCurriculum(u, toEdit.getDestinationCurriculum(), c.get(Calendar.YEAR), true);
|
||||
userCurriculumRepository.save(userCurriculum);
|
||||
}
|
||||
|
||||
@GetMapping("/exemptionreq/{userId}")
|
||||
public ResponseEntity<ArrayList<ExemptionsRequest>> getExReqByuser(@RequestHeader("Authorization") String token, @PathVariable long userId){
|
||||
User currentUser = tokenService.getUserFromToken(token);
|
||||
|
||||
//Only admin, teacher, secretary and the student himself can access a student's data here
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher, Role.Secretary},token) && currentUser.getRegNo() != userId)
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
User u = userRepository.findById(userId);
|
||||
|
||||
ArrayList<ExemptionsRequest> exList = err.findByUser(u);
|
||||
return new ResponseEntity<>(exList, HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Inscription;
|
||||
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.CurriculumRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.Inscription.InscriptionService;
|
||||
import ovh.herisson.Clyde.Services.InscriptionService;
|
||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import java.util.Map;
|
||||
@ -21,18 +19,17 @@ public class InscriptionController {
|
||||
|
||||
private final InscriptionService inscriptionServ;
|
||||
private final AuthenticatorService authServ;
|
||||
private final CurriculumRepository curriculumRepository;
|
||||
public InscriptionController(InscriptionService inscriptionServ, AuthenticatorService authServ, CurriculumRepository curriculumRepository){
|
||||
|
||||
public InscriptionController(InscriptionService inscriptionServ, AuthenticatorService authServ){
|
||||
this.inscriptionServ = inscriptionServ;
|
||||
this.authServ = authServ;
|
||||
this.curriculumRepository = curriculumRepository;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/requests/register")
|
||||
public ResponseEntity<Iterable<Map<String,Object>>> getAllRequests(@RequestHeader("Authorization") String token){
|
||||
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService, Role.Teacher},token))
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
|
||||
@ -44,7 +41,7 @@ public class InscriptionController {
|
||||
@GetMapping("/request/register/{id}")
|
||||
public ResponseEntity<Map<String,Object>> getById(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService, Role.Teacher},token))
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
InscriptionRequest foundInscriptionRequest = inscriptionServ.getById(id);
|
||||
@ -82,55 +79,4 @@ public class InscriptionController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
//Allow teacher or admin to accept or refuse the equivalence
|
||||
@PatchMapping("/request/registerequiv/{id}/{newstate}")
|
||||
public ResponseEntity<Object> editRegisterEquiv(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newstate){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher}, token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
InscriptionRequest toEdit = inscriptionServ.getById(id);
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (toEdit.getEquivalenceState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
toEdit.setEquivalenceState(newstate);
|
||||
|
||||
inscriptionServ.save(toEdit);
|
||||
|
||||
if (toEdit.getState() == RequestState.Accepted && (toEdit.getEquivalenceState() == RequestState.Accepted || toEdit.getEquivalenceState() == RequestState.Unrequired))
|
||||
{
|
||||
inscriptionServ.createUser(toEdit);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/request/registerequivimpose/{id}/{cursusid}")
|
||||
public ResponseEntity<Object> editRegisterEquiv(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable long cursusid){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher}, token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
InscriptionRequest toEdit = inscriptionServ.getById(id);
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (toEdit.getEquivalenceState() == RequestState.Accepted){
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
//We impose a curriculum
|
||||
Curriculum curriculum = curriculumRepository.findById(cursusid);
|
||||
|
||||
toEdit.setCurriculumId(curriculum.getCurriculumId());
|
||||
toEdit.setEquivalenceState(RequestState.Accepted);
|
||||
|
||||
inscriptionServ.save(toEdit);
|
||||
|
||||
if (toEdit.getState() == RequestState.Accepted && (toEdit.getEquivalenceState() == RequestState.Accepted || toEdit.getEquivalenceState() == RequestState.Unrequired))
|
||||
{
|
||||
inscriptionServ.createUser(toEdit);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
/******************************************************
|
||||
* @file LessonController.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Controller of Lessons API
|
||||
******************************************************/
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.LessonService;
|
||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Services.ScheduleLessonService;
|
||||
import ovh.herisson.Clyde.Tables.Lesson;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class LessonController {
|
||||
private final LessonService lessonServ;
|
||||
|
||||
private final ScheduleLessonService scheduleLessonServ;
|
||||
private final AuthenticatorService authServ;
|
||||
|
||||
public LessonController(LessonService lessonServ, ScheduleLessonService scheduleLessonService, AuthenticatorService authServ) {
|
||||
this.lessonServ = lessonServ;
|
||||
this.scheduleLessonServ = scheduleLessonService;
|
||||
this.authServ = authServ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a lesson via its id
|
||||
*/
|
||||
@GetMapping("/lesson/{id}")
|
||||
public ResponseEntity<HashMap<String,Object>> getLesson(@PathVariable long id){
|
||||
Lesson lesson = lessonServ.findById(id);
|
||||
|
||||
if(lesson == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
|
||||
return new ResponseEntity<>(ProtectionService.lessonWithoutPassword(lesson),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the lessons
|
||||
*/
|
||||
@GetMapping("/lessons")
|
||||
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllLessons(@RequestHeader("Authorization") String token){
|
||||
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findAll()),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the lessons of a teacher's courses
|
||||
*/
|
||||
@GetMapping("/lessons/owned")
|
||||
public ResponseEntity<Iterable<HashMap<String,Object>>> getOwnedLessons(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token)){
|
||||
return new UnauthorizedResponse<>(null);}
|
||||
return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findAllOwnedLesson(authServ.getUserFromToken(token))),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
⋅* Return all the lessons of a student
|
||||
*/
|
||||
@GetMapping("/lessons/OwnCurriculum")
|
||||
public ResponseEntity<Iterable<HashMap<String,Object>>> getOnesLessons(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Student},token)){
|
||||
return new UnauthorizedResponse<>(null);}
|
||||
return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findOnesLessons(authServ.getUserFromToken(token))),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a new lesson
|
||||
*/
|
||||
@PostMapping("/lesson")
|
||||
public ResponseEntity<HashMap<String, Object>> postLesson(@RequestHeader("Authorization") String token,
|
||||
@RequestBody Map<String, Object> lessonInfos){
|
||||
if(authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
|
||||
Lesson lesson = lessonServ.createLesson(lessonInfos);
|
||||
Lesson createdLesson = lessonServ.save(lesson);
|
||||
scheduleLessonServ.saveToAllSchedule(lesson);
|
||||
|
||||
if(createdLesson==null)
|
||||
return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
|
||||
return new ResponseEntity<>(ProtectionService.lessonWithoutPassword(createdLesson), HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Modify a lesson
|
||||
*/
|
||||
@PatchMapping("/lesson/{id}")
|
||||
public ResponseEntity<Lesson> patchLesson(@RequestHeader("Authorization") String token,
|
||||
@RequestBody Map<String, Object> updates,
|
||||
@PathVariable long id){
|
||||
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
if(!lessonServ.modifyData(id, updates)){
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Delete a lesson
|
||||
*/
|
||||
@DeleteMapping("lesson/{id}")
|
||||
public ResponseEntity<String> deleteLesson(@RequestHeader("Authorization") String token,
|
||||
@PathVariable Long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
Lesson toDelete = lessonServ.findById(id);
|
||||
if(toDelete == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
lessonServ.delete(toDelete);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
}
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
/******************************************************
|
||||
* @file LessonRequestsController.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Controller of lesson requests API
|
||||
******************************************************/
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.LessonRequestService;
|
||||
import ovh.herisson.Clyde.Services.LessonService;
|
||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Tables.LessonChangesRequest;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class LessonRequestsController {
|
||||
private final LessonRequestService lessonRequestServ;
|
||||
private final AuthenticatorService authServ;
|
||||
|
||||
private final LessonService lessonServ;
|
||||
public LessonRequestsController(LessonRequestService lessonRequestServer, AuthenticatorService authServ, LessonService lessonServ) {
|
||||
this.lessonRequestServ = lessonRequestServer;
|
||||
this.authServ = authServ;
|
||||
this.lessonServ = lessonServ;
|
||||
}
|
||||
/**
|
||||
* Return a lesson request via its id
|
||||
*/
|
||||
@GetMapping("/requests/lessonRequest/{id}")
|
||||
public ResponseEntity<Map<String,Object>> getById(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
LessonChangesRequest lessonRequest= lessonRequestServ.findById(id);
|
||||
|
||||
return new ResponseEntity<>(ProtectionService.lessonRequestWithoutPassword(lessonRequest), HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* return all the requests made by a user
|
||||
*/
|
||||
@GetMapping("/requests/lessonRequests/owned")
|
||||
public ResponseEntity<Iterable<Map<String, Object>>> getOwnedRequests(@RequestHeader("Authorization") String token){
|
||||
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
User user = authServ.getUserFromToken(token);
|
||||
Iterable<LessonChangesRequest> lessonChangesRequests = lessonRequestServ.findOwnRequests(user);
|
||||
return new ResponseEntity<>(ProtectionService.lessonRequestsWithoutPassword(lessonChangesRequests),HttpStatus.OK);
|
||||
|
||||
}
|
||||
/**
|
||||
* Return all the lesson requests
|
||||
*/
|
||||
@GetMapping("/requests/lessonRequests")
|
||||
public ResponseEntity<Iterable<Map<String,Object>>> getAllRequests(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Iterable<LessonChangesRequest> lessonRequests= lessonRequestServ.getAll();
|
||||
|
||||
return new ResponseEntity<>(ProtectionService.lessonRequestsWithoutPassword(lessonRequests), HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Post a lesson request
|
||||
*/
|
||||
@PostMapping("/requests/lessonRequest")
|
||||
public ResponseEntity<Map<String, Object>> makeRequest(@RequestHeader("Authorization") String token, @RequestBody Map<String,Object> lessonRequestInfos){
|
||||
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
LessonChangesRequest lessonChangesRequest = lessonRequestServ.createLessonRequest(lessonRequestInfos);
|
||||
LessonChangesRequest createdRequest = lessonRequestServ.save(lessonChangesRequest);
|
||||
if(createdRequest == null)
|
||||
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
|
||||
return new ResponseEntity<>(ProtectionService.lessonRequestWithoutPassword(lessonChangesRequest),HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Modify a lesson Request
|
||||
*/
|
||||
@PatchMapping("/requests/lessonRequest/{id}")
|
||||
public ResponseEntity<LessonChangesRequest> changeRequestState(@PathVariable long id,
|
||||
@RequestHeader("Authorization") String token,
|
||||
@RequestBody Map<String , Object> infos){
|
||||
if(authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
LessonChangesRequest lessonRequest = lessonRequestServ.findById(id);
|
||||
String local = "";
|
||||
RequestState state = null;
|
||||
for (Map.Entry<String, Object> entry : infos.entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case "local":
|
||||
local = (String) entry.getValue();
|
||||
break;
|
||||
case "state":
|
||||
state = RequestState.valueOf((String)entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (state == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
|
||||
if(lessonRequest.getRequestType() == 0 ) {
|
||||
if (!lessonRequestServ.modifyCreateRequestState(lessonRequest, state, local))
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
else if(lessonRequest.getRequestType() == 1){
|
||||
infos.put("lessonStart", lessonRequest.getLessonStart());
|
||||
infos.put("lessonEnd", lessonRequest.getLessonEnd());
|
||||
infos.put("lessonType",lessonRequest.getLessonType());
|
||||
if(!lessonRequestServ.modifyChangeRequestState(infos,lessonRequest.getLessonId(),state))
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
lessonRequest.setState(state);
|
||||
}
|
||||
|
||||
else{
|
||||
lessonRequestServ.modifyDeleteRequest(lessonRequest, state);
|
||||
lessonRequest.setState(state);
|
||||
|
||||
}
|
||||
lessonRequestServ.save(lessonRequest);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a lesson request
|
||||
*/
|
||||
@DeleteMapping("/requests/lessonRequest/{id}")
|
||||
public ResponseEntity<String> deleteRequest(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
LessonChangesRequest lessonChangesRequest = lessonRequestServ.findById(id);
|
||||
if (lessonChangesRequest == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
lessonRequestServ.delete(lessonChangesRequest);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -5,14 +5,10 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@ -20,7 +16,7 @@ import java.util.Map;
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class LoginController {
|
||||
private final AuthenticatorService authServ;
|
||||
private final CurriculumRepository curriculumRepository;
|
||||
|
||||
static public class RequestLogin{
|
||||
private final String identifier;
|
||||
private final String password;
|
||||
@ -33,9 +29,8 @@ public class LoginController {
|
||||
}
|
||||
}
|
||||
|
||||
public LoginController(AuthenticatorService authServ, CurriculumRepository curriculumRepository){
|
||||
public LoginController(AuthenticatorService authServ){
|
||||
this.authServ = authServ;
|
||||
this.curriculumRepository = curriculumRepository;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/login")
|
||||
@ -53,18 +48,9 @@ public class LoginController {
|
||||
|
||||
@PostMapping("/register")
|
||||
public ResponseEntity<Map<String,Object>> register(@RequestBody InscriptionRequest inscriptionRequest){
|
||||
//We ensure here that if the targeted cursus year is more than first grade then we need the teacher equivalence approval
|
||||
Curriculum curr = curriculumRepository.findById(inscriptionRequest.getCurriculumId());
|
||||
|
||||
if (curr.getYear() > 1){
|
||||
inscriptionRequest.setEquivalenceState(RequestState.Pending);
|
||||
}else{
|
||||
inscriptionRequest.setEquivalenceState(RequestState.Unrequired);
|
||||
}
|
||||
|
||||
InscriptionRequest returnedInscriptionRequest = authServ.register(inscriptionRequest);
|
||||
|
||||
|
||||
return new ResponseEntity<>(ProtectionService.requestWithoutPassword(returnedInscriptionRequest), HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,10 @@ package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
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.Repositories.TokenRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Services.*;
|
||||
import ovh.herisson.Clyde.Services.Inscription.InscriptionService;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@ -28,24 +22,12 @@ public class MockController {
|
||||
public final CurriculumCourseService CurriculumCourseService;
|
||||
public final CurriculumService curriculumService;
|
||||
public final CourseService courseService;
|
||||
public final ExternalCurriculumRepository externalCurriculumRepository;
|
||||
|
||||
public final InscriptionService inscriptionService;
|
||||
|
||||
public final LessonService lessonService;
|
||||
public final ScheduleService scheduleService;
|
||||
public final ScheduleLessonService scheduleLessonService;
|
||||
|
||||
public final LessonRequestService lessonRequestService;
|
||||
ArrayList<User> mockUsers;
|
||||
|
||||
public final UserCurriculumRepository ucr;
|
||||
|
||||
public final MinervalRepository minervalRepository;
|
||||
|
||||
public final ScholarshipRequestRepository scholarshipRequestRepository;
|
||||
|
||||
public final UnregisterRequestRepository uninscriptionRequestRepository;
|
||||
public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository, UnregisterRequestRepository unregisterRequestRepository, LessonService lessonService, ScheduleService scheduleService, ScheduleLessonService scheduleLessonService, LessonRequestService lessonRequestService){
|
||||
public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){
|
||||
this.userService = userService;
|
||||
this.tokenRepo = tokenRepo;
|
||||
this.userRepo = userRepo;
|
||||
@ -53,16 +35,7 @@ public class MockController {
|
||||
this.CurriculumCourseService = CurriculumCourseService;
|
||||
this.curriculumService = curriculumService;
|
||||
this.courseService = courseService;
|
||||
this.externalCurriculumRepository = externalCurriculumRepository;
|
||||
this.inscriptionService = inscriptionService;
|
||||
this.lessonService = lessonService;
|
||||
this.scheduleService = scheduleService;
|
||||
this.scheduleLessonService = scheduleLessonService;
|
||||
this.lessonRequestService = lessonRequestService;
|
||||
this.ucr = ucr;
|
||||
this.minervalRepository = minervalRepository;
|
||||
this.scholarshipRequestRepository = scholarshipRequestRepository;
|
||||
this.uninscriptionRequestRepository = unregisterRequestRepository;
|
||||
}
|
||||
|
||||
/** Saves an example of each user type by :
|
||||
@ -73,53 +46,33 @@ public class MockController {
|
||||
|
||||
@PostMapping("/mock")
|
||||
public void postMock(){
|
||||
|
||||
// user part
|
||||
|
||||
User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin"));
|
||||
User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student"));
|
||||
User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary"));
|
||||
User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
|
||||
User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
|
||||
User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService"));
|
||||
User popo = new User("Smith", "Paul", "paulsmith@gmail.com", "306 rue du poulet", "belgique", new Date(0), null, Role.Student, passwordEncoder.encode("jesuispaulleroi"));
|
||||
mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo, popo));
|
||||
|
||||
mockUsers = new ArrayList<>(Arrays.asList(joke, herobrine, joe, meh, jojo));
|
||||
userService.saveAll(mockUsers);
|
||||
userService.save(lena);
|
||||
|
||||
ExternalCurriculum externalCurriculum = new ExternalCurriculum(null, "HEH", "Bachelier en ingénieur", "completed", 2015, 2017, null, joe);
|
||||
externalCurriculumRepository.save(externalCurriculum);
|
||||
|
||||
Minerval minerval = new Minerval(joe.getRegNo(), 0, 852, 2023);
|
||||
minervalRepository.save(minerval);
|
||||
// Course / Curriculum part
|
||||
//Course / Curriculum part
|
||||
|
||||
Curriculum infoBab1 = new Curriculum(1,"info", false);
|
||||
Curriculum chemistryBab1 = new Curriculum(1,"chemistry", false);
|
||||
Curriculum psychologyBab1 = new Curriculum(1,"psychology", false);
|
||||
Curriculum infoBab2 = new Curriculum(2,"info", false);
|
||||
Curriculum masterinfo1 = new Curriculum(4, "info", false);
|
||||
Curriculum masterinfo2 = new Curriculum(5, "info", false);
|
||||
Curriculum chemistryBab2 = new Curriculum(2, "chemistry", false);
|
||||
Curriculum ingebab1 = new Curriculum(1, "ingénieur", true);
|
||||
Curriculum infoBab1 = new Curriculum(1,"info");
|
||||
Curriculum chemistryBab1 = new Curriculum(1,"chemistry");
|
||||
Curriculum psychologyBab1 = new Curriculum(1,"psychology");
|
||||
|
||||
curriculumService.save(infoBab1);
|
||||
curriculumService.save(chemistryBab1);
|
||||
curriculumService.save(psychologyBab1);
|
||||
curriculumService.save(infoBab2);
|
||||
curriculumService.save(masterinfo1);
|
||||
curriculumService.save(masterinfo2);
|
||||
curriculumService.save(chemistryBab2);
|
||||
curriculumService.save(ingebab1);
|
||||
|
||||
ucr.save(new UserCurriculum(joe, infoBab1, 2022, false));
|
||||
ucr.save(new UserCurriculum(joe, chemistryBab1, 2023, true));
|
||||
ucr.save(new UserCurriculum(joe, infoBab1, 2023, true));
|
||||
ucr.save(new UserCurriculum(joe, psychologyBab1, 2020, false));
|
||||
ucr.save(new UserCurriculum(popo, infoBab1, 2022, false));
|
||||
ucr.save(new UserCurriculum(popo, infoBab2, 2023, true));
|
||||
|
||||
Course progra1 = new Course(5,"Programmation et algorithmique 1",joke);
|
||||
Course chemistry1 = new Course(12, "Thermochimie",jojo);
|
||||
Course chemistry1 = new Course(12, "Thermochimie",joke);
|
||||
Course psycho1 = new Course(21, "Neuroreaction of isolated brain cells",joke);
|
||||
Course commun = new Course(2, "cours commun",joke);
|
||||
|
||||
@ -128,72 +81,22 @@ public class MockController {
|
||||
courseService.save(psycho1);
|
||||
courseService.save(commun);
|
||||
|
||||
ScholarshipRequest ssr1 = new ScholarshipRequest(joe, RequestState.Pending, 0, new Date(), "test", "test");
|
||||
scholarshipRequestRepository.save(ssr1);
|
||||
|
||||
CurriculumCourseService.save(new CurriculumCourse(infoBab1,progra1));
|
||||
CurriculumCourseService.save(new CurriculumCourse(infoBab1,commun));
|
||||
CurriculumCourseService.save(new CurriculumCourse(infoBab1, psycho1));
|
||||
|
||||
CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,psycho1));
|
||||
CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,commun));
|
||||
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1, chemistry1));
|
||||
|
||||
|
||||
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun));
|
||||
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1));
|
||||
|
||||
InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 4,RequestState.Pending,"yes.png","password", null, new Date(), RequestState.Pending, null);
|
||||
|
||||
InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Pending,"yes.png","password");
|
||||
|
||||
inscriptionService.save(inscriptionRequest);
|
||||
|
||||
|
||||
//Schedule part
|
||||
|
||||
Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 22 2024 08:15", "Mon Apr 22 2024 10:15","rgb(0,50,100)","A0B2","Course");
|
||||
Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(100,50,0)","A0B2","TP");
|
||||
Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(100,50,100)", "A0B2","TD");
|
||||
Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(0,50,100)","A0B2","TP");
|
||||
Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(0,50,100)","A0B2","Course");
|
||||
|
||||
LessonChangesRequest request1 = new LessonChangesRequest(joke,RequestState.Pending,null,null,null,null,2,null,1);
|
||||
LessonChangesRequest request2 = new LessonChangesRequest(joke,RequestState.Pending,"Fri Apr 19 2024 10:30 ","Fri Apr 19 2024 12:30 ",null,null,1,null,2);
|
||||
LessonChangesRequest request3 = new LessonChangesRequest(joke,RequestState.Pending,"Fri Apr 19 2024 13:30 ","Fri Apr 19 2024 15:30 ","Course",progra1,0,"rgb(27,49,100)",4);
|
||||
|
||||
|
||||
Schedule infoBab1Schedule = new Schedule(infoBab1);
|
||||
Schedule chemistryBab1Schedule = new Schedule(chemistryBab1);
|
||||
Schedule psychoBab1Schedule = new Schedule(psychologyBab1);
|
||||
|
||||
|
||||
scheduleService.save(infoBab1Schedule);
|
||||
scheduleService.save(chemistryBab1Schedule);
|
||||
scheduleService.save(psychoBab1Schedule);
|
||||
|
||||
lessonService.save(lesson_0_progra1);
|
||||
lessonService.save(lesson_0_chemistry1);
|
||||
lessonService.save(lesson_0_commun);
|
||||
lessonService.save(lesson_0_psycho1);
|
||||
lessonService.save(lesson_1_progra1);
|
||||
|
||||
scheduleLessonService.save(new ScheduleLesson(infoBab1Schedule,lesson_0_progra1));
|
||||
scheduleLessonService.save(new ScheduleLesson(infoBab1Schedule,lesson_1_progra1));
|
||||
scheduleLessonService.save(new ScheduleLesson(infoBab1Schedule,lesson_0_commun));
|
||||
|
||||
scheduleLessonService.save(new ScheduleLesson(chemistryBab1Schedule,lesson_0_chemistry1));
|
||||
scheduleLessonService.save(new ScheduleLesson(chemistryBab1Schedule,lesson_0_commun));
|
||||
|
||||
scheduleLessonService.save(new ScheduleLesson(psychoBab1Schedule,lesson_0_psycho1));
|
||||
scheduleLessonService.save(new ScheduleLesson(psychoBab1Schedule,lesson_0_commun));
|
||||
|
||||
|
||||
lessonRequestService.save(request1);
|
||||
lessonRequestService.save(request2);
|
||||
lessonRequestService.save(request3);
|
||||
|
||||
UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail(), null);
|
||||
uninscriptionRequestRepository.save(unregisterRequest);
|
||||
|
||||
externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null);
|
||||
externalCurriculumRepository.save(externalCurriculum);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,113 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Msg;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.websocket.server.PathParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Msg.AnswerRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Msg.ForumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Msg.TopicRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.CourseService;
|
||||
import ovh.herisson.Clyde.Services.Msg.ForumService;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.Token;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Answer;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Forum;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Topic;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
@AllArgsConstructor
|
||||
public class ForumController {
|
||||
|
||||
private CourseRepository courseRepo;
|
||||
private AuthenticatorService authServ;
|
||||
private ForumService forumServ;
|
||||
private ForumRepository forumRepo;
|
||||
private TopicRepository topicRepo;
|
||||
|
||||
//// Endpoints to get and create new forums
|
||||
|
||||
@GetMapping("/forums/{id}")
|
||||
public ResponseEntity<List<Forum>> getForumFromCourseId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
if(u == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
return new ResponseEntity<>(courseRepo.findById(id).getForums(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/forums/{id}")
|
||||
public ResponseEntity<Forum> createForumOfCourse(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Forum data){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
Course c = courseRepo.findById(id);
|
||||
if(!(c.getOwner().equals(u) || u.getRole() == Role.Admin)){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
forumServ.createForum(c, data);
|
||||
return new ResponseEntity<>(HttpStatus.ACCEPTED);
|
||||
}
|
||||
|
||||
//// Endpoints to get and create forum's topic
|
||||
|
||||
@GetMapping("/forum/{id}")
|
||||
public ResponseEntity<List<Topic>> getTopicsFromForumId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
if(u == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
return new ResponseEntity<>(forumRepo.findById(id).orElse(null).getTopics(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/forum/{id}")
|
||||
public ResponseEntity<Topic> postTopicToForum(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Topic data){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
Forum f = forumRepo.findById(id).orElse(null);
|
||||
if(!(f.getWriters().contains(u) || u.getRole() == Role.Admin)){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
forumServ.createTopic(f, data);
|
||||
return new ResponseEntity<>(HttpStatus.ACCEPTED);
|
||||
}
|
||||
|
||||
//// Endpoints related to topics and messages
|
||||
|
||||
@GetMapping("/forum/post/{id}")
|
||||
public ResponseEntity<Topic> getPost(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
if(u == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
Topic t = topicRepo.findById(id).orElse(null);
|
||||
return new ResponseEntity<>(t, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/forum/post/{id}")
|
||||
public ResponseEntity<Topic> postTopicToForum(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Answer data){
|
||||
User u = authServ.getUserFromToken(token);
|
||||
Topic t = topicRepo.findById(id).orElse(null);
|
||||
if(t.isLocked() && u.getRole() != Role.Admin){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
System.out.println(data);
|
||||
forumServ.answerTopic(t, data, u);
|
||||
return new ResponseEntity<>(HttpStatus.ACCEPTED);
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file MessagesController.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* Entry point for the messages application
|
||||
******************************************************/
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import ovh.herisson.Clyde.DTO.Msg.DiscussionDTO;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Msg.DiscussionRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
import ovh.herisson.Clyde.Services.Msg.DiscussionService;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Discussion;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Message;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
@AllArgsConstructor
|
||||
public class MessagesController {
|
||||
|
||||
private AuthenticatorService authServ;
|
||||
private DiscussionService discServ;
|
||||
private DiscussionRepository discRepo;
|
||||
private UserService userServ;
|
||||
|
||||
@GetMapping("/discussions")
|
||||
public ResponseEntity<Iterable<Discussion>> getDiscussions(@RequestHeader("Authorization") String token ){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Iterable<Discussion> mock = discServ.getOwned(authServ.getUserFromToken(token));
|
||||
|
||||
return new ResponseEntity<>(mock, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/discussion/{id}")
|
||||
public ResponseEntity<DiscussionDTO> getDiscussion(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null || !discServ.hasDiscussion(user, id) ){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
return new ResponseEntity<>(DiscussionDTO.construct(discRepo.findById(id).orElse(null), authServ.getUserFromToken(token)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/discussion/{id}")
|
||||
public ResponseEntity<Discussion> AlterDiscussion(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Discussion data){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
disc.setName(data.getName());
|
||||
discRepo.save(disc);
|
||||
return new ResponseEntity<>(disc, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/discussion/{id}/add")
|
||||
public ResponseEntity<Discussion> invite(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody User data){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
User invited = userServ.getUserById(data.getRegNo());
|
||||
disc.addMember(invited);
|
||||
discRepo.save(disc);
|
||||
return new ResponseEntity<>(disc, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/discussion/{id}/remove")
|
||||
public ResponseEntity<Discussion> removeMember(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody User data){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
User member = userServ.getUserById(data.getRegNo());
|
||||
disc.delMember(member);
|
||||
discRepo.save(disc);
|
||||
return new ResponseEntity<>(disc, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/discussion/{id}")
|
||||
public ResponseEntity<Discussion> sendMessage(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Message msg){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
msg.setAuthor(user);
|
||||
if(disc != null)
|
||||
discServ.CreateMessage(disc, msg);
|
||||
return new ResponseEntity<>(disc, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/discussion")
|
||||
public ResponseEntity<Discussion> createDiscussion(@RequestHeader("Authorization") String token, @RequestBody Discussion data){
|
||||
return new ResponseEntity<>(discServ.create(data.getName(), authServ.getUserFromToken(token)), HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
/******************************************************
|
||||
* @file ScheduleController.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Controller of Schedule API
|
||||
******************************************************/
|
||||
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.ScheduleLessonService;
|
||||
import ovh.herisson.Clyde.Services.ScheduleService;
|
||||
import ovh.herisson.Clyde.Services.UserCurriculumService;
|
||||
import ovh.herisson.Clyde.Services.CurriculumService;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Services.LessonService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class ScheduleController {
|
||||
|
||||
private final ScheduleService scheduleServ;
|
||||
private final LessonService lessonServ;
|
||||
|
||||
private final CurriculumService curriculumServ;
|
||||
private final AuthenticatorService authServ;
|
||||
|
||||
private final ScheduleLessonService scheduleLessonServ;
|
||||
|
||||
public ScheduleController(ScheduleService scheduleServ, AuthenticatorService authServ, ScheduleLessonService scheduleLessonServ, CurriculumService curriculumServ,LessonService lessonServ) {
|
||||
this.scheduleServ = scheduleServ;
|
||||
this.authServ = authServ;
|
||||
this.scheduleLessonServ = scheduleLessonServ;
|
||||
this.curriculumServ = curriculumServ;
|
||||
this.lessonServ = lessonServ;
|
||||
}
|
||||
/**
|
||||
* Return schedule via its id
|
||||
*/
|
||||
@GetMapping("/schedule/{id}")
|
||||
public ResponseEntity<Map<String,Object>> findById(@PathVariable long id){
|
||||
Schedule schedule = scheduleServ.findById(id);
|
||||
|
||||
if(schedule == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
return new ResponseEntity<>(scheduleLessonServ.getDepthScheduleBySchedule(schedule),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a schedule via its curriculum id
|
||||
*/
|
||||
@GetMapping("/schedule/curriculum/{id}")
|
||||
public ResponseEntity<Map<String, Object>> findCurriculumSchedule(@PathVariable Long id){
|
||||
Schedule schedule = scheduleLessonServ.getScheduleByCurriculum(curriculumServ.findById(id));
|
||||
if(schedule == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
return new ResponseEntity<>(scheduleLessonServ.getDepthScheduleBySchedule(schedule),HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Return all schedules
|
||||
*/
|
||||
@GetMapping("/schedules")
|
||||
public ResponseEntity<Iterable<Map<String , Object>>> findAllSchedule(){
|
||||
return new ResponseEntity<>(scheduleLessonServ.getAllSchedule(),HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Post a new schedule
|
||||
*/
|
||||
@PostMapping("/schedule")
|
||||
public ResponseEntity<Schedule> postSchedule(@RequestHeader("Authorization") String token,
|
||||
@RequestBody Schedule schedule){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
return new ResponseEntity<>(scheduleServ.save(schedule),HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Post a lesson to a schedule
|
||||
*/
|
||||
@PostMapping("/schedule/{id}")
|
||||
public ResponseEntity<String> postLessonToSchedule(@RequestHeader("Authorization") String token,
|
||||
@RequestBody Long lessonId,
|
||||
@PathVariable long id)
|
||||
{
|
||||
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
if (!scheduleLessonServ.save(new ScheduleLesson( scheduleServ.findById(id), lessonServ.findById(lessonId))))
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
/**
|
||||
* Delete a lesson from a schedule
|
||||
*/
|
||||
@DeleteMapping("/schedule/lesson/{id}")
|
||||
public ResponseEntity<String> deleteLessonFromSchedule(@RequestHeader("Authorization") String token,
|
||||
@RequestBody Long lessonId,
|
||||
@PathVariable Long id)
|
||||
{
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
if (!scheduleLessonServ.delete(lessonId))
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -103,6 +103,9 @@ public class UserController {
|
||||
|
||||
@GetMapping("/teachers")
|
||||
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllTeachers(@RequestHeader("Authorization") String token){
|
||||
if (authServ.getUserFromToken(token) == null)
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Iterable<User> teachers = userService.getAllTeachers();
|
||||
|
||||
return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(teachers), HttpStatus.OK);
|
||||
|
37
backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java
Normal file
37
backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java
Normal file
@ -0,0 +1,37 @@
|
||||
package ovh.herisson.Clyde;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class JdbcConfig {
|
||||
|
||||
@Bean
|
||||
@Profile("!prod")
|
||||
public DataSource psqlSource(){
|
||||
DriverManagerDataSource source = new DriverManagerDataSource();
|
||||
source.setDriverClassName("org.postgresql.Driver");
|
||||
source.setUrl("jdbc:postgresql://localhost:5442/clyde");
|
||||
source.setUsername("devel");
|
||||
source.setPassword("devel");
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Profile("prod")
|
||||
public DataSource psqlSourceProd(){
|
||||
DriverManagerDataSource source = new DriverManagerDataSource();
|
||||
source.setDriverClassName("org.postgresql.Driver");
|
||||
source.setUrl("jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432");
|
||||
source.setUsername("clyde");
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
package ovh.herisson.Clyde;
|
||||
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
@ -43,4 +43,4 @@ public class RegNoGenerator implements IdentifierGenerator {
|
||||
public static void resetCount(){
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.ChangeCurriculumRequest;
|
||||
|
||||
public interface ChangeCurriculumRequestRepository extends CrudRepository<ChangeCurriculumRequest, Long> {
|
||||
ChangeCurriculumRequest findById(long id);
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface ExemptionsRequestRepository extends CrudRepository<ExemptionsRequest, Long> {
|
||||
ExemptionsRequest findById(long id);
|
||||
|
||||
ArrayList<ExemptionsRequest> findByUser(User user);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface ExternalCurriculumRepository extends CrudRepository<ExternalCurriculum, Long> {
|
||||
ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequest(InscriptionRequest ir);
|
||||
|
||||
ArrayList<ExternalCurriculum> getExternalCurriculumByUser(User user);
|
||||
ExternalCurriculum getExternalCurriculumById(long id);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.Minerval;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface MinervalRepository extends CrudRepository<Minerval, Long> {
|
||||
public ArrayList<Minerval> getMinervalsByStudentRegNoOrderByYearDesc(Long studentRegNo);
|
||||
|
||||
public Minerval findById(long id);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.Payment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface PaymentRepository extends CrudRepository<Payment, Long> {
|
||||
public ArrayList<Payment> getPaymentsByStudentRegNo(long regNo);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||
|
||||
public interface ScholarshipRequestRepository extends CrudRepository<ScholarshipRequest, Long> {
|
||||
public ScholarshipRequest findById(long id);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
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> {
|
||||
public UnregisterRequest findById(long l);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||
package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
|
||||
|
||||
public interface InscriptionRepository extends CrudRepository<InscriptionRequest,Long> {
|
@ -1,23 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
/******************************************************
|
||||
* @file LessonChangesRequestRepository.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.LessonChangesRequest;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
public interface LessonChangesRequestRepository extends CrudRepository<LessonChangesRequest, Long> {
|
||||
LessonChangesRequest findById(long id);
|
||||
|
||||
|
||||
@Query("select lr from LessonChangesRequest lr where lr.user = ?1")
|
||||
Iterable<LessonChangesRequest> findOwnRequests(User user);
|
||||
|
||||
@Query("select lr from LessonChangesRequest lr where lr.lessonId = ?1")
|
||||
Iterable<LessonChangesRequest> findRequestByLessonId(long id);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
/******************************************************
|
||||
* @file LessonRepository.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.Lesson;
|
||||
|
||||
public interface LessonRepository extends CrudRepository<Lesson, Long> {
|
||||
|
||||
Lesson findById(long id);
|
||||
|
||||
@Query("select l from Lesson l where l.course = ?1")
|
||||
Iterable<Lesson> findLessonByCourse(Course course);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Msg;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.Msg.Answer;
|
||||
|
||||
public interface AnswerRepository extends CrudRepository<Answer, Long> {
|
||||
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file DiscussionRepository.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* Repository of Discussion allowing to fetch discussion by user
|
||||
******************************************************/
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.Msg.Discussion;
|
||||
|
||||
public interface DiscussionRepository extends CrudRepository<Discussion, Long>{
|
||||
|
||||
@Query("SELECT d FROM Discussion d INNER JOIN FETCH d.members dm WHERE dm.id = ?1")
|
||||
List<Discussion> findByMembership(long userid);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Msg;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.Msg.Forum;
|
||||
|
||||
public interface ForumRepository extends CrudRepository<Forum, Long> {
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file MessageRepository.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
******************************************************/
|
||||
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.Msg.Message;
|
||||
|
||||
public interface MessageRepository extends CrudRepository<Message, Long> {}
|
@ -1,10 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories.Msg;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.Msg.Topic;
|
||||
|
||||
public interface TopicRepository extends CrudRepository<Topic, Long> {
|
||||
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
/******************************************************
|
||||
* @file ScheduleLessonRepository.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.Lesson;
|
||||
import ovh.herisson.Clyde.Tables.Schedule;
|
||||
import ovh.herisson.Clyde.Tables.ScheduleLesson;
|
||||
|
||||
public interface ScheduleLessonRepository extends CrudRepository<ScheduleLesson,Long> {
|
||||
|
||||
@Query("select distinct sl.lesson from ScheduleLesson sl where sl.schedule.curriculum = ?1")
|
||||
Iterable<Lesson> findLessonByCurriculum(Curriculum curriculum);
|
||||
|
||||
@Query("select distinct sl.schedule from ScheduleLesson sl where sl.schedule.curriculum = ?1")
|
||||
Schedule findScheduleByCurriculum(Curriculum curriculum);
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query("delete from ScheduleLesson sl where sl.lesson =?1")
|
||||
void delete(Lesson lesson);
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
/******************************************************
|
||||
* @file ScheduleRepository.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.Lesson;
|
||||
import ovh.herisson.Clyde.Tables.Schedule;
|
||||
|
||||
public interface ScheduleRepository extends CrudRepository<Schedule,Long> {
|
||||
|
||||
Schedule getById(long id);
|
||||
|
||||
|
||||
@Query("select distinct sl from Schedule sl where EXISTS (select c.curriculum from CurriculumCourse c where (sl.curriculum = c.curriculum) AND (c.course = ?1))")
|
||||
Iterable<Schedule> findAllLessonSchedule(Course course);
|
||||
}
|
@ -6,16 +6,8 @@ import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.UserCurriculum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface UserCurriculumRepository extends CrudRepository<UserCurriculum, Long> {
|
||||
|
||||
@Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1")
|
||||
Curriculum findByUser(User student);
|
||||
|
||||
ArrayList<UserCurriculum> findByUserOrderByCurriculum(User student);
|
||||
UserCurriculum findByUserAndCurriculumAndActual(User user, Curriculum curriculum, boolean actual);
|
||||
|
||||
ArrayList<UserCurriculum> findByUserAndActual(User user, boolean actual);
|
||||
|
||||
}
|
||||
|
@ -5,13 +5,10 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
public interface UserRepository extends CrudRepository<User, Long> {
|
||||
|
||||
User findById(long id);
|
||||
|
||||
User findByEmail(String email);
|
||||
|
||||
|
||||
|
||||
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher")
|
||||
Iterable<User> findAllTeachers();
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Services.Inscription.InscriptionService;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
|
@ -46,7 +46,7 @@ public class CurriculumCourseService {
|
||||
toReturn.put("curriculumId", curriculum.getCurriculumId());
|
||||
toReturn.put("year", curriculum.getYear());
|
||||
toReturn.put("option", curriculum.getOption());
|
||||
toReturn.put("requireCertificate", curriculum.isRequireCertificate());
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class CurriculumService {
|
||||
public Curriculum findById(long id){
|
||||
return curriculumRepo.findById(id);
|
||||
}
|
||||
|
||||
public void delete(Curriculum curriculum) {
|
||||
curriculumRepo.delete(curriculum);
|
||||
}
|
||||
|
@ -1,115 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services.Inscription;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.*;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
@Service
|
||||
public class InscriptionService {
|
||||
|
||||
private final InscriptionRepository inscriptionRepo;
|
||||
|
||||
private final UserRepository userRepo;
|
||||
|
||||
private final UserCurriculumRepository userCurriculumRepo;
|
||||
|
||||
private final CurriculumRepository curriculumRepo;
|
||||
|
||||
private final MinervalRepository minervalRepository;
|
||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
private final ExternalCurriculumRepository externalCurriculumRepository;
|
||||
private final UserService userService;
|
||||
public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo, MinervalRepository minervalRepository, ExternalCurriculumRepository externalCurriculumRepository, UserService userService){
|
||||
this.inscriptionRepo = inscriptionRepo;
|
||||
this.userRepo = userRepo;
|
||||
this.userCurriculumRepo = userCurriculumRepo;
|
||||
this.curriculumRepo = curriculumRepo;
|
||||
this.minervalRepository = minervalRepository;
|
||||
this.externalCurriculumRepository = externalCurriculumRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public InscriptionRequest save(InscriptionRequest inscriptionRequest){
|
||||
inscriptionRequest.setPassword(passwordEncoder.encode(inscriptionRequest.getPassword()));
|
||||
return inscriptionRepo.save(inscriptionRequest);
|
||||
}
|
||||
|
||||
public InscriptionRequest getById(long id){
|
||||
return inscriptionRepo.findById(id);
|
||||
}
|
||||
|
||||
public Iterable<InscriptionRequest> getAll(){
|
||||
return inscriptionRepo.findAll();
|
||||
}
|
||||
|
||||
public boolean modifyState(long id, RequestState requestState) {
|
||||
InscriptionRequest inscrRequest = getById(id);
|
||||
|
||||
if (inscrRequest == null)
|
||||
return false;
|
||||
|
||||
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
|
||||
if (inscrRequest.getState() == RequestState.Accepted){
|
||||
return true;
|
||||
}
|
||||
|
||||
inscrRequest.setState(requestState);
|
||||
save(inscrRequest);
|
||||
|
||||
//saves the user from the request if accepted from teacher and inscription services
|
||||
if (requestState == RequestState.Accepted && (inscrRequest.getEquivalenceState() == RequestState.Accepted || inscrRequest.getEquivalenceState() == RequestState.Unrequired))
|
||||
{
|
||||
return createUser(inscrRequest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createUser(InscriptionRequest inscrRequest){
|
||||
//We must send an email here
|
||||
|
||||
if (curriculumRepo.findById(inscrRequest.getCurriculumId()) == null)
|
||||
return false;
|
||||
|
||||
User userFromRequest = new User(
|
||||
inscrRequest.getLastName(),
|
||||
inscrRequest.getFirstName(),
|
||||
inscrRequest.getEmail(),
|
||||
inscrRequest.getAddress(),
|
||||
inscrRequest.getCountry(),
|
||||
inscrRequest.getBirthDate(),
|
||||
inscrRequest.getProfilePicture(),
|
||||
inscrRequest.getPassword(),
|
||||
inscrRequest.getIdentityCard()
|
||||
);
|
||||
|
||||
userService.save(userFromRequest);
|
||||
Calendar c = Calendar.getInstance();
|
||||
userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),c.get(Calendar.YEAR), true));
|
||||
|
||||
//Create a minerval for the new student
|
||||
Minerval minerval = new Minerval(userFromRequest.getRegNo(), 0, 852, 2023);
|
||||
minervalRepository.save(minerval);
|
||||
|
||||
//Assign the externals curriculums from the inscription request to newly created student
|
||||
ArrayList<ExternalCurriculum> extCurrList = externalCurriculumRepository.getExternalCurriculumByInscriptionRequest(inscrRequest);
|
||||
for (int i = 0; i < extCurrList.size(); i++){
|
||||
extCurrList.get(i).setUser(userFromRequest);
|
||||
externalCurriculumRepository.save(extCurrList.get(i));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void delete(InscriptionRequest toDelete) {
|
||||
inscriptionRepo.delete(toDelete);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.UserCurriculum;
|
||||
|
||||
@Service
|
||||
public class InscriptionService {
|
||||
|
||||
private final InscriptionRepository inscriptionRepo;
|
||||
|
||||
private final UserRepository userRepo;
|
||||
|
||||
private final UserCurriculumRepository userCurriculumRepo;
|
||||
|
||||
private final CurriculumRepository curriculumRepo;
|
||||
|
||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
|
||||
|
||||
public InscriptionService(InscriptionRepository inscriptionRepo, UserRepository userRepo, UserCurriculumRepository userCurriculumRepo, CurriculumRepository curriculumRepo){
|
||||
this.inscriptionRepo = inscriptionRepo;
|
||||
this.userRepo = userRepo;
|
||||
this.userCurriculumRepo = userCurriculumRepo;
|
||||
this.curriculumRepo = curriculumRepo;
|
||||
}
|
||||
|
||||
public InscriptionRequest save(InscriptionRequest inscriptionRequest){
|
||||
inscriptionRequest.setPassword(passwordEncoder.encode(inscriptionRequest.getPassword()));
|
||||
return inscriptionRepo.save(inscriptionRequest);
|
||||
}
|
||||
|
||||
public InscriptionRequest getById(long id){
|
||||
return inscriptionRepo.findById(id);
|
||||
}
|
||||
|
||||
public Iterable<InscriptionRequest> getAll(){
|
||||
return inscriptionRepo.findAll();
|
||||
}
|
||||
|
||||
public boolean modifyState(long id, RequestState requestState) {
|
||||
InscriptionRequest inscrRequest = getById(id);
|
||||
|
||||
if (inscrRequest == null)
|
||||
return false;
|
||||
|
||||
// if th state is the same we don't send an email
|
||||
if (requestState == inscrRequest.getState())
|
||||
return false;
|
||||
|
||||
/** todo send an email to tell the poster of the inscrRequest (inscrRequest.getEmail())
|
||||
* to notify them that the state of their request changed
|
||||
* FooEmailFormat toSend = (String.format("Your request state changed from %s to %s"),
|
||||
* inscrRequest.getState(), requestState)
|
||||
* FooEmailSender.send(toSend, inscrRequest.getEmail())
|
||||
*/
|
||||
|
||||
|
||||
//saves the user from the request if accepted
|
||||
if (requestState == RequestState.Accepted)
|
||||
{
|
||||
if (curriculumRepo.findById(inscrRequest.getCurriculumId()) == null)
|
||||
return false;
|
||||
|
||||
User userFromRequest = new User(
|
||||
inscrRequest.getLastName(),
|
||||
inscrRequest.getFirstName(),
|
||||
inscrRequest.getEmail(),
|
||||
inscrRequest.getAddress(),
|
||||
inscrRequest.getCountry(),
|
||||
inscrRequest.getBirthDate(),
|
||||
inscrRequest.getProfilePicture(),
|
||||
inscrRequest.getPassword()
|
||||
);
|
||||
|
||||
userRepo.save(userFromRequest);
|
||||
userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId())));
|
||||
}
|
||||
inscrRequest.setState(requestState);
|
||||
save(inscrRequest);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void delete(InscriptionRequest toDelete) {
|
||||
inscriptionRepo.delete(toDelete);
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
/******************************************************
|
||||
* @file LeessonRequestService.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.*;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class LessonRequestService {
|
||||
private final LessonChangesRequestRepository lessonChangesRepo;
|
||||
|
||||
private final UserRepository userRepo;
|
||||
|
||||
private final LessonRepository lessonRepo;
|
||||
|
||||
private final LessonService lessonServ;
|
||||
|
||||
private final ScheduleLessonRepository scheduleLessonRepo;
|
||||
|
||||
private final ScheduleRepository scheduleRepository;
|
||||
|
||||
private final ScheduleLessonService scheduleLessonService;
|
||||
|
||||
private final UserService userServ;
|
||||
|
||||
private final CourseRepository courseRepository;
|
||||
public LessonRequestService(LessonChangesRequestRepository lessonChangesRepo,
|
||||
UserRepository userRepo, LessonRepository lessonRepo,
|
||||
LessonService lessonServ, ScheduleLessonRepository scheduleLessonRepo,
|
||||
ScheduleRepository scheduleRepository, ScheduleLessonService scheduleLessonService,
|
||||
UserService userServ, CourseRepository courseRepository) {
|
||||
this.lessonChangesRepo = lessonChangesRepo;
|
||||
this.userRepo = userRepo;
|
||||
this.lessonRepo = lessonRepo;
|
||||
this.lessonServ = lessonServ;
|
||||
this.scheduleLessonRepo = scheduleLessonRepo;
|
||||
this.scheduleRepository = scheduleRepository;
|
||||
this.scheduleLessonService = scheduleLessonService;
|
||||
this.userServ = userServ;
|
||||
this.courseRepository = courseRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new lesson request
|
||||
*/
|
||||
public LessonChangesRequest save(LessonChangesRequest lessonRequest){
|
||||
return lessonChangesRepo.save(lessonRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all the requests made by a user
|
||||
*/
|
||||
public Iterable<LessonChangesRequest> findOwnRequests(User user){
|
||||
return lessonChangesRepo.findOwnRequests(user);
|
||||
}
|
||||
public LessonChangesRequest findById(long id){
|
||||
return lessonChangesRepo.findById(id);
|
||||
}
|
||||
/**
|
||||
* Return all the requests
|
||||
*/
|
||||
public Iterable<LessonChangesRequest> getAll(){return lessonChangesRepo.findAll();}
|
||||
|
||||
/**
|
||||
* Create a lesson if a request is accepted
|
||||
*/
|
||||
public boolean modifyCreateRequestState(LessonChangesRequest lessonRequest, RequestState state, String local ){
|
||||
if(lessonRequest == null || state == lessonRequest.getState() || state == null){
|
||||
return false;}
|
||||
if (state == RequestState.Accepted){
|
||||
Course course = courseRepository.findById(lessonRequest.getCourse().getCourseID());
|
||||
if(courseRepository.findById(lessonRequest.getCourse().getCourseID())==null|| local == null){
|
||||
return false;}
|
||||
Lesson lesson = new Lesson();
|
||||
lesson.setCourse(course);
|
||||
lesson.setLessonStart(lessonRequest.getLessonStart());
|
||||
lesson.setLessonEnd(lessonRequest.getLessonEnd());
|
||||
lesson.setColor(lessonRequest.getColor());
|
||||
lesson.setLocal(local);
|
||||
lesson.setLessonType(lessonRequest.getLessonType());
|
||||
|
||||
lesson = lessonRepo.save(lesson);
|
||||
scheduleLessonService.saveToAllSchedule(lesson);
|
||||
}
|
||||
lessonRequest.setState(state);
|
||||
save(lessonRequest);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Iterable<LessonChangesRequest> findRequestByLessonId(long id){
|
||||
return lessonChangesRepo.findRequestByLessonId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refuse all the lesson request that depends on a certain lesson
|
||||
* Used after the deletion of the lesson
|
||||
*/
|
||||
public void refuseAllByLessonId(long id){
|
||||
Iterable<LessonChangesRequest> toRefuse = findRequestByLessonId(id);
|
||||
for(LessonChangesRequest element : toRefuse)
|
||||
element.setState(RequestState.Refused);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a lesson if a request is accepted
|
||||
*/
|
||||
public boolean modifyChangeRequestState(Map<String, Object> updates, long lessonId,RequestState state){
|
||||
if(state == RequestState.Accepted){
|
||||
Lesson lesson = lessonServ.findById(lessonId);
|
||||
return lessonServ.modifyData(lesson.getLessonID(),updates);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a lesson if a request is accepted
|
||||
*/
|
||||
public void modifyDeleteRequest(LessonChangesRequest lessonChangesRequest, RequestState state){
|
||||
if(state == RequestState.Accepted){
|
||||
lessonServ.delete(lessonServ.findById(lessonChangesRequest.getLessonId()));
|
||||
refuseAllByLessonId(lessonChangesRequest.getLessonId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a lesson request
|
||||
*/
|
||||
public LessonChangesRequest createLessonRequest(Map<String,Object> lessonInfos) {
|
||||
LessonChangesRequest target = new LessonChangesRequest();
|
||||
|
||||
for (Map.Entry<String, Object> entry : lessonInfos.entrySet()) {
|
||||
System.out.println(entry.toString());
|
||||
if(entry.getValue() != null){
|
||||
switch (entry.getKey()) {
|
||||
case "requestType":
|
||||
target.setRequestType((int) entry.getValue());
|
||||
break;
|
||||
case "lessonStart":
|
||||
target.setLessonStart((String) entry.getValue());
|
||||
break;
|
||||
case "lessonEnd":
|
||||
target.setLessonEnd((String) entry.getValue());
|
||||
break;
|
||||
case "color":
|
||||
target.setColor((String) entry.getValue());
|
||||
break;
|
||||
case "user":
|
||||
target.setUser(userServ.getUserById((int) entry.getValue()));
|
||||
break;
|
||||
case "lessonType":
|
||||
target.setLessonType((String) entry.getValue());
|
||||
break;
|
||||
case "course":
|
||||
target.setCourse(courseRepository.findById((int) entry.getValue()));
|
||||
break;
|
||||
case "lessonId":
|
||||
target.setLessonId((int) entry.getValue());
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
target.setState(RequestState.Pending);
|
||||
return target;
|
||||
}
|
||||
|
||||
public void delete (LessonChangesRequest toDelete) {
|
||||
lessonChangesRepo.delete(toDelete);
|
||||
}
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* @file LessonService.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.CurriculumCourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.LessonRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class LessonService {
|
||||
private final LessonRepository lessonRepo;
|
||||
private final UserCurriculumRepository userCurriculumRepo;
|
||||
private final CourseRepository courseRepo;
|
||||
private final CurriculumCourseRepository curriculumCourseRepo;
|
||||
public LessonService(LessonRepository lessonRepo, UserCurriculumRepository userCurriculumRepo, CourseRepository courseRepo, CurriculumCourseRepository curriculumCourseRepo){
|
||||
this.lessonRepo = lessonRepo;
|
||||
this.userCurriculumRepo = userCurriculumRepo;
|
||||
this.courseRepo = courseRepo;
|
||||
this.curriculumCourseRepo = curriculumCourseRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a lesson
|
||||
*/
|
||||
public Lesson save(Lesson lesson){
|
||||
return lessonRepo.save(lesson);
|
||||
}
|
||||
/**
|
||||
* Find a lesson by its id
|
||||
*/
|
||||
public Lesson findById(long id){
|
||||
return lessonRepo.findById(id);
|
||||
}
|
||||
/**
|
||||
* Return all the lessons
|
||||
*/
|
||||
public Iterable<Lesson> findAll(){return lessonRepo.findAll();}
|
||||
/**
|
||||
* Return all a teacher's lessons
|
||||
*/
|
||||
public Iterable<Lesson> findAllOwnedLesson(User teacher){
|
||||
ArrayList<Lesson> toReturn = new ArrayList<>();
|
||||
ArrayList<Course> coursesOwned = (ArrayList<Course>) courseRepo.findAllOwnedCoures(teacher);
|
||||
for (Course element : coursesOwned) {
|
||||
for(Lesson lesson : lessonRepo.findLessonByCourse(element))
|
||||
toReturn.add(lesson);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* Return all a student's lessons
|
||||
*/
|
||||
|
||||
public Iterable<Lesson> findOnesLessons(User student){
|
||||
ArrayList<Lesson> toReturn = new ArrayList<>();
|
||||
ArrayList<Course> courses = new ArrayList<>();
|
||||
ArrayList<UserCurriculum> userCurricula = userCurriculumRepo.findByUserAndActual(student, true);
|
||||
for (UserCurriculum userCurriculum : userCurricula) {
|
||||
curriculumCourseRepo.findCoursesByCurriculum(userCurriculum.getCurriculum()).forEach((item) -> {
|
||||
//We need this to eliminate clones because a course can belong to several curriculums
|
||||
if (!courses.contains(item)) {
|
||||
System.out.println(item.getTitle());
|
||||
courses.add(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (Course element : courses) {
|
||||
for(Lesson lesson : lessonRepo.findLessonByCourse(element))
|
||||
toReturn.add(lesson);
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* Construct a new lesson
|
||||
*/
|
||||
public Lesson createLesson(Map<String,Object> lessonInfos) {
|
||||
Lesson target = new Lesson();
|
||||
|
||||
for (Map.Entry<String, Object> entry : lessonInfos.entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case "lessonStart":
|
||||
target.setLessonStart((String) entry.getValue());
|
||||
break;
|
||||
case "lessonEnd":
|
||||
target.setLessonEnd((String) entry.getValue());
|
||||
case "color":
|
||||
target.setColor((String) entry.getValue());
|
||||
break;
|
||||
case "local":
|
||||
target.setLocal((String) entry.getValue());
|
||||
break;
|
||||
case "lessonType":
|
||||
target.setLessonType((String) entry.getValue());
|
||||
break;
|
||||
case "courseID":
|
||||
target.setCourse(courseRepo.findById((int) entry.getValue()));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return target;
|
||||
}
|
||||
/**
|
||||
* Modify a lesson
|
||||
*/
|
||||
public boolean modifyData(long id, Map<String ,Object> updates){
|
||||
Lesson target = lessonRepo.findById(id);
|
||||
|
||||
if(target == null)
|
||||
return false;
|
||||
|
||||
for (Map.Entry<String , Object> entry: updates.entrySet()){
|
||||
switch (entry.getKey()){
|
||||
case "lessonStart":
|
||||
target.setLessonStart((String) entry.getValue());
|
||||
break;
|
||||
case "lessonEnd":
|
||||
target.setLessonEnd((String) entry.getValue());
|
||||
break;
|
||||
case "local":
|
||||
target.setLocal((String) entry.getValue());
|
||||
break;
|
||||
case "lessonType":
|
||||
target.setLessonType((String) entry.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
lessonRepo.save(target);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Delete a lesson
|
||||
*/
|
||||
public void delete(Lesson lesson){
|
||||
lessonRepo.delete(lesson);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services.Msg;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/******************************************************
|
||||
* @file DiscussionService.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* Various function utilised by the messages application
|
||||
******************************************************/
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.JSONPObject;
|
||||
|
||||
import ovh.herisson.Clyde.Repositories.Msg.DiscussionRepository;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Discussion;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Message;
|
||||
|
||||
@Service
|
||||
public class DiscussionService {
|
||||
|
||||
@Autowired
|
||||
private DiscussionRepository discRepo;
|
||||
|
||||
public Discussion create(String name, User author){
|
||||
return discRepo.save(new Discussion(name, author));
|
||||
}
|
||||
|
||||
/**
|
||||
* list discussions owned by a certain user
|
||||
*/
|
||||
public Iterable<Discussion> getOwned(User author){
|
||||
return discRepo.findByMembership(author.getRegNo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a message and link it to it's discussion
|
||||
*/
|
||||
public Discussion CreateMessage(Discussion disc, Message msg){
|
||||
disc.addMessage(msg);
|
||||
return discRepo.save(disc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is in a discussion
|
||||
*/
|
||||
public boolean hasDiscussion(User user, long id) {
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
List<User> members = disc.getMembers();
|
||||
return members.contains(user);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services.Msg;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Msg.ForumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Msg.TopicRepository;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Answer;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Forum;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Topic;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ForumService {
|
||||
|
||||
private CourseRepository courseRepo;
|
||||
private ForumRepository forumRepo;
|
||||
private TopicRepository topicRepo;
|
||||
|
||||
public void createForum(Course c, Forum f){
|
||||
c.addForum(f);
|
||||
courseRepo.save(c);
|
||||
}
|
||||
|
||||
public void createTopic(Forum f, Topic data) {
|
||||
f.addTopic(data);
|
||||
forumRepo.save(f);
|
||||
}
|
||||
|
||||
public void answerTopic(Topic t, Answer data, User u) {
|
||||
data.setAuthor(u);
|
||||
t.addAnswer(data);
|
||||
topicRepo.save(t);
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -29,7 +30,6 @@ public class ProtectionService {
|
||||
toReturn.put("country",user.getCountry());
|
||||
toReturn.put("profilePictureUrl",user.getProfilePictureUrl());
|
||||
toReturn.put("role",user.getRole());
|
||||
toReturn.put("identityCard", user.getIdentityCardUrl());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class ProtectionService {
|
||||
|
||||
HashMap<String ,Object> toReturn = new HashMap<>();
|
||||
|
||||
toReturn.put("courseID",course.getCourseID());
|
||||
toReturn.put("courseId",course.getCourseID());
|
||||
toReturn.put("credits",course.getCredits());
|
||||
toReturn.put("title", course.getTitle());
|
||||
toReturn.put("owner", userWithoutPassword(course.getOwner()));
|
||||
@ -69,33 +69,6 @@ public class ProtectionService {
|
||||
|
||||
}
|
||||
|
||||
public static HashMap<String , Object> lessonWithoutPassword(Lesson lesson){
|
||||
if(lesson == null)
|
||||
return null;
|
||||
|
||||
HashMap<String, Object> toReturn = new HashMap<>();
|
||||
|
||||
toReturn.put("lessonID", lesson.getLessonID());
|
||||
toReturn.put("lessonStart", lesson.getLessonStart());
|
||||
toReturn.put("lessonEnd", lesson.getLessonEnd());
|
||||
toReturn.put("course",courseWithoutPassword(lesson.getCourse()));
|
||||
toReturn.put("local",lesson.getLocal());
|
||||
toReturn.put("color", lesson.getColor());
|
||||
toReturn.put("lessonType",lesson.getLessonType());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static Iterable<HashMap<String ,Object>> lessonsWithoutPassword(Iterable<Lesson> lessons){
|
||||
ArrayList<HashMap<String,Object>> toReturn = new ArrayList<>();
|
||||
|
||||
for (Lesson l: lessons){
|
||||
toReturn.add(ProtectionService.lessonWithoutPassword(l));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) {
|
||||
|
||||
@ -114,38 +87,10 @@ public class ProtectionService {
|
||||
toReturn.put("curriculum", inscriptionRequest.getCurriculumId());
|
||||
toReturn.put("state", inscriptionRequest.getState());
|
||||
toReturn.put("profilePictureUrl", inscriptionRequest.getProfilePicture());
|
||||
toReturn.put("identityCard", inscriptionRequest.getIdentityCard());
|
||||
toReturn.put("submissionDate", inscriptionRequest.getSubmissionDate());
|
||||
toReturn.put("equivalenceState", inscriptionRequest.getEquivalenceState());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static Map<String, Object> lessonRequestWithoutPassword(LessonChangesRequest lessonRequest){
|
||||
if (lessonRequest == null)
|
||||
return null;
|
||||
Map<String, Object> toReturn = new HashMap<>();
|
||||
toReturn.put("id", lessonRequest.getId());
|
||||
toReturn.put("lessonStart", lessonRequest.getLessonStart());
|
||||
toReturn.put("lessonEnd", lessonRequest.getLessonEnd());
|
||||
toReturn.put("lessonType",lessonRequest.getLessonType());
|
||||
toReturn.put("course", courseWithoutPassword(lessonRequest.getCourse()));
|
||||
toReturn.put("user", userWithoutPassword(lessonRequest.getUser()));
|
||||
toReturn.put("requestType", lessonRequest.getRequestType());
|
||||
toReturn.put("state", lessonRequest.getState());
|
||||
toReturn.put("lessonId",lessonRequest.getLessonId());
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static Iterable<Map<String, Object>> lessonRequestsWithoutPassword(Iterable<LessonChangesRequest> lessonChangesRequests){
|
||||
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
|
||||
|
||||
for(LessonChangesRequest lessonChangeRequest: lessonChangesRequests){
|
||||
toReturn.add(lessonRequestWithoutPassword(lessonChangeRequest));
|
||||
}
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
public static Iterable<Map<String ,Object>> requestsWithoutPasswords(Iterable<InscriptionRequest> inscriptionRequests){
|
||||
|
||||
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
|
||||
|
@ -1,93 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
/******************************************************
|
||||
* @file ScheduleLessonService.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
******************************************************/
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.LessonRepository;
|
||||
import ovh.herisson.Clyde.Repositories.ScheduleLessonRepository;
|
||||
import ovh.herisson.Clyde.Repositories.ScheduleRepository;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class ScheduleLessonService {
|
||||
|
||||
private final ScheduleLessonRepository scheduleLessonRepo;
|
||||
|
||||
private final LessonRepository lessonRepo;
|
||||
private final ScheduleRepository scheduleRepo;
|
||||
public ScheduleLessonService(ScheduleLessonRepository scheduleLessonRepo, LessonRepository lessonRepo, ScheduleRepository scheduleRepo) {
|
||||
this.scheduleLessonRepo = scheduleLessonRepo;
|
||||
this.lessonRepo = lessonRepo;
|
||||
this.scheduleRepo = scheduleRepo;
|
||||
}
|
||||
public boolean save(ScheduleLesson scheduleLesson){
|
||||
if(scheduleLesson == null)
|
||||
return false;
|
||||
scheduleLessonRepo.save(scheduleLesson);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Save a lesson to all the schedule it is linked
|
||||
*/
|
||||
public boolean saveToAllSchedule(Lesson lesson){
|
||||
Iterable<Schedule> schedules = scheduleRepo.findAllLessonSchedule(lesson.getCourse());
|
||||
if(schedules == null)
|
||||
return false;
|
||||
for (Schedule schedule : schedules){
|
||||
save(new ScheduleLesson(schedule, lesson));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Delete a scheduleLesson via its lesson
|
||||
*/
|
||||
public boolean delete(long lessonId){
|
||||
if(lessonId == 0)
|
||||
return false;
|
||||
scheduleLessonRepo.delete(lessonRepo.findById(lessonId));
|
||||
return true;
|
||||
}
|
||||
|
||||
public Schedule getScheduleByCurriculum(Curriculum curriculum){
|
||||
return scheduleLessonRepo.findScheduleByCurriculum(curriculum);
|
||||
}
|
||||
/**
|
||||
* Return a schedule and the list of lessons that corresponds
|
||||
*/
|
||||
public Map<String , Object> getDepthScheduleBySchedule(Schedule schedule){
|
||||
if(schedule == null)
|
||||
return null;
|
||||
|
||||
HashMap<String , Object> toReturn = new HashMap<>();
|
||||
ArrayList<Map<String, Object>> lessons = new ArrayList<>();
|
||||
Iterable<Lesson> foundLessons = scheduleLessonRepo.findLessonByCurriculum(schedule.getCurriculum());
|
||||
|
||||
for (Lesson l: foundLessons){
|
||||
lessons.add(ProtectionService.lessonWithoutPassword(l));
|
||||
}
|
||||
toReturn.put("lessons",lessons);
|
||||
toReturn.put("scheduleId" , schedule.getScheduleID());
|
||||
toReturn.put("curriculum", schedule.getCurriculum());
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* Return all the schedules
|
||||
*/
|
||||
public Iterable<Map<String,Object>> getAllSchedule(){
|
||||
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
|
||||
|
||||
for (Schedule schedule: scheduleRepo.findAll()){
|
||||
toReturn.add(getDepthScheduleBySchedule(schedule));
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.ScheduleRepository;
|
||||
import ovh.herisson.Clyde.Tables.Schedule;
|
||||
|
||||
@Service
|
||||
public class ScheduleService {
|
||||
private final ScheduleRepository scheduleRepo;
|
||||
public ScheduleService(ScheduleRepository scheduleRepo) {
|
||||
this.scheduleRepo = scheduleRepo;
|
||||
}
|
||||
public Schedule save(Schedule schedule){
|
||||
return scheduleRepo.save(schedule);
|
||||
}
|
||||
public Schedule findById(long id){
|
||||
return scheduleRepo.getById(id);
|
||||
}
|
||||
public void delete(Schedule schedule){
|
||||
scheduleRepo.delete(schedule);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,55 +1,20 @@
|
||||
package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Service
|
||||
public class UserCurriculumService {
|
||||
|
||||
private final UserCurriculumRepository userCurriculumRepository;
|
||||
private final CurriculumRepository curriculumRepo;
|
||||
|
||||
private final ExternalCurriculumRepository externalCurriculumRepo;
|
||||
public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo, ExternalCurriculumRepository externalCurriculumRepo) {
|
||||
public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) {
|
||||
this.userCurriculumRepository = userCurriculumRepository;
|
||||
this.curriculumRepo = curriculumRepo;
|
||||
this.externalCurriculumRepo = externalCurriculumRepo;
|
||||
}
|
||||
|
||||
public Curriculum findByUser(User student){
|
||||
return userCurriculumRepository.findByUser(student);
|
||||
}
|
||||
|
||||
public HashMap<String,Object> findAllCurriculumByStudent(User student) {
|
||||
ArrayList<UserCurriculum> list = userCurriculumRepository.findByUserOrderByCurriculum(student);
|
||||
|
||||
ArrayList<HashMap<String, Object>> curriculumlist = new ArrayList<HashMap<String, Object>>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
HashMap<String, Object> element = new HashMap<>();
|
||||
Curriculum c = list.get(i).getCurriculum();
|
||||
|
||||
element.put("curriculumId", c.getCurriculumId());
|
||||
element.put("year", c.getYear());
|
||||
element.put("option", c.getOption());
|
||||
element.put("dateyear", list.get(i).getYear());
|
||||
element.put("actual", list.get(i).isActual());
|
||||
|
||||
curriculumlist.add(element);
|
||||
}
|
||||
|
||||
HashMap<String, Object> toReturn = new HashMap<String, Object>();
|
||||
toReturn.put("curriculumList", curriculumlist);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public ArrayList<UserCurriculum> findByStudentAndActual(User u, boolean actual){
|
||||
return userCurriculumRepository.findByUserAndActual(u, actual);
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ package ovh.herisson.Clyde.Services;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Tables.RegNoGenerator;
|
||||
import ovh.herisson.Clyde.RegNoGenerator;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private final UserRepository userRepo;
|
||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
|
||||
public UserService(UserRepository userRepo){
|
||||
this.userRepo = userRepo;
|
||||
}
|
||||
@ -116,6 +116,8 @@ public class UserService {
|
||||
//S'assure que le compteur est bien a 0
|
||||
RegNoGenerator.resetCount();
|
||||
userRepo.saveAll(list);
|
||||
//Reset le compteur a zero pour les futurs ajouts
|
||||
RegNoGenerator.resetCount();
|
||||
}
|
||||
|
||||
public Iterable<User> getAll(){
|
||||
@ -139,4 +141,5 @@ public class UserService {
|
||||
public void delete(User user) {
|
||||
userRepo.delete(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package ovh.herisson.Clyde.Tables;
|
||||
public enum Applications {
|
||||
// without any token
|
||||
Login,
|
||||
Schedule,
|
||||
|
||||
// with any token
|
||||
Profile,
|
||||
@ -13,20 +12,12 @@ public enum Applications {
|
||||
Msg,
|
||||
Forum,
|
||||
Rdv,
|
||||
// teachers authorization
|
||||
|
||||
ManageOwnedLessons,
|
||||
|
||||
// teachers and Secretary authorization
|
||||
ManageCourses,
|
||||
UsersList,
|
||||
|
||||
//Secretary authorization
|
||||
ManageSchedules,
|
||||
LessonRequests,
|
||||
|
||||
// InscriptionService authorization
|
||||
Requests,
|
||||
StudentsList,
|
||||
Payments
|
||||
Inscription,
|
||||
StudentsList
|
||||
}
|
||||
|
@ -1,95 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
public class ChangeCurriculumRequest {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="Users")
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ActualCurriculum")
|
||||
private Curriculum actualCurriculum;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "DestCurriculum")
|
||||
private Curriculum destinationCurriculum;
|
||||
|
||||
private Date date;
|
||||
|
||||
private RequestState state;
|
||||
|
||||
private RequestState teacherApprovalState;
|
||||
public ChangeCurriculumRequest(){}
|
||||
|
||||
public ChangeCurriculumRequest(User user, Curriculum actualCurriculum, Curriculum destinationCurriculum, Date date, RequestState state, RequestState teacherApprovalState){
|
||||
this.user = user;
|
||||
this.actualCurriculum = actualCurriculum;
|
||||
this.destinationCurriculum = destinationCurriculum;
|
||||
this.date = date;
|
||||
this.state = state;
|
||||
this.teacherApprovalState = teacherApprovalState;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
public Curriculum getActualCurriculum() {
|
||||
return actualCurriculum;
|
||||
}
|
||||
|
||||
public void setActualCurriculum(Curriculum actualCurriculum) {
|
||||
this.actualCurriculum = actualCurriculum;
|
||||
}
|
||||
|
||||
public Curriculum getDestinationCurriculum() {
|
||||
return destinationCurriculum;
|
||||
}
|
||||
|
||||
public void setDestinationCurriculum(Curriculum destinationCurriculum) {
|
||||
this.destinationCurriculum = destinationCurriculum;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public RequestState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(RequestState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public RequestState getTeacherApprovalState() {
|
||||
return teacherApprovalState;
|
||||
}
|
||||
|
||||
public void setTeacherApprovalState(RequestState teacherApprovalState) {
|
||||
this.teacherApprovalState = teacherApprovalState;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,10 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Forum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Course {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@ -27,18 +17,39 @@ public class Course {
|
||||
@JoinColumn(name = "Users")
|
||||
private User owner;
|
||||
|
||||
//// Extension Messagerie /////
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
private List<Forum> forums;
|
||||
|
||||
public void addForum(Forum f){
|
||||
forums.add(f);
|
||||
}
|
||||
///////////////////////////////
|
||||
|
||||
public Course(int credits, String title, User owner){
|
||||
this.credits = credits;
|
||||
this.title = title;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Course() {}
|
||||
|
||||
public int getCourseID() {
|
||||
return courseID;
|
||||
}
|
||||
|
||||
public int getCredits() {
|
||||
return credits;
|
||||
}
|
||||
|
||||
public void setCredits(int credits){
|
||||
this.credits = credits;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title){
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public User getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(User owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,9 @@ public class Curriculum {
|
||||
private int curriculumId;
|
||||
private int year;
|
||||
private String option;
|
||||
|
||||
//True if the curriculum need an entry exam
|
||||
private boolean requireCertificate;
|
||||
public Curriculum(int year, String option, boolean requireCertificate){
|
||||
public Curriculum(int year, String option){
|
||||
this.year = year;
|
||||
this.option = option;
|
||||
this.requireCertificate = requireCertificate;
|
||||
}
|
||||
|
||||
public Curriculum() {}
|
||||
@ -43,11 +39,4 @@ public class Curriculum {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public void setRequireCertificate(boolean requireCertificate) {
|
||||
this.requireCertificate = requireCertificate;
|
||||
}
|
||||
|
||||
public boolean isRequireCertificate() {
|
||||
return requireCertificate;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
public enum FileType {
|
||||
|
||||
ProfilePicture,
|
||||
EducationCertificate,
|
||||
JustificationDocument,
|
||||
IdentityCard,
|
||||
|
||||
EducationCertificate
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
public class ExemptionsRequest {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@JoinColumn(name = "Users")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
private User user;
|
||||
|
||||
@JoinColumn(name = "Course")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
private Course course;
|
||||
private String justifDocument;
|
||||
|
||||
private RequestState state;
|
||||
|
||||
private Date date;
|
||||
|
||||
public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state, Date date){
|
||||
this.user = user;
|
||||
this.course = course;
|
||||
this.justifDocument = justifDocument;
|
||||
this.state = state;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
public ExemptionsRequest(){}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public String getJustifDocument() {
|
||||
return justifDocument;
|
||||
}
|
||||
|
||||
public void setJustifDocument(String justifDocument) {
|
||||
this.justifDocument = justifDocument;
|
||||
}
|
||||
|
||||
|
||||
public RequestState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(RequestState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
//This table stores a student's curriculum from another university
|
||||
@Entity
|
||||
public class ExternalCurriculum {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
//An external curriculum is first linked to an inscription request and when it is accepted and the user is created we link it to the user
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name="InscriptionRequest")
|
||||
private InscriptionRequest inscriptionRequest;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name="Users")
|
||||
private User user;
|
||||
|
||||
private String school;
|
||||
|
||||
private String formation;
|
||||
|
||||
//This string denotes the completion of the external formation or the last year completed by the student in this formation
|
||||
private String completion;
|
||||
|
||||
private int startYear;
|
||||
private int endYear;
|
||||
private String justifdocUrl;
|
||||
|
||||
public ExternalCurriculum(){}
|
||||
|
||||
public ExternalCurriculum(InscriptionRequest ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl,User user){
|
||||
this.inscriptionRequest = ir;
|
||||
this.school = school;
|
||||
this.formation = formation;
|
||||
this.completion = completion;
|
||||
this.startYear = startYear;
|
||||
this.endYear = endYear;
|
||||
this.justifdocUrl = justifdocUrl;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public InscriptionRequest getInscriptionRequest() {
|
||||
return inscriptionRequest;
|
||||
}
|
||||
|
||||
public void setInscriptionRequest(InscriptionRequest inscriptionRequest) {
|
||||
this.inscriptionRequest = inscriptionRequest;
|
||||
}
|
||||
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getFormation() {
|
||||
return formation;
|
||||
}
|
||||
|
||||
public void setFormation(String formation) {
|
||||
this.formation = formation;
|
||||
}
|
||||
|
||||
public String getCompletion(){
|
||||
return completion;
|
||||
}
|
||||
|
||||
public void setCompletion(String completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
public int getStartYear() {
|
||||
return startYear;
|
||||
}
|
||||
|
||||
public void setStartYear(int startYear) {
|
||||
this.startYear = startYear;
|
||||
}
|
||||
|
||||
public int getEndYear() {
|
||||
return endYear;
|
||||
}
|
||||
|
||||
public void setEndYear(int endYear) {
|
||||
this.endYear = endYear;
|
||||
}
|
||||
|
||||
public void setJustifdocUrl(String justifdocUrl) {
|
||||
this.justifdocUrl = justifdocUrl;
|
||||
}
|
||||
|
||||
public String getJustifdocUrl() {
|
||||
return justifdocUrl;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Minerval {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
private long studentRegNo;
|
||||
private int paidAmount;
|
||||
private int toPay;
|
||||
|
||||
//If the academic year is 2023-2024 then 2023 will be stored here (we take the lowest year)
|
||||
private int year;
|
||||
public Minerval(){}
|
||||
|
||||
public Minerval(long studentRegNo, int paidAmount, int toPay, int year){
|
||||
this.studentRegNo = studentRegNo;
|
||||
this.paidAmount = paidAmount;
|
||||
this.toPay = toPay;
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public long getStudentRegNo() {
|
||||
return studentRegNo;
|
||||
}
|
||||
|
||||
public void setStudentRegNo(long studentRegNo) {
|
||||
this.studentRegNo = studentRegNo;
|
||||
}
|
||||
|
||||
public int getPaidAmount() {
|
||||
return paidAmount;
|
||||
}
|
||||
|
||||
public void setPaidAmount(int paidAmount) {
|
||||
this.paidAmount = paidAmount;
|
||||
}
|
||||
|
||||
public int getToPay() {
|
||||
return toPay;
|
||||
}
|
||||
|
||||
public void setToPay(int toPay) {
|
||||
this.toPay = toPay;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
public class Payment {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
private long studentRegNo;
|
||||
private String card;
|
||||
private String client;
|
||||
private Date expDate;
|
||||
private int amount;
|
||||
private Date date;
|
||||
public Payment(){}
|
||||
|
||||
public Payment(long studentRegNo, String card, String client, Date expDate, int amount, Date date){
|
||||
this.studentRegNo = studentRegNo;
|
||||
this.card = card;
|
||||
this.client = client;
|
||||
this.expDate = expDate;
|
||||
this.amount = amount;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public long getStudentRegNo() {
|
||||
return studentRegNo;
|
||||
}
|
||||
|
||||
public void setStudentRegNo(long studentRegNo) {
|
||||
this.studentRegNo = studentRegNo;
|
||||
}
|
||||
|
||||
public String getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
public void setCard(String card) {
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
public String getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setClient(String client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public Date getExpDate() {
|
||||
return expDate;
|
||||
}
|
||||
|
||||
public void setExpDate(Date expDate) {
|
||||
this.expDate = expDate;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Entity
|
||||
public class ScholarshipRequest {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
@JoinColumn(name="Users")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
private User user;
|
||||
private RequestState state;
|
||||
private Date date;
|
||||
private int amount;
|
||||
private String taxDocUrl;
|
||||
private String residencyDocUrl;
|
||||
|
||||
public ScholarshipRequest(User user, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){
|
||||
this.user = user;
|
||||
this.state = state;
|
||||
this.amount = amount;
|
||||
this.date = date;
|
||||
this.taxDocUrl = taxDocUrl;
|
||||
this.residencyDocUrl = residencyDocUrl;
|
||||
}
|
||||
|
||||
public ScholarshipRequest(){}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public RequestState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(RequestState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getResidencyDocUrl() {
|
||||
return residencyDocUrl;
|
||||
}
|
||||
|
||||
public void setResidencyDocUrl(String residencyDocUrl) {
|
||||
this.residencyDocUrl = residencyDocUrl;
|
||||
}
|
||||
|
||||
public String getTaxDocUrl() {
|
||||
return taxDocUrl;
|
||||
}
|
||||
|
||||
public void setTaxDocUrl(String taxDocUrl) {
|
||||
this.taxDocUrl = taxDocUrl;
|
||||
}
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
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;
|
||||
|
||||
//Null if the user unregister for the academic year, contains a curriculum if the user wants to unregister from a specific curriculum
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "Curriculum")
|
||||
private Curriculum curriculum;
|
||||
|
||||
public UnregisterRequest(RequestState state, String reason, Date date, long regNo, String firstName, String lastName, String email, Curriculum curriculum){
|
||||
this.state = state;
|
||||
this.reason = reason;
|
||||
this.date = date;
|
||||
this.regNo = regNo;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.curriculum = curriculum;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void setCurriculum(Curriculum curriculum) {
|
||||
this.curriculum = curriculum;
|
||||
}
|
||||
|
||||
public Curriculum getCurriculum() {
|
||||
return curriculum;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -17,17 +15,14 @@ public class InscriptionRequest {
|
||||
private String email;
|
||||
private String country;
|
||||
private Date birthDate;
|
||||
|
||||
private Long curriculumId;
|
||||
private RequestState state;
|
||||
private String profilePicture;
|
||||
private String password;
|
||||
private String identityCard;
|
||||
private String admissionDocUrl;
|
||||
private Date submissionDate;
|
||||
private RequestState equivalenceState;
|
||||
public InscriptionRequest(){}
|
||||
|
||||
public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState, String admissionDocUrl){
|
||||
private String password;
|
||||
public InscriptionRequest(){}
|
||||
public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password){
|
||||
this.lastName = lastName;
|
||||
this.firstName = firstName;
|
||||
this.address = address;
|
||||
@ -38,10 +33,6 @@ public class InscriptionRequest {
|
||||
this.state = state;
|
||||
this.profilePicture = profilePicture;
|
||||
this.password = password;
|
||||
this.identityCard = identityCard;
|
||||
this.submissionDate = submissionDate;
|
||||
this.equivalenceState = equivalenceState;
|
||||
this.admissionDocUrl = admissionDocUrl;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -127,36 +118,4 @@ public class InscriptionRequest {
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getIdentityCard() {
|
||||
return identityCard;
|
||||
}
|
||||
|
||||
public void setIdentityCard(String identityCard) {
|
||||
this.identityCard = identityCard;
|
||||
}
|
||||
|
||||
public Date getSubmissionDate() {
|
||||
return submissionDate;
|
||||
}
|
||||
|
||||
public void setSubmissionDate(Date submissionDate) {
|
||||
this.submissionDate = submissionDate;
|
||||
}
|
||||
|
||||
public RequestState getEquivalenceState() {
|
||||
return equivalenceState;
|
||||
}
|
||||
|
||||
public void setEquivalenceState(RequestState equivalenceState) {
|
||||
this.equivalenceState = equivalenceState;
|
||||
}
|
||||
|
||||
public String getAdmissionDocUrl() {
|
||||
return admissionDocUrl;
|
||||
}
|
||||
|
||||
public void setAdmissionDocUrl(String admissionDocUrl) {
|
||||
this.admissionDocUrl = admissionDocUrl;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* @file Lesson.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Represent a course in a schedule
|
||||
******************************************************/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
|
||||
@Entity
|
||||
public class Lesson {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int lessonID;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@OnDelete(action = OnDeleteAction.SET_NULL)
|
||||
@JoinColumn(name = "Course")
|
||||
private Course course;
|
||||
|
||||
private String lessonStart;
|
||||
|
||||
private String lessonEnd;
|
||||
|
||||
private String color;
|
||||
|
||||
private String lessonType;
|
||||
|
||||
private String local;
|
||||
|
||||
public Lesson(Course course,String start, String end ,String color,String local,String lessonType){
|
||||
this.lessonEnd = end;
|
||||
this.course = course;
|
||||
this.lessonStart = start;
|
||||
this.color = color;
|
||||
this.local = local;
|
||||
this.lessonType = lessonType;
|
||||
}
|
||||
|
||||
public Lesson() {
|
||||
}
|
||||
|
||||
public int getLessonID(){
|
||||
return lessonID;
|
||||
}
|
||||
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public Course getCourse(){
|
||||
return course;
|
||||
}
|
||||
|
||||
public String getLessonStart(){
|
||||
return lessonStart;
|
||||
}
|
||||
|
||||
public String getLessonEnd() {
|
||||
return lessonEnd;
|
||||
}
|
||||
|
||||
public String getColor(){
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
public String getLessonType(){
|
||||
return lessonType;
|
||||
}
|
||||
|
||||
public void setLessonStart(String start){
|
||||
this.lessonStart = start;
|
||||
}
|
||||
|
||||
public void setLessonEnd(String lessonEnd) {
|
||||
this.lessonEnd = lessonEnd;
|
||||
}
|
||||
|
||||
public void setColor(String color){
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setLocal(String local){
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
public void setLessonType(String lessonType){
|
||||
this.lessonType = lessonType;
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* @file LessonChangesRequest.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Represent a request about changes on schedules and lessons
|
||||
******************************************************/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
@Entity
|
||||
public class LessonChangesRequest {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "Users")
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
private User user;
|
||||
|
||||
private long lessonId;
|
||||
|
||||
private RequestState state;
|
||||
|
||||
private String lessonStart;
|
||||
|
||||
private String lessonEnd;
|
||||
|
||||
private String color;
|
||||
@ManyToOne
|
||||
@JoinColumn(name ="Course")
|
||||
private Course course;
|
||||
|
||||
private String lessonType;
|
||||
|
||||
/**
|
||||
* Can take 3 values:
|
||||
* 0 : Request to CREATE a lesson
|
||||
* 1 : Request to MODIFY an existing lesson
|
||||
* 2 : Request to DELETE a lesson
|
||||
*/
|
||||
private int requestType;
|
||||
|
||||
public LessonChangesRequest(User user, RequestState state, String lessonStart,
|
||||
String lessonEnd, String lessonType, Course course,
|
||||
int requestType, String color,long lessonId){
|
||||
this.user = user;
|
||||
this.state = state;
|
||||
this.requestType = requestType;
|
||||
this.lessonType = lessonType;
|
||||
this.lessonStart = lessonStart;
|
||||
this.lessonEnd= lessonEnd;
|
||||
this.color = color;
|
||||
this.course = course;
|
||||
this.lessonId = lessonId;
|
||||
}
|
||||
|
||||
public LessonChangesRequest() {
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public RequestState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public long getLessonId(){
|
||||
return lessonId;
|
||||
}
|
||||
|
||||
public String getLessonStart() {
|
||||
return lessonStart;
|
||||
}
|
||||
|
||||
public String getLessonEnd() {
|
||||
return lessonEnd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
public String getLessonType() {
|
||||
return lessonType;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setState(RequestState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void setLessonStart(String lessonStart) {
|
||||
this.lessonStart = lessonStart;
|
||||
}
|
||||
|
||||
public void setLessonType(String lessonType) {
|
||||
this.lessonType = lessonType;
|
||||
}
|
||||
|
||||
public void setLessonEnd(String lessonEnd) {
|
||||
this.lessonEnd = lessonEnd;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setRequestType(int requestType) {
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
|
||||
public void setLessonId(long lessonId) {
|
||||
this.lessonId = lessonId;
|
||||
}
|
||||
|
||||
public void setCourse(Course course){
|
||||
this.course = course;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Msg;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Answer {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@CreationTimestamp
|
||||
private Date creation;
|
||||
|
||||
private String content;
|
||||
|
||||
@ManyToOne(cascade=CascadeType.ALL)
|
||||
private User author;
|
||||
|
||||
private boolean anonymous;
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file Discussion.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* Discussion allow to regroupe multiple user in and message together
|
||||
* for the messages application to work
|
||||
******************************************************/
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class Discussion{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
private String name;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "discussion_members",
|
||||
joinColumns = @JoinColumn(name = "discussion_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "user_id")
|
||||
)
|
||||
private List<User> members;
|
||||
|
||||
@OneToMany(mappedBy="discussion", orphanRemoval = true, cascade = CascadeType.ALL)
|
||||
private List<Message> msgs;
|
||||
|
||||
public Discussion(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Discussion(String name, User user){
|
||||
this.name = name;
|
||||
this.members = List.of(user);
|
||||
}
|
||||
|
||||
public void addMessage(Message msg){
|
||||
msg.setDiscussion(this);
|
||||
msgs.add(msg);
|
||||
}
|
||||
|
||||
public void addMember(User user) {
|
||||
members.add(user);
|
||||
}
|
||||
|
||||
public void delMember(User user) {
|
||||
members.remove(user);
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Msg;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import ovh.herisson.Clyde.Tables.Course;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Forum {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@ManyToOne
|
||||
private Course course;
|
||||
|
||||
private String name;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
private List<Topic> topics;
|
||||
|
||||
public void addTopic(Topic t) {
|
||||
topics.add(t);
|
||||
}
|
||||
|
||||
@OneToMany
|
||||
private List<User> writers; // User who are authorized to create a post
|
||||
|
||||
@OneToMany
|
||||
private List<User> register;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Msg;
|
||||
|
||||
/******************************************************
|
||||
* @file Message.java
|
||||
* @author Anthony Debucquoy
|
||||
* @scope Extension messagerie
|
||||
*
|
||||
* Represent a message sent to a discussion
|
||||
******************************************************/
|
||||
|
||||
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import java.util.Date;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.PrePersist;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.TemporalType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
public class Message {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
private String content;
|
||||
|
||||
@CreationTimestamp
|
||||
@Column(nullable = false)
|
||||
private Date created;
|
||||
|
||||
@ManyToOne
|
||||
private User author;
|
||||
|
||||
public User getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
@OneToOne
|
||||
private Message response;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JsonIgnore
|
||||
private Discussion discussion;
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables.Msg;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class Topic {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
private String subject, content;
|
||||
|
||||
@ManyToOne
|
||||
private User author;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
private List<Answer> answers;
|
||||
|
||||
public void addAnswer(Answer a){
|
||||
answers.add(a);
|
||||
}
|
||||
|
||||
private boolean locked; // true if new messages can be posted
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
@Entity
|
||||
public class ReInscriptionRequest {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "Users")
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
private User user;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "Curriculum")
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
private Curriculum newCurriculum;
|
||||
private RequestState state;
|
||||
|
||||
//Permet de différencier les demandes de changement et une réinscription dans le même Curriculum
|
||||
//Pour la réinscription on va le mettre a 0
|
||||
private boolean type = false;
|
||||
|
||||
public ReInscriptionRequest(){}
|
||||
|
||||
public ReInscriptionRequest(User user, Curriculum newCurriculum, RequestState state, boolean type){
|
||||
this.user = user;
|
||||
this.newCurriculum = newCurriculum;
|
||||
this.state = state;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ReInscriptionRequest(User user, Curriculum newCurriculum, RequestState state){
|
||||
this.user = user;
|
||||
this.newCurriculum = newCurriculum;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Curriculum getNewCurriculum() {
|
||||
return newCurriculum;
|
||||
}
|
||||
|
||||
public void setNewCurriculum(Curriculum newCurriculum) {
|
||||
this.newCurriculum = newCurriculum;
|
||||
}
|
||||
|
||||
public RequestState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(RequestState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public boolean isType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(boolean type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -3,6 +3,5 @@ package ovh.herisson.Clyde.Tables;
|
||||
public enum RequestState {
|
||||
Accepted,
|
||||
Refused,
|
||||
Pending,
|
||||
Unrequired
|
||||
Pending
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* @file Schedule.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Represent a schedule linked to a curriculum
|
||||
******************************************************/
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
@Entity
|
||||
public class Schedule {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int scheduleID;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "Curriculum")
|
||||
@OnDelete(action = OnDeleteAction.SET_NULL)
|
||||
private Curriculum curriculum;
|
||||
|
||||
public Schedule(Curriculum curriculum){
|
||||
this.curriculum = curriculum;
|
||||
}
|
||||
|
||||
public Schedule() {}
|
||||
|
||||
|
||||
public int getScheduleID(){
|
||||
return scheduleID;
|
||||
}
|
||||
|
||||
public Curriculum getCurriculum(){
|
||||
return curriculum;
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
|
||||
/******************************************************
|
||||
* @file ScheduleLesson.java
|
||||
* @author William Karpinski
|
||||
* @scope Extension Horaire
|
||||
*
|
||||
* Used to link schedules and lessons to each others
|
||||
******************************************************/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
|
||||
@Entity
|
||||
public class ScheduleLesson{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "Schedule")
|
||||
@OnDelete(action = OnDeleteAction.SET_NULL)
|
||||
private Schedule schedule;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@OnDelete(action = OnDeleteAction.SET_NULL)
|
||||
@JoinColumn(name = "Lesson")
|
||||
private Lesson lesson;
|
||||
|
||||
public ScheduleLesson(Schedule schedule,Lesson lesson){
|
||||
this.schedule = schedule;
|
||||
this.lesson = lesson;
|
||||
}
|
||||
|
||||
public ScheduleLesson() {
|
||||
}
|
||||
|
||||
public int getID(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public Lesson getLesson(){
|
||||
return lesson;
|
||||
}
|
||||
|
||||
public Schedule getSchedule(){
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setLesson(Lesson lesson){
|
||||
this.lesson = lesson;
|
||||
}
|
||||
|
||||
public void setSchedule(Schedule schedule){
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,22 +1,16 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Discussion;
|
||||
import ovh.herisson.Clyde.Tables.Msg.Message;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
@Entity
|
||||
@Table(name = "Users")
|
||||
public class User {
|
||||
@Id
|
||||
@GenericGenerator(name = "userGen", type = ovh.herisson.Clyde.Tables.RegNoGenerator.class)
|
||||
@GenericGenerator(name = "userGen", type = ovh.herisson.Clyde.RegNoGenerator.class)
|
||||
@GeneratedValue(generator = "userGen")
|
||||
private Long regNo;
|
||||
private String lastName;
|
||||
@ -27,19 +21,8 @@ public class User {
|
||||
private String country;
|
||||
private Date birthDate;
|
||||
private String profilePictureUrl;
|
||||
private Role role;
|
||||
private String identityCardUrl;
|
||||
@JsonIgnore
|
||||
private ovh.herisson.Clyde.Tables.Role role;
|
||||
private String password;
|
||||
|
||||
////// Extension Messagerie /////
|
||||
@OneToMany(mappedBy = "author", cascade = CascadeType.ALL)
|
||||
private List<Message> msgs;
|
||||
/////////////////////////////////
|
||||
|
||||
@ManyToMany( mappedBy = "members" )
|
||||
private List<Discussion> discussions;
|
||||
|
||||
public User(String lastName, String firstName, String email, String address,
|
||||
String country, Date birthDate, String profilePictureUrl, Role role, String password)
|
||||
{
|
||||
@ -54,10 +37,8 @@ public class User {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
//This constructor is used to add a student
|
||||
public User(String lastName, String firstName, String email, String address,
|
||||
String country, Date birthDate, String profilePictureUrl, String password,String identityCardUrl)
|
||||
String country, Date birthDate, String profilePictureUrl, String password)
|
||||
{
|
||||
this.lastName = lastName;
|
||||
this.firstName = firstName;
|
||||
@ -68,7 +49,6 @@ public class User {
|
||||
this.profilePictureUrl = profilePictureUrl;
|
||||
this.password = password;
|
||||
this.role = Role.Student;
|
||||
this.identityCardUrl = identityCardUrl;
|
||||
}
|
||||
public User() {}
|
||||
|
||||
@ -142,12 +122,4 @@ public class User {
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setIdentityCardUrl(String identityCardUrl) {
|
||||
this.identityCardUrl = identityCardUrl;
|
||||
}
|
||||
|
||||
public String getIdentityCardUrl() {
|
||||
return identityCardUrl;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserCurriculum {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@ -28,15 +21,30 @@ public class UserCurriculum {
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
private Curriculum curriculum;
|
||||
|
||||
private int year;
|
||||
public UserCurriculum(User user, Curriculum curriculum){
|
||||
this.user = user;
|
||||
this.curriculum = curriculum;
|
||||
}
|
||||
|
||||
//True if the user has that curriculum at the moment false if not
|
||||
private boolean actual;
|
||||
public UserCurriculum() {}
|
||||
|
||||
public UserCurriculum(User u, Curriculum cu, int year, boolean actual){
|
||||
this.user = u;
|
||||
this.curriculum = cu;
|
||||
this.year = year;
|
||||
this.actual = actual;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Curriculum getCurriculum() {
|
||||
return curriculum;
|
||||
}
|
||||
|
||||
public void setCurriculum(Curriculum curriculum) {
|
||||
this.curriculum = curriculum;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,2 @@
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.sql.init.mode=always
|
||||
|
||||
# spring.datasource.url=jdbc:postgresql://localhost:5442/clyde
|
||||
spring.datasource.url=jdbc:postgresql://db:5432/clyde
|
||||
spring.datasource.username=devel
|
||||
spring.datasource.password=devel
|
||||
|
||||
# spring.config.activate.on-profile=prod
|
||||
# spring.datasource.url=jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432
|
||||
# spring.datasource.username=clyde
|
||||
|
@ -23,6 +23,7 @@ import ovh.herisson.Clyde.Repositories.TokenRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.TokenService;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.Token;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
@ -47,6 +48,8 @@ public class UserControllerTest {
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
@Autowired
|
||||
@ -79,12 +82,13 @@ public class UserControllerTest {
|
||||
tokenRepository.deleteAll();
|
||||
userRepository.deleteAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
//Verifie qu'un user qui n'a pas les permissions admin ou secretaire ne peut pas post
|
||||
public void userPostTest(){
|
||||
User god = new User("god","god","admin@admin.com","everywhere","every",new Date(0), null, Role.Admin,"goddoesntneedpassword");
|
||||
Token godToken = new Token(god, tokenService.generateNewToken(), new Date());
|
||||
userRepository.save(god);
|
||||
userService.save(god);
|
||||
tokenService.saveToken(godToken);
|
||||
|
||||
//Can god post herobrine himself ?
|
||||
@ -97,7 +101,7 @@ public class UserControllerTest {
|
||||
//Can noob post herobrine without authorizations (no)
|
||||
User noob = new User("boon","noob","noob@student.com","everywhere","every",new Date(0), null, Role.Student,"noob");
|
||||
Token noobToken = new Token(noob, tokenService.generateNewToken(), new Date());
|
||||
userRepository.save(noob);
|
||||
userService.save(noob);
|
||||
tokenService.saveToken(noobToken);
|
||||
|
||||
with().body(herobrine).contentType(ContentType.JSON).header("Authorization", noobToken.getToken()).when().request("POST", "/user").then().statusCode(401);
|
||||
|
@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
|
29
compose.yaml
29
compose.yaml
@ -1,29 +0,0 @@
|
||||
services:
|
||||
db:
|
||||
image: 'postgres:16'
|
||||
environment:
|
||||
- 'POSTGRES_DB=clyde'
|
||||
- 'POSTGRES_USER=devel'
|
||||
- 'POSTGRES_PASSWORD=devel'
|
||||
# Uncomment this to allow connections to the db from outside the container
|
||||
# ports:
|
||||
# - '5442:5432'
|
||||
back:
|
||||
build: backend/.
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- cdn:/backend/cdn
|
||||
ulimits:
|
||||
nofile:
|
||||
soft: 65536
|
||||
hard: 65536
|
||||
front:
|
||||
build: frontend/.
|
||||
volumes:
|
||||
- cdn:/app/front/dist/cdn
|
||||
ports:
|
||||
- "8000:8080"
|
||||
|
||||
volumes:
|
||||
cdn:
|
@ -1,11 +0,0 @@
|
||||
# https://v2.vuejs.org/v2/cookbook/dockerize-vuejs-app
|
||||
FROM node:lts-alpine
|
||||
RUN npm install -g http-server
|
||||
WORKDIR /app/front
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
ENV VITE_CLYDE_MODE=container
|
||||
RUN npm run build
|
||||
EXPOSE 8080
|
||||
CMD [ "http-server", "dist" ]
|
@ -13,13 +13,6 @@ login.guest.lastpage=Last Page
|
||||
login.guest.submit=Submit
|
||||
login.guest.birthday=BIRTHDAY
|
||||
login.guest.confirm=CONFIRM
|
||||
login.guest.browse=Browse...
|
||||
login.guest.disclaimer=If you are already registered please connect to your account and use the change cursus/reregister function if not continue here.
|
||||
login.guest.identityCard=Identity Card :
|
||||
login.guest.attestationdisclaimer=This curriculum requires an entrance exam attestation
|
||||
login.guest.formationdisclaimer=Please add your old formations with the associated degree/attestation,your case will be check by a member of the inscription service.
|
||||
login.guest.managecareer=Manage your external formations
|
||||
login.guest.sendRegReq=Send register request
|
||||
login.cPassword=Confirm Password
|
||||
login.password=Password
|
||||
app.home=Home
|
||||
@ -29,76 +22,15 @@ app.settings=Settings
|
||||
app.messages=Messages
|
||||
app.forum=Forum
|
||||
app.schedules=Schedules
|
||||
app.manageSchedules=Manage Schedules
|
||||
app.inscription.requests=Inscription Requests
|
||||
app.manage.courses=Manage Courses
|
||||
app.language=Language
|
||||
app.manage.profile=Manage profile
|
||||
app.studentList=Students List
|
||||
app.users=Users
|
||||
app.manageOwnLessons=Manage Owned Courses Schedule
|
||||
app.lessonRequests=Schedule Requests
|
||||
app.payments=Payments
|
||||
request.moreInfos=More Infos
|
||||
request.accept=Accept
|
||||
request.refuse=Refuse
|
||||
Pending=Pending
|
||||
Delete=Delete
|
||||
Modify=Modify
|
||||
Create=Créer
|
||||
requestType=Request Type
|
||||
day=Day
|
||||
start=Start
|
||||
end=End
|
||||
monday=Monday
|
||||
tuesday=Tuesday
|
||||
wednesday=Wednesday
|
||||
thursday=Thursday
|
||||
friday=Friday
|
||||
saturday=Saturday
|
||||
sunday=Sunday
|
||||
january=January
|
||||
february=February
|
||||
march=March
|
||||
april=April
|
||||
may=May
|
||||
june=June
|
||||
july=July
|
||||
august=August
|
||||
september=September
|
||||
october=October
|
||||
november=November
|
||||
december=December
|
||||
Grid=Grid
|
||||
Week=Week
|
||||
Month=Month
|
||||
List=List
|
||||
Type=Type
|
||||
Teacher=Teacher
|
||||
Course=Course
|
||||
TP=TP
|
||||
TD=TD
|
||||
Exam=Exam
|
||||
OwnSchedule=Own Schedule
|
||||
SwitchToJSON=Switch to JSON FILE
|
||||
schedule.previous=Previous
|
||||
schedule.next=Next
|
||||
schedule.current=Current
|
||||
schedule.settings=Settings
|
||||
schedule.courses=Courses
|
||||
schedule.teachers=Teacher(s)
|
||||
schedule.askChanges=Ask Changes
|
||||
schedule.askCreate=Ask to create course
|
||||
schedule.askDeletion=Ask Deletion
|
||||
schedule.createSchedule=Create Schedule
|
||||
schedule.createLesson=Create course
|
||||
schedule.deleteMod=Unable deletion
|
||||
schedule.noDeleteMod=Disable deletion
|
||||
schedule=Schedule
|
||||
old_day=Precedent day
|
||||
old_start=Precedent start
|
||||
old_end=Precedent end
|
||||
old_type=Precedent type
|
||||
courses.createCourse=Create course
|
||||
courses.deleteCourse=Delete course
|
||||
courses.modify=Modify
|
||||
@ -120,90 +52,3 @@ Curriculum=curriculum
|
||||
Credits=Credits
|
||||
InscriptionService=I.S.
|
||||
faculty=Faculty
|
||||
forum.create=Create forum
|
||||
forum.create.name=New forum's name
|
||||
forum.post.create.name=New post's title
|
||||
firstname/name=Firstname/Name
|
||||
regNo=regNo
|
||||
From=From
|
||||
To=To
|
||||
WantedCursus=Wanted Cursus
|
||||
seeprofile=See profile
|
||||
acceptequiv=Accept equivalence
|
||||
refuseequiv=Refuse equivalence
|
||||
course=course
|
||||
state=state
|
||||
dljustifdoc=Download justification document
|
||||
backtoreq=Back to request
|
||||
dlidentitycard=Download identity card
|
||||
dladmissiondoc=Download admission document
|
||||
seeextcur=See external curriculums
|
||||
dltaxdoc=Download tax justification document
|
||||
dlresidency=Download residency justification document
|
||||
enteramount=Please enter the amount to provide :
|
||||
oldcursus=Old curriculums
|
||||
newcursus=New curriculums
|
||||
year=Year
|
||||
reason=Reason :
|
||||
selectedcursus=Selected curriculum :
|
||||
askexemp=Ask exemption
|
||||
exemp=Exempted
|
||||
uploadjustifdoc=Please upload the justification document
|
||||
subexemreq=Submit exemption request
|
||||
addextcurr=Add external curriculum
|
||||
dldoc=Download document
|
||||
edit=Edit
|
||||
delete=Delete
|
||||
school=School
|
||||
checkifnotcompleted=Check the box if you didn't complete the formation
|
||||
wichyearstop=In which year did you stop (ex: 3rd year) ?
|
||||
startyear=Start year
|
||||
endyear=End year
|
||||
giveextcurdoc=Please upload a document that proves this formation
|
||||
uploadcurr=Upload curriculum
|
||||
editcurr=Edit curriculum
|
||||
reqtype=Request type :
|
||||
inscription=register
|
||||
scholarship=scholarship
|
||||
exemption=exemption
|
||||
unregister=unregister
|
||||
curriculumch=curriculum change
|
||||
filter=Filter :
|
||||
approval=Approval :
|
||||
teacherapproval=Teacher approval :
|
||||
surreq=Are you sure that you want to accept this request ?
|
||||
validate=Validate
|
||||
amount=Amount
|
||||
role=Role
|
||||
manageextcur=Manage external curriculum
|
||||
managecourse=Manage courses
|
||||
manageminerval=Manage school fees
|
||||
enterreason=Please enter the reason you leave
|
||||
onlycursus=I only want to unregister from a specific cursus
|
||||
plsselectcurs=Please select that cursus
|
||||
sureunreg=Are you sure that you want to unregister ?
|
||||
no=No
|
||||
yes=Yes
|
||||
reqsend=Your request has been send !
|
||||
payment=Payment
|
||||
lefttopay=left to pay
|
||||
paydeposit=Pay deposit
|
||||
payrest=Pay all the rest
|
||||
alreadypaid=Payment : School fees have already been paid this year
|
||||
askscholarship=Ask scholarship
|
||||
uploaddocs=Please upload the required documents
|
||||
taxjustdoc=Tax justification document :
|
||||
residencydoc=Residency justification document :
|
||||
reqsent=Your request has been sent to the inscription service.
|
||||
backprofile=Go back to profile
|
||||
procpayment=Proceed to payment of
|
||||
procpaybutton=Process payment
|
||||
rereg=Reregister in the next year of one of my cursus
|
||||
reregsup=Register in a supplementary cursus
|
||||
chcur=Change from a cursus to another
|
||||
iwouldlike=I would like to :
|
||||
newcurr=New curriculum
|
||||
cursusprereq=The cursus you selected has some prerequisites ensure that your external curriculum data is updated in your profile
|
||||
imposecurriculum=Impose a curriculum
|
||||
impose=Impose
|
||||
gotimposed=The selected curriculum has been imposed
|
||||
|
@ -13,13 +13,6 @@ login.guest.lastpage=Derniere Page
|
||||
login.guest.submit=Envoyer
|
||||
login.guest.birthday=DATE DE NAISSANCE
|
||||
login.guest.confirm=CONFIRMER
|
||||
login.guest.browse=Parcourir...
|
||||
login.guest.disclaimer=Si vous êtes déja inscrits dans cette université veuillez vous connecter a votre compte et utilisez les fonctions changer de cursus/réinscription sinon continuez ici.
|
||||
login.guest.identityCard=Carte d'identité :
|
||||
login.guest.attestationdisclaimer=Ce cursus requiert une attestation de réussite d'un examen d'entrée
|
||||
login.guest.formationdisclaimer=Veuillez ajouter vos formations antérieures en y joignant les attestations/diplomes, votre dossier sera vérifié par un membre du service d'inscription.
|
||||
login.guest.managecareer=Gèrer mon parcours extérieur
|
||||
login.guest.sendRegReq=Envoyer la demande d'inscription
|
||||
login.cPassword=Confirmer mot de passe
|
||||
login.password=Mot de passe
|
||||
app.home=Home
|
||||
@ -29,76 +22,15 @@ app.settings=Options
|
||||
app.messages=Messages
|
||||
app.forum=Forum
|
||||
app.schedules=Horaires
|
||||
app.manageSchedules=Gérer les horaires
|
||||
app.inscription.requests=Demandes d'Inscription
|
||||
app.manage.courses=Gérer les cours
|
||||
app.language=Langue
|
||||
app.manage.profile=Gérer le profil
|
||||
app.studentList=Liste des étudiants
|
||||
app.users=Utilisateurs
|
||||
app.manageOwnLessons=Gérer ses horaires de cours
|
||||
app.lessonRequests=Requêtes d'horaire
|
||||
app.payments=Payements
|
||||
request.moreInfos=Plus d'Infos
|
||||
request.accept=Accepter
|
||||
request.refuse=Refuser
|
||||
Pending=En attente
|
||||
Delete=Supprimer
|
||||
Modify=Modifier
|
||||
Create=Créer
|
||||
requestType=Type de Requête
|
||||
day=Jour
|
||||
start=Début
|
||||
end=Fin
|
||||
monday=Lundi
|
||||
tuesday=Mardi
|
||||
wednesday=Mercredi
|
||||
thursday=Jeudi
|
||||
friday=Vendredi
|
||||
saturday=Samedi
|
||||
sunday=Dimanche
|
||||
january=Janvier
|
||||
february=Février
|
||||
march=Mars
|
||||
april=Avril
|
||||
may=Mai
|
||||
june=Juin
|
||||
july=Juillet
|
||||
august=Août
|
||||
september=Septembre
|
||||
october=Octobre
|
||||
november=Novembre
|
||||
december=Decembre
|
||||
Grid=Grille
|
||||
Week=Semaine
|
||||
Month=Mois
|
||||
List=Liste
|
||||
Type=Type
|
||||
Teacher=Professeur
|
||||
Course=Cours
|
||||
TP=TP
|
||||
TD=TD
|
||||
Exam=Exam
|
||||
OwnSchedule=Mon Horaire
|
||||
SwitchToJSON=Afficher le JSON
|
||||
schedule.previous=Précédent
|
||||
schedule.next=Prochain
|
||||
schedule.current=Actuel
|
||||
schedule.settings=Options
|
||||
schedule.courses=Cours
|
||||
schedule.teachers=Professeurs(s)
|
||||
schedule.askChanges=Demander Changement
|
||||
schedule.askCreate=Demander de créer un cours
|
||||
schedule.askDeletion=Demander suppression
|
||||
schedule.createSchedule=Créer Horaire
|
||||
schedule.createLesson=Créer cours
|
||||
schedule.deleteMod=Activer suppression
|
||||
schedule.noDeleteMod=Désactiver suppression
|
||||
schedule=Horaire
|
||||
old_day=Ancien Jour
|
||||
old_start=Ancien Début
|
||||
old_end=Ancienne Fin
|
||||
old_type=Ancien Type
|
||||
courses.createCourse=Créer un cours
|
||||
courses.deleteCourse=Supprimer un cours
|
||||
courses.modify=Modifier
|
||||
@ -120,90 +52,3 @@ Curriculum=Cursus
|
||||
Credits=Credits
|
||||
InscriptionService=S.I.
|
||||
faculty=Faculté
|
||||
forum.create=Créer un forum
|
||||
forum.create.name=Nom du forum
|
||||
forum.post.create.name=Titre du post
|
||||
firstname/name=Prénom/Nom
|
||||
regNo=Matricule
|
||||
From=De
|
||||
To=A
|
||||
WantedCursus=Cursus voulu
|
||||
seeprofile=Voir le profil
|
||||
acceptequiv=Accepter l'équivalence
|
||||
refuseequiv=Refuser l'équivalence
|
||||
course=cours
|
||||
state=état
|
||||
dljustifdoc=Télécharger le justificatif
|
||||
backtoreq=Retour a la requête
|
||||
dlidentitycard=Télécharger la carte d'identité
|
||||
dladmissiondoc=Télécharger le certificat d'admission
|
||||
seeextcur=Voir le parcours extérieur
|
||||
dltaxdoc=Télécharger le justificatif d'impot
|
||||
dlresidency=Télécharger le justificatif de résidence
|
||||
enteramount=Veuillez entrer le montant alloué :
|
||||
oldcursus=Anciens cursus
|
||||
newcursus=Nouveaux cursus
|
||||
year=Année
|
||||
reason=Raison :
|
||||
selectedcursus=Cursus selectionné :
|
||||
askexemp=Demander une dispense
|
||||
exemp=Dispensé
|
||||
uploadjustifdoc=Veuillez soumettre le justificatif
|
||||
subexemreq=Envoyer la demande de dispense
|
||||
addextcurr=Ajouter une formation
|
||||
dldoc=Télécharger le document
|
||||
edit=Modifier
|
||||
delete=Supprimer
|
||||
school=Ecole
|
||||
checkifnotcompleted=Cochez la case si vous n'avez terminé cette formation
|
||||
wichyearstop=En quelle année de la formation vous êtes vous arrété (exemple: 3ème) ?
|
||||
startyear=Année de début
|
||||
endyear=Année de fin
|
||||
giveextcurdoc=Veuillez soumettre un document attestant de ce parcours
|
||||
uploadcurr=Ajouter la formation
|
||||
editcurr=Modifier la formation
|
||||
reqtype=Type de requête :
|
||||
inscription=inscription
|
||||
scholarship=bourse
|
||||
exemption=dispense
|
||||
unregister=désinscription
|
||||
curriculumch=changement de cursus
|
||||
filer=Filtre :
|
||||
approval=Approbation :
|
||||
teacherapproval=Approbation d'un prof :
|
||||
surreq=Etes vous sur de vouloir accepter cette demande ?
|
||||
validate=Valider
|
||||
amount=Montant
|
||||
role=Role
|
||||
manageextcur=Gérer les formations
|
||||
managecourse=Gérer les cours
|
||||
manageminerval=Gérer le minerval
|
||||
enterreason=Veuillez entrer la raison de votre départ
|
||||
onlycursus=Je veux uniquement me désinscrire d'un seul cursus
|
||||
plsselectcurs=Veuillez sélectionner ce cursus
|
||||
sureunreg=Etes-vous sur de vouloir vous désinscrire ?
|
||||
no=Non
|
||||
yes=Oui
|
||||
reqsend=Votre requête a été envoyée !
|
||||
payment=Payement
|
||||
lefttopay=restants a payer
|
||||
paydeposit=Payer l'acompte
|
||||
payrest=Payer le reste
|
||||
alreadypaid=Payement : les frais ont déja été payés cette année
|
||||
askscholarship=Demander une bourse
|
||||
uploaddocs=Veuillez soumettre les documents requis
|
||||
taxjustdoc=Justificatif d'impôts :
|
||||
residencydoc=Justificatif de résidence :
|
||||
reqsent=Votre requête a été envoyée au service d'inscription.
|
||||
backprofile=Retour au profil
|
||||
procpayment=Procéder au payement de
|
||||
procpaybutton=Procéder au payement
|
||||
rereg=Me réinscrire dans l'année supérieure
|
||||
reregsup=M'inscrire dans un cursus supplémentaire
|
||||
chcur=Changer d'un cursus vers un autre
|
||||
iwouldlike=Je voudrais :
|
||||
newcurr=Nouveau cursus
|
||||
cursusprereq=Le cursus que vous avez selectionné a des prérequis assurez vous que votre dossier de parcours est a jour dans votre profil
|
||||
imposecurriculum=Imposer un cursusgotimposed
|
||||
impose=Imposer
|
||||
gotimposed=Le cursus selectionné a été imposé
|
||||
|
@ -25,6 +25,7 @@ window.addEventListener('hashchange', () => {
|
||||
const login=ref(i18n("app.login"))
|
||||
const active=ref(false)
|
||||
|
||||
|
||||
const apps = ref([])
|
||||
appList().then(e => apps.value = e)
|
||||
|
||||
@ -32,6 +33,7 @@ window.addEventListener('hashchange', () => {
|
||||
|
||||
<template>
|
||||
<div class="container">
|
||||
|
||||
<div class="topBar">
|
||||
<ul class="horizontal">
|
||||
<li title=home>
|
||||
@ -50,7 +52,7 @@ window.addEventListener('hashchange', () => {
|
||||
<a class="icon" href="#Notifications">
|
||||
<div class="fa-solid fa-bell" style="margin-top: 7px; margin-bottom: 3px;"></div>
|
||||
</a></li>
|
||||
<li @click="active=!active" class="option"style="float: right;" title=settings>
|
||||
<li @click="active=!active" class="option"style="float: right;" title=settings>
|
||||
<a class="icon" >
|
||||
<div class="fa-solid fa-gear" style="margin-top: 7px; margin-bottom: 3px;"></div>
|
||||
<div v-if="active" class="dropdown">
|
||||
@ -67,6 +69,7 @@ window.addEventListener('hashchange', () => {
|
||||
{{i18n("app.manage.profile")}}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</a></li>
|
||||
</ul>
|
||||
@ -83,9 +86,12 @@ window.addEventListener('hashchange', () => {
|
||||
</ul>
|
||||
</div>
|
||||
<div class="page">
|
||||
<div style=" margin:50px;">
|
||||
<Suspense>
|
||||
<component :is="currentView" />
|
||||
|
||||
<component :is="currentView" />
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -93,22 +99,19 @@ window.addEventListener('hashchange', () => {
|
||||
<style scoped>
|
||||
|
||||
.container{
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display:grid;
|
||||
|
||||
grid-template-columns:[firstCol-start]70px[firstCol-end secondCol-start] auto [endCol];
|
||||
grid-template-rows:[firstRow-start] var(--header-size) [firstRow-end secondRow-start] calc(100% - var(--header-size)) [endRow];
|
||||
grid-template-columns:[firstCol-start]70px[firstCol-end secondCol-start]auto[endCol];
|
||||
grid-template-rows:[firstRow-start]61px[firstRow-end secondRow-start] auto [endRow];
|
||||
grid-template-areas:
|
||||
"topBar topBar"
|
||||
"leftBar page";
|
||||
|
||||
row-gap:0px;
|
||||
column-gap:0px;
|
||||
}
|
||||
|
||||
.page {
|
||||
grid-area:page;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
place-self:center;
|
||||
}
|
||||
|
||||
.topBar{
|
||||
@ -151,7 +154,7 @@ window.addEventListener('hashchange', () => {
|
||||
|
||||
ul.vertical{
|
||||
list-style-type: none;
|
||||
margin-top: var(--header-size);
|
||||
margin-top: 61px;
|
||||
top:0;
|
||||
left:0;
|
||||
padding: 25px 0 0;
|
||||
@ -199,7 +202,7 @@ window.addEventListener('hashchange', () => {
|
||||
left:0;
|
||||
|
||||
position: fixed;
|
||||
height:var(--header-size);
|
||||
height:61px;
|
||||
width: 100%;
|
||||
background-color: rgb(24, 24, 24);
|
||||
}
|
||||
@ -231,7 +234,6 @@ window.addEventListener('hashchange', () => {
|
||||
.text {
|
||||
right: 0%;
|
||||
width: 0%;
|
||||
visibility: collapse;
|
||||
opacity: 0;
|
||||
color: white;
|
||||
font-size: 1.2em;
|
||||
@ -240,8 +242,7 @@ window.addEventListener('hashchange', () => {
|
||||
}
|
||||
|
||||
ul.vertical:hover .text {
|
||||
opacity:1;
|
||||
visibility:visible;
|
||||
opacity: 1;
|
||||
width: 60%;
|
||||
transition-duration: .3s;
|
||||
padding-left: 15px;
|
||||
|
@ -1,215 +0,0 @@
|
||||
<!----------------------------------------------------
|
||||
File: Forums.vue
|
||||
Author: Anthony Debucquoy
|
||||
Scope: Extension messagerie
|
||||
Description: Forum des étudiants
|
||||
----------------------------------------------------->
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import i18n from '@/i18n.js'
|
||||
import { getCourses, getUserActualCourses } from '@/rest/courses.js'
|
||||
import { ForumsOfCurrentCourse, getForumsOfCourse, createForum } from '@/rest/forum.js'
|
||||
import { PostsOfCurrentForum, getPostsOfForum, createPost } from '@/rest/forum.js'
|
||||
import { fetchedPost, fetchPost, sendAnswer } from '@/rest/forum.js'
|
||||
import { getSelf } from '@/rest/Users.js'
|
||||
|
||||
const Role = (await getSelf()).role;
|
||||
const courses = Role === 'Admin' || Role === 'Secretary' ? await reactive(getCourses()) : await reactive(getUserActualCourses());
|
||||
const selectedCourse = ref();
|
||||
const selectedForum = ref();
|
||||
|
||||
const addForumName = ref("");
|
||||
const addPost = ref(false);
|
||||
const addPostSubject = ref("");
|
||||
const addPostContent = ref("");
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="ForumSelector">
|
||||
<select id="cours" value="" v-model="selectedCourse" @change="getForumsOfCourse(selectedCourse)">
|
||||
<option v-for="course in courses" :value="course.courseID">{{course.title}}</option>
|
||||
</select>
|
||||
|
||||
<select id="forum" value="" v-model="selectedForum" @change="getPostsOfForum(selectedForum !== 'create' ? selectedForum : null)" v-if="ForumsOfCurrentCourse != null">
|
||||
<option v-for="forum in ForumsOfCurrentCourse" :value=forum.id>{{forum.name}}</option>
|
||||
<option v-if="(Role === 'Admin' || Role === 'Teacher') && ForumsOfCurrentCourse != null" value="create">{{ i18n("forum.create") }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="PostSelector" v-if="PostsOfCurrentForum != null">
|
||||
<div @click="fetchPost(post.id)" class="postItem" v-for="post in PostsOfCurrentForum" :key="post.id">{{ post.subject }}</div>
|
||||
<button v-if="Role === 'Admin' || Role === 'Teacher' " id="createPost" @click="addPost = true">+</button>
|
||||
</div>
|
||||
<div id="PostViewer" v-if="fetchedPost != null">
|
||||
<div id="Post">
|
||||
<h1>{{ fetchedPost.subject }}</h1>
|
||||
{{fetchedPost.content}}
|
||||
</div>
|
||||
<div id="Messages">
|
||||
<p v-for="msg in fetchedPost.answers">{{msg.author.firtName}} {{msg.author.lastName}} - {{msg.content}}</p>
|
||||
<input v-if=!fetchedPost.locked type="text" placeholder="response" @keyup.enter="sendAnswer(fetchedPost.id, $event.target.value); $event.target.value = ''"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=popup v-if="selectedForum === 'create' || addPost" @click.self="selectedForum = ''; addPost = false" >
|
||||
|
||||
<!-- Popup to add forum -->
|
||||
<div id="addForumForm" v-if="selectedForum === 'create'" @keyup.enter="createForum(selectedCourse, addForumName); selectedForum = '';">
|
||||
<label>{{ i18n("forum.create.name") }}</label>
|
||||
<input type="text" placeholder="Name" v-model=addForumName />
|
||||
</div>
|
||||
|
||||
<!-- Popup to add Post -->
|
||||
<div id="addPostForm" v-if=addPost>
|
||||
<label>{{ i18n("forum.post.create.name") }}</label>
|
||||
<input type="text" placeholder="subject" v-model=addPostSubject @keyup.enter="createPost(selectedForum, addPostSubject, addPostContent); addPost = false;"/>
|
||||
<textarea v-model="addPostContent" placeholder=content></textarea>
|
||||
<input type="submit" value="send" @click="createPost(selectedForum, addPostSubject, addPostContent); addPost = false;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.popup{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #00000022;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
#addForumForm{
|
||||
position: relative;
|
||||
width: 30%;
|
||||
left: calc(50% - 30% / 2);
|
||||
top: calc(50% - 10% / 2);
|
||||
border-radius: 10px;
|
||||
height: 10%;
|
||||
background-color: white;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#addPostForm{
|
||||
position: relative;
|
||||
width: 30%;
|
||||
left: calc(50% - 30% / 2);
|
||||
top: calc(50% - 50% / 2);
|
||||
border-radius: 10px;
|
||||
height: 50%;
|
||||
background-color: white;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#app{
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
grid-template: 5em auto / 25% 75%;
|
||||
}
|
||||
|
||||
#ForumSelector{
|
||||
background-color: #FFFFFF0E;
|
||||
grid-column: 1 / 3;
|
||||
border-radius: 100px;
|
||||
margin: 10px;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
#ForumSelector select{
|
||||
background-color: #ffa000;
|
||||
border: none;
|
||||
margin: 10px;
|
||||
border-radius: 10px;
|
||||
width: 200px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#PostSelector button{
|
||||
background-color: green;
|
||||
color: white;
|
||||
border: none;
|
||||
height: 4vh;
|
||||
margin: 5px;
|
||||
border-radius: 0 30px 30px 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#PostSelector{
|
||||
background-color: #FFFFFF0E;
|
||||
border-radius: 0 25px 25px 0;
|
||||
margin: 10px 0 10px 10px;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
}
|
||||
|
||||
.postItem{
|
||||
color: darkorange;
|
||||
display: flex;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
height: 4vh;
|
||||
margin: 5px;
|
||||
border-radius: 0 30px 30px 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid darkorange;
|
||||
}
|
||||
|
||||
.postItem:hover{
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
#PostViewer{
|
||||
background-color: #FFFFFF0E;
|
||||
border-radius: 25px;
|
||||
margin: 10px;
|
||||
|
||||
max-height: 100%;
|
||||
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
#Post{
|
||||
padding: 25px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#Post > h1{
|
||||
text-align: center;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#Messages{
|
||||
padding: 25px;
|
||||
border-top: 3px dotted white;
|
||||
|
||||
}
|
||||
|
||||
#Messages > p {
|
||||
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
113
frontend/src/Apps/Inscription.vue
Normal file
113
frontend/src/Apps/Inscription.vue
Normal file
@ -0,0 +1,113 @@
|
||||
<script setup>
|
||||
import i18n from "@/i18n.js"
|
||||
import {ref} from 'vue'
|
||||
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
||||
|
||||
const requests = ref(await getAllRegisters());
|
||||
console.log(requests);
|
||||
|
||||
async function upPage(id,review){
|
||||
await validateRegister(id,review);
|
||||
requests.value = await getAllRegisters();
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
<div v-for="item of requests">
|
||||
<div class="bodu" v-if="item.state === 'Pending'">
|
||||
<div class="container">
|
||||
|
||||
<div class="id"><a>{{item.id}}</a></div>
|
||||
<div class="surname"><a>{{item.lastName}}</a></div>
|
||||
<div class="firstname"><a>{{item.firstName}}</a></div>
|
||||
<div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}}</button></div>
|
||||
<div class="accept"><button @click="upPage(item.id,'Accepted')" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
|
||||
<div class="refuse"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
color:white;
|
||||
height:100px;
|
||||
font-size:20px;
|
||||
display:grid;
|
||||
grid-template-columns:[firstCol-start]100px[firstCol-end secondCol-start]150px[secondCol-end thirdCol-start]200px[thirdCol-end fourthCol-start]150px[fourthCol-end]150px[fifthCol-end]150px[sixthCol-end]150px[endCol];
|
||||
grid-template-areas:
|
||||
"id type surname firstname infos accept refuse";
|
||||
column-gap:10px;
|
||||
|
||||
}
|
||||
|
||||
.infos {
|
||||
grid-area:infos;
|
||||
align-self:center;
|
||||
}
|
||||
|
||||
.accept{
|
||||
grid-area:accept;
|
||||
align-self:center;
|
||||
}
|
||||
|
||||
.refuse{
|
||||
grid-area:refuse;
|
||||
align-self:center;
|
||||
}
|
||||
|
||||
.titles {
|
||||
grid-area:titles;
|
||||
background-color:rgb(215,215,215);
|
||||
}
|
||||
.id{
|
||||
grid-area:id;
|
||||
margin-left:40px;
|
||||
align-self:center;
|
||||
}
|
||||
|
||||
.type{
|
||||
grid-area:type;
|
||||
align-self:center;
|
||||
}
|
||||
|
||||
.surname{
|
||||
grid-area:surname;
|
||||
align-self:center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
}
|
||||
|
||||
.firstname{
|
||||
grid-area:firstname;
|
||||
align-self:center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
}
|
||||
|
||||
button{
|
||||
font-size:15px;
|
||||
height:50px;
|
||||
width:100px;
|
||||
border:none;
|
||||
border-radius:20px;
|
||||
|
||||
}
|
||||
|
||||
.bodu {
|
||||
width:100%;
|
||||
margin-bottom:10px;
|
||||
border:2px solid black;
|
||||
border-radius:9px;
|
||||
background-color:rgb(50,50,50);
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
|
@ -1,121 +0,0 @@
|
||||
<script setup>
|
||||
|
||||
import {
|
||||
editChangeCurrReq, editChangeCurrReqTeacherState,
|
||||
getChangeCurrReqById,
|
||||
} from "@/rest/requests.js";
|
||||
import i18n from "@/i18n.js";
|
||||
import {getSelf} from "@/rest/Users.js";
|
||||
import {ref} from "vue";
|
||||
import AboutStudent from "@/Apps/Inscription/AboutStudent.vue";
|
||||
|
||||
const props = defineProps(["reqId"])
|
||||
const req = ref(await getChangeCurrReqById(props.reqId))
|
||||
|
||||
const user = await getSelf()
|
||||
//0 liste, 1 profil
|
||||
const localwindowstate = ref(0);
|
||||
|
||||
const tag = req.value.user.regNo
|
||||
|
||||
const windowState = defineModel("windowState")
|
||||
|
||||
async function uploadandrefreshChangeRequest(state){
|
||||
await editChangeCurrReq(req.value.id, state);
|
||||
}
|
||||
|
||||
async function editChangeCurrReqTeacherApproval(state){
|
||||
await editChangeCurrReqTeacherState(req.value.id, state)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="body" v-if="localwindowstate === 0">
|
||||
<div class="container">
|
||||
<div class="globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
{{i18n("firstname/name")}} : {{req.user.firstName}} {{req.user.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
{{i18n("regNo")}} : {{req.user.regNo}}
|
||||
</div>
|
||||
<div v-if="req.actualCurriculum !== null">
|
||||
{{i18n("From")}} : Bac {{req.actualCurriculum.year}} {{req.actualCurriculum.option}}
|
||||
{{i18n("To")}} : Bac {{req.destinationCurriculum.year}} {{req.destinationCurriculum.option}}
|
||||
</div>
|
||||
<div v-else>
|
||||
{{i18n("WantedCursus")}} : Bac {{req.destinationCurriculum.year}} {{req.destinationCurriculum.option}}
|
||||
</div>
|
||||
<div>
|
||||
<button @click="localwindowstate++"> {{ i18n("seeprofile") }} </button>
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Accepted';uploadandrefreshChangeRequest('Accepted')">{{ i18n("request.accept") }}</button>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Refused';uploadandrefreshChangeRequest('Refused')" style="margin-left: 2%;">{{i18n("request.refuse")}}</button>
|
||||
</div>
|
||||
<div v-if="user.role === 'Teacher' || user.role === 'Admin'">
|
||||
<button v-if="req.teacherApprovalState === 'Pending'" @click="req.teacherApprovalState='Accepted';editChangeCurrReqTeacherApproval('Accepted')">{{i18n("acceptequiv")}}</button>
|
||||
<button v-if="req.teacherApprovalState === 'Pending'" @click="req.teacherApprovalState='Refused';editChangeCurrReqTeacherApproval('Refused')">{{i18n("refuseequiv")}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="localwindowstate === 0" style="margin-left: 23%">
|
||||
<button @click="windowState = 0" style="margin-left: 10%">{{ i18n("courses.back") }}</button>
|
||||
</div>
|
||||
<div v-if="localwindowstate === 1">
|
||||
<AboutStudent :target="tag"></AboutStudent>
|
||||
<button @click="localwindowstate--;" style="margin-left: 10%">{{ i18n("courses.back") }}</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos"
|
||||
"minfos minfos";
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:7%;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
min-width:350px;
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
|
||||
button{
|
||||
border:none;
|
||||
background-color:rgb(239, 60, 168);
|
||||
border-radius:10px;
|
||||
height:35px;
|
||||
margin-top:10px;
|
||||
}
|
||||
</style>
|
@ -1,108 +0,0 @@
|
||||
<script setup>
|
||||
|
||||
import {
|
||||
editExempReqState,
|
||||
getExempReq,
|
||||
} from "@/rest/requests.js";
|
||||
import i18n from "@/i18n.js";
|
||||
import {ref} from "vue";
|
||||
import AboutStudent from "@/Apps/Inscription/AboutStudent.vue";
|
||||
|
||||
const props = defineProps(["reqId"])
|
||||
|
||||
const req = ref(await getExempReq(props.reqId))
|
||||
|
||||
const profile = ref(false)
|
||||
|
||||
const windowState = defineModel("windowState")
|
||||
|
||||
async function editExemp(newstate){
|
||||
await editExempReqState(req.value.id, newstate)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="body" v-if="profile === false">
|
||||
<div class="container">
|
||||
<div class="globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
{{ i18n("firstname/name") }} : {{req.user.firstName}} {{req.user.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("course") }}: {{req.course.title}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("state") }} : {{req.state}}
|
||||
</div>
|
||||
<div>
|
||||
<button @click="profile = !profile">{{ i18n("seeprofile") }}</button>
|
||||
</div>
|
||||
<div>
|
||||
<button><a :href="req.justifDocument">{{ i18n("dljustifdoc") }}</a></button>
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Accepted';editExemp('Accepted')">{{ i18n("request.accept") }}</button>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Refused';editExemp('Refused')" style="margin-left: 2%;">{{ i18n("request.refuse") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<AboutStudent :target="req.user.regNo"></AboutStudent>
|
||||
<button @click="profile=!profile" style="margin-left: 17%;margin-top: 3%">{{ i18n("backtoreq") }}</button>
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="profile===false" @click="windowState = 0" style="margin-left: 31%">{{ i18n("courses.back") }}</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos"
|
||||
"minfos minfos";
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:7%;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
min-width:350px;
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
|
||||
button{
|
||||
border:none;
|
||||
background-color:rgb(239, 60, 168);
|
||||
border-radius:10px;
|
||||
height:35px;
|
||||
margin-top:10px;
|
||||
}
|
||||
</style>
|
@ -1,159 +0,0 @@
|
||||
<script setup>
|
||||
import i18n from "@/i18n.js"
|
||||
import {getSelf} from '../../rest/Users.js'
|
||||
import {getAllCurriculums, getcurriculum} from "@/rest/curriculum.js";
|
||||
import {getRegisters} from "@/rest/ServiceInscription.js";
|
||||
import {getExternalCurriculumByInscrReq} from "@/rest/externalCurriculum.js";
|
||||
import {ref} from "vue";
|
||||
import ExternalCurriculumList from "@/Apps/Inscription/ExternalCurriculumList.vue";
|
||||
import {editEquivalenceState, imposeCurriculum} from "@/rest/requests.js";
|
||||
|
||||
const curriculums = await getAllCurriculums()
|
||||
const props = defineProps(['target']);
|
||||
const request = await getRegisters(props.target);
|
||||
const cursus = await getcurriculum(request.curriculum);
|
||||
const user = await getSelf();
|
||||
const list = ref(false);
|
||||
const externalCurriculum = await getExternalCurriculumByInscrReq(request.id)
|
||||
const impose = ref(false)
|
||||
const imposeCurr = ref(0)
|
||||
const imposed = ref(false)
|
||||
|
||||
//Get the parent page windowState to display the correct button
|
||||
const windowState = defineModel("windowState")
|
||||
function getPP(){
|
||||
if(request.profilePictureUrl === null){
|
||||
return "/Clyde.png"
|
||||
}
|
||||
return request.profilePictureUrl;
|
||||
}
|
||||
|
||||
async function editEquivalence(id, newstate){
|
||||
await editEquivalenceState(id, newstate)
|
||||
}
|
||||
|
||||
async function refreshCursus(){
|
||||
cursus.value = await getcurriculum(request.curriculum)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="body" v-if="list == false" style="margin-top: 10%;">
|
||||
<div class="container">
|
||||
<div class="profilPic">
|
||||
<img class="subContainter" :src=getPP()>
|
||||
</div>
|
||||
<div class = "globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
{{ i18n("firstname/name") }} : {{request.firstName}} {{request.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.email") }}: {{request.email}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.address") }} : {{request.address}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.country") }} : {{request.country}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.birthday") }} : {{request.birthDate}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("WantedCursus") }} : BAB {{cursus.year}} {{cursus.option}}
|
||||
</div>
|
||||
<div style="margin-top: 3%">
|
||||
<button><a :href="request.identityCard">{{ i18n("dlidentitycard") }}</a></button>
|
||||
<button v-if="request.admissionDocUrl != null"><a :href="request.admissionDocUrl">{{ i18n("dladmissiondoc") }}</a></button>
|
||||
</div>
|
||||
<div v-if="externalCurriculum.length !== 0">
|
||||
<button style="background-color:rgb(105,05,105);margin-top: 3%" @click="list=!list" v-if="(user.role == 'Teacher' || user.role == 'Admin')">{{ i18n("seeextcur") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="list == false" style="margin-left: 30%; margin-top: 5%">
|
||||
<button @click="windowState = 0">{{ i18n("courses.back") }}</button>
|
||||
</div>
|
||||
<div v-if="list==true">
|
||||
<ExternalCurriculumList :ext-curr-list="externalCurriculum" :mode="0"></ExternalCurriculumList>
|
||||
<div style="margin-left: 15%;margin-top: 5%;">
|
||||
<button style="margin-left: 2%" v-if="request.equivalenceState === 'Pending' && !impose" @click="list = false;editEquivalence(request.id, 'Accepted'); request.equivalenceState='Accepted'">{{i18n("acceptequiv")}}</button>
|
||||
<button style="margin-left: 2%;margin-right: 3%" v-if="request.equivalenceState === 'Pending' && !impose" @click="list = false;editEquivalence(request.id, 'Refused'); request.equivalenceState='Refused'">{{i18n("refuseequiv")}}</button>
|
||||
<div v-if="!imposed && request.equivalenceState !== 'Accepted'" style="margin-top: 3%;margin-left: 1%">
|
||||
{{i18n("imposecurriculum")}}
|
||||
<input type="checkbox" v-model="impose" v-if="!imposed">
|
||||
<select v-if="impose" v-model="imposeCurr">
|
||||
<option v-for="item in curriculums" :value="item.curriculumId">Bac {{item.year}} {{item.option}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<button v-if="impose && !imposed" style="margin-left: 2%" @click="imposeCurriculum(request.id, imposeCurr);request.equivalenceState='Accepted';imposed=true;">{{ i18n("impose") }}</button>
|
||||
<div v-if="imposed">
|
||||
{{ i18n("gotimposed") }}
|
||||
</div>
|
||||
<button style="margin-left: 2%" @click="list=false;refreshCursus()">{{ i18n("courses.back") }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos"
|
||||
"minfos minfos";
|
||||
}
|
||||
|
||||
.profilPic{
|
||||
grid-area:profilPic;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:5%;
|
||||
}
|
||||
|
||||
.subContainter{
|
||||
width:100%;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
border:4px solid black;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
|
||||
button{
|
||||
border:none;
|
||||
background-color:rgb(239, 60, 168);
|
||||
border-radius:10px;
|
||||
height:35px;
|
||||
margin-top:10px;
|
||||
}
|
||||
</style>
|
@ -1,131 +0,0 @@
|
||||
<script setup>
|
||||
|
||||
import {editScholarshipReq, getScholarshipReqById} from "@/rest/requests.js";
|
||||
import i18n from "@/i18n.js";
|
||||
import {reactive, ref} from "vue";
|
||||
|
||||
const props = defineProps(["reqId"])
|
||||
const req = ref(await getScholarshipReqById(props.reqId))
|
||||
|
||||
const user = req.value.user;
|
||||
|
||||
const scholarshipData = reactive({
|
||||
amount : 0,
|
||||
id : req.value.id,
|
||||
state : ""
|
||||
})
|
||||
|
||||
function getPP(){
|
||||
if(user.profilePictureUrl === null){
|
||||
return "/Clyde.png"
|
||||
}
|
||||
return user.profilePictureUrl
|
||||
}
|
||||
|
||||
async function uploadandrefreshScholarshipRequest(){
|
||||
await editScholarshipReq(scholarshipData);
|
||||
req.value = await getScholarshipReqById(props.reqId);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="body">
|
||||
<div class="container">
|
||||
<div class="profilPic">
|
||||
<img class="subContainter" :src=getPP()>
|
||||
</div>
|
||||
<div class="globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
{{ i18n("firstname/name") }} : {{user.firstName}} {{user.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.email") }}: {{user.email}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.address") }} : {{user.address}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.country") }} : {{user.country}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.birthday") }} : {{user.birthDate.slice(0,10)}}
|
||||
</div>
|
||||
<div>
|
||||
<button><a :href="req.taxDocUrl">{{ i18n("dltaxdoc") }}</a></button>
|
||||
<button style="margin-left: 2%"><a :href="req.residencyDocUrl">{{ i18n("dlresidency") }}</a></button>
|
||||
</div>
|
||||
<div v-if="req.state == 'Pending'" style="margin-top: 2%; margin-bottom: 2%;">
|
||||
{{i18n("enteramount")}}
|
||||
<input type="number" v-model="scholarshipData.amount">
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="req.state === 'Pending'" @click="scholarshipData.state='Accepted';uploadandrefreshScholarshipRequest()">{{i18n("request.accept")}}</button>
|
||||
<button v-if="req.state === 'Pending'" @click="scholarshipData.state='Refused';uploadandrefreshScholarshipRequest()" style="margin-left: 2%;">{{i18n("request.refuse")}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos"
|
||||
"minfos minfos";
|
||||
}
|
||||
|
||||
.profilPic{
|
||||
width:100%;
|
||||
grid-area:profilPic;
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:10%;
|
||||
}
|
||||
|
||||
.subContainter{
|
||||
width:100%;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
border:4px solid black;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
min-width:350px;
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
|
||||
button{
|
||||
border:none;
|
||||
background-color:rgb(239, 60, 168);
|
||||
border-radius:10px;
|
||||
height:35px;
|
||||
margin-top:10px;
|
||||
}
|
||||
</style>
|
@ -1,191 +0,0 @@
|
||||
<script setup>
|
||||
import i18n from "@/i18n.js"
|
||||
import {getSelf, getUser} from '../../rest/Users.js'
|
||||
import {getSomeonesCurriculumList} from "@/rest/curriculum.js";
|
||||
import {ref} from "vue";
|
||||
import ExternalCurriculumList from "@/Apps/Inscription/ExternalCurriculumList.vue";
|
||||
import {getExternalCurriculumByUser} from "@/rest/externalCurriculum.js";
|
||||
|
||||
const props = defineProps(['target'])
|
||||
const user = await getUser(props.target)
|
||||
const UserCurriculum = await getSomeonesCurriculumList(props.target)
|
||||
const externalcurrlist = await getExternalCurriculumByUser(user.regNo)
|
||||
const extercurrlist = ref(false)
|
||||
|
||||
const watchingUser = await getSelf()
|
||||
function getPP(){
|
||||
if(user.profilePictureUrl === null){
|
||||
return "/Clyde.png"
|
||||
}
|
||||
return user.profilePictureUrl
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="body" v-if="extercurrlist==false">
|
||||
<div class="container">
|
||||
<div class="profilPic">
|
||||
<img class="subContainter" :src=getPP()>
|
||||
</div>
|
||||
<div class = "globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
{{ i18n("firstname/name") }} : {{user.firstName}} {{user.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.email") }}: {{user.email}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.address") }} : {{user.address}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.country") }} : {{user.country}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.birthday") }} : {{user.birthDate}}
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="watchingUser.role === 'Admin' || watchingUser.role === 'InscriptionService' || watchingUser.role === 'Secretary' || watchingUser.regNo === user.regNo"><a :href="user.identityCard">{{i18n("dlidentitycard")}}</a></button>
|
||||
</div>
|
||||
<div>
|
||||
<button @click="extercurrlist=!extercurrlist">{{i18n("seeextcur")}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="moreInfos" style="margin-top: 15%">
|
||||
<div class = "oldcursus">
|
||||
<div class="listTitle">
|
||||
{{ i18n("oldcursus") }}
|
||||
</div>
|
||||
<div class="listElement">
|
||||
<div class=" containerElement" v-for="item in UserCurriculum.curriculumList">
|
||||
<div class="year" v-if="item.actual === false">Bac {{item.year}}</div>
|
||||
<div class="option" v-if="item.actual === false">{{item.option}}</div>
|
||||
<div class="dateyear" v-if="item.actual === false">{{ i18n("year") }} {{item.dateyear}}-{{item.dateyear+1}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="newcursus">
|
||||
<div class="listTitle">
|
||||
{{ i18n("newcursus") }}
|
||||
</div>
|
||||
<div class="listElement">
|
||||
<div class=" containerElement" v-for="item in UserCurriculum.curriculumList" >
|
||||
<div class="year" v-if="item.actual === true">Bac {{item.year}}</div>
|
||||
<div class="option" v-if="item.actual === true">{{item.option}}</div>
|
||||
<div class="dateyear" v-if="item.actual === true">{{ i18n("year") }} {{item.dateyear}}-{{item.dateyear+1}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="extercurrlist==true">
|
||||
<ExternalCurriculumList :ext-curr-list="externalcurrlist" :mode="1"></ExternalCurriculumList>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos";
|
||||
}
|
||||
|
||||
.profilPic{
|
||||
grid-area:profilPic;
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:5%;
|
||||
}
|
||||
|
||||
.subContainter{
|
||||
width:100%;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
border:4px solid black;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
|
||||
.moreInfos {
|
||||
display:inline-grid;
|
||||
column-gap:50px;
|
||||
grid-template-areas:
|
||||
"oldcursus newcursus";
|
||||
grid-template-columns:600px 600px;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-left: 320%;
|
||||
}
|
||||
|
||||
.listTitle{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width:250px;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;margin-bottom:10px;
|
||||
}
|
||||
|
||||
.listElement{
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
.containerElement{
|
||||
justify-content:center;
|
||||
display:grid;
|
||||
grid-template-columns:100px 100px 300px;
|
||||
grid-template-areas:
|
||||
"year option dateyear";
|
||||
column-gap:40px;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
button{
|
||||
border:none;
|
||||
background-color:rgb(239, 60, 168);
|
||||
border-radius:10px;
|
||||
height:35px;
|
||||
margin-top:10px;
|
||||
}
|
||||
</style>
|
@ -1,85 +0,0 @@
|
||||
<script setup>
|
||||
|
||||
import {
|
||||
editUnregReq,
|
||||
getUnregisterbyId
|
||||
} from "@/rest/requests.js";
|
||||
import i18n from "@/i18n.js";
|
||||
import {ref} from "vue";
|
||||
|
||||
const props = defineProps(["reqId"])
|
||||
const req = ref(await getUnregisterbyId(props.reqId))
|
||||
|
||||
async function uploadandrefreshUnregRequest(state){
|
||||
await editUnregReq(req.value.id, state)
|
||||
req.value.state = state
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="body">
|
||||
<div class="container">
|
||||
<div class="globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
{{ i18n("firstname/name") }} : {{req.firstName}} {{req.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("login.guest.email") }}: {{req.email}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("regNo") }} : {{req.regNo}}
|
||||
</div>
|
||||
<div>
|
||||
{{ i18n("reason") }}
|
||||
<input type="text" v-model="req.reason" readonly/>
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Accepted';uploadandrefreshUnregRequest('Accepted')">{{i18n("request.accept")}}</button>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Refused';uploadandrefreshUnregRequest('Refused')" style="margin-left: 2%;">{{i18n("request.refuse")}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos"
|
||||
"minfos minfos";
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:7%;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
min-width:350px;
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
</style>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user