feat: switch to a service layer architecture
All checks were successful
Format / formatting (push) Successful in 6s
CI / build (push) Successful in 11s

This commit is contained in:
Pierre Tellier
2025-02-18 22:15:14 +01:00
parent 11ab5e1dc4
commit 04a73073c1
42 changed files with 1295 additions and 1146 deletions

View File

@ -0,0 +1,96 @@
package enseirb.myinpulse.controller;
import enseirb.myinpulse.model.Administrateurs;
import enseirb.myinpulse.model.Appointment;
import enseirb.myinpulse.model.Entrepreneurs;
import enseirb.myinpulse.model.Sections;
import enseirb.myinpulse.service.SharedApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@RestController
public class SharedApi {
private final SharedApiService sharedApiService;
@Autowired
SharedApi(SharedApiService sharedApiService) {
this.sharedApiService = sharedApiService;
}
/**
* TODO: It does not looks like a good id to have the title and the date in the url. What even
* TODO: is the title btw ? if this is the LC section, wouldn't it be better to use an ID ?
* TODO: choose return type, cf comment in LCSection
*
* <p>Endpoint used to get the data inside the lean canvas
*
* @return a list of lean canvas sections
*/
@GetMapping("/shared/project/lcsection/{projectId}/{title}/{date}")
public Iterable<Sections> getLCSection(
@PathVariable("projectId") String projectId,
@PathVariable("title") String title,
@PathVariable("date") String date) {
return sharedApiService.getLCSection(projectId, title, date);
}
/**
* Endpoint used to get entrepreneurs details
*
* @return a list of all entrepreneurs in a project
*/
@GetMapping("/shared/entrepreneurs/{projectId}")
public Iterable<Entrepreneurs> getEntrepreneursByProjectId(@PathVariable int projectId) {
return sharedApiService.getEntrepreneursByProjectId(projectId);
}
/**
* 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.
*
* @return a list of all project managed by the current admin user
*/
@GetMapping("/shared/projects/admin/{projectId}")
public Iterable<Administrateurs> getAdminByProjectId(@PathVariable int projectId) {
return sharedApiService.getAdminByProjectId(projectId);
}
/**
* 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.
*
* @return a list of all appointments.
*/
@GetMapping("/shared/projects/appointments/{projectId}")
public Iterable<Appointment> getAppointmentsByProjectId(@PathVariable int projectId) {
return sharedApiService.getAppointmentsByProjectId(projectId);
}
/**
* Endpoint used to generate a PDF report
*
* @return a PDF file? TODO: how does that works ?
*/
@GetMapping("/shared/projects/appointments/report/{appointmentId}")
public void getPDFReport(@PathVariable int appointmentId) {
sharedApiService.getPDFReport(appointmentId);
}
/**
* TODO
*
* @return TODO
*/
@PostMapping("/shared/appointment/request")
public void createAppointmentRequest(@RequestBody Appointment appointment) {
sharedApiService.createAppointmentRequest(appointment);
}
}