Fix: merge
All checks were successful
Format / formatting (push) Successful in 7s
CI / build (push) Successful in 11s

This commit is contained in:
Théo Le Lez
2025-02-19 18:52:43 +01:00
6 changed files with 77 additions and 57 deletions

View File

@ -1,13 +1,12 @@
package enseirb.myinpulse.controller;
import enseirb.myinpulse.model.Administrator;
import enseirb.myinpulse.model.DelAppointment;
import enseirb.myinpulse.model.Entrepreneur;
import enseirb.myinpulse.model.SectionCell;
import enseirb.myinpulse.model.*;
import enseirb.myinpulse.service.SharedApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@ -34,8 +33,10 @@ public class SharedApi {
public Iterable<SectionCell> getLCSection(
@PathVariable("projectId") String projectId,
@PathVariable("title") String title,
@PathVariable("date") String date) {
return sharedApiService.getLCSection(projectId, title, date);
@PathVariable("date") String date,
@AuthenticationPrincipal Jwt principal) {
return sharedApiService.getLCSection(
projectId, title, date, principal.getClaimAsString("email"));
}
/**
@ -44,34 +45,33 @@ public class SharedApi {
* @return a list of all entrepreneurs in a project
*/
@GetMapping("/shared/entrepreneurs/{projectId}")
public Iterable<Entrepreneur> getEntrepreneursByProjectId(@PathVariable int projectId) {
return sharedApiService.getEntrepreneursByProjectId(projectId);
public Iterable<Entrepreneur> getEntrepreneursByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getEntrepreneursByProjectId(
projectId, principal.getClaimAsString("email"));
}
/**
* TODO: is it really useful for the admin ? We can already get all the project of the current
* administrator.
*
* <p>Endpoint used to get the administrator of a project.
* Endpoint used to get the administrator of a project.
*
* @return a list of all project managed by the current admin user
*/
@GetMapping("/shared/projects/admin/{projectId}")
public Iterable<Administrator> getAdminByProjectId(@PathVariable int projectId) {
return sharedApiService.getAdminByProjectId(projectId);
public Iterable<Administrator> getAdminByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getAdminByProjectId(projectId, principal.getClaimAsString("email"));
}
/**
* TODO: Should it really be all appointments? all future appointments ? a flag to choose \\
* TODO: between both ?
*
* <p>Endpoint used to get all appointments of a single project.
* Endpoint used to get all appointments of a single project.
*
* @return a list of all appointments.
*/
@GetMapping("/shared/projects/appointments/{projectId}")
public Iterable<DelAppointment> getAppointmentsByProjectId(@PathVariable int projectId) {
return sharedApiService.getAppointmentsByProjectId(projectId);
public Iterable<Appointment> getAppointmentsByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getAppointmentsByProjectId(
projectId, principal.getClaimAsString("email"));
}
/**
@ -80,17 +80,17 @@ public class SharedApi {
* @return a PDF file? TODO: how does that works ?
*/
@GetMapping("/shared/projects/appointments/report/{appointmentId}")
public void getPDFReport(@PathVariable int appointmentId) {
sharedApiService.getPDFReport(appointmentId);
public void getPDFReport(
@PathVariable int appointmentId, @AuthenticationPrincipal Jwt principal) {
sharedApiService.getPDFReport(appointmentId, principal.getClaimAsString("email"));
}
/**
* TODO
*
* @return TODO
*/
@PostMapping("/shared/appointment/request")
public void createAppointmentRequest(@RequestBody DelAppointment appointment) {
sharedApiService.createAppointmentRequest(appointment);
public void createAppointmentRequest(
@RequestBody Appointment appointment, @AuthenticationPrincipal Jwt principal) {
sharedApiService.createAppointmentRequest(appointment, principal.getClaimAsString("email"));
}
}