feat: switch to a service layer architecture
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user