feat: switch to a service layer architecture
This commit is contained in:
@ -0,0 +1,95 @@
|
||||
package enseirb.myinpulse.controller;
|
||||
|
||||
import enseirb.myinpulse.model.*;
|
||||
import enseirb.myinpulse.service.AdminApiService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class AdminApi {
|
||||
|
||||
private final AdminApiService adminApiService;
|
||||
|
||||
@Autowired
|
||||
AdminApi(AdminApiService adminApiService) {
|
||||
this.adminApiService = adminApiService;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: description
|
||||
*
|
||||
* @return a list of all project managed by the current admin user
|
||||
*/
|
||||
@GetMapping("/admin/projects")
|
||||
public Iterable<Administrateurs> getProjects() {
|
||||
return adminApiService.getProjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Why in admin instead of shared ? + desc
|
||||
*
|
||||
* @return a list of upcoming appointments for the current user
|
||||
*/
|
||||
@GetMapping("/admin/appointments/upcoming")
|
||||
public Iterable<Appointment> getUpcomingAppointments() {
|
||||
return adminApiService.getUpcomingAppointments();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: description
|
||||
*
|
||||
* @return a list of current unvalidated projects, waiting to be accepted
|
||||
*/
|
||||
@GetMapping("/admin/projects/pending")
|
||||
public Iterable<Project> getPendingProjects() {
|
||||
return adminApiService.getPendingProjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint used to make a decision about a project.
|
||||
*
|
||||
* @return the status code of the request
|
||||
*/
|
||||
@PostMapping("/admin/projects/decision")
|
||||
public void validateProject(@RequestBody ProjectDecision decision) {
|
||||
adminApiService.validateProject(decision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint used to manually add a project by an admin
|
||||
*
|
||||
* @return the status code of the request
|
||||
*/
|
||||
@PostMapping("/admin/project/add")
|
||||
public void addNewProject(@RequestBody Project project) {
|
||||
adminApiService.addNewProject(project);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: shouldn't it be an PUT request ? / What is the rerun type
|
||||
*
|
||||
* <p>Endpoint used to add a new report to an appointment
|
||||
*
|
||||
* @return the status code of the request
|
||||
*/
|
||||
@PostMapping("/admin/appoitements/report/{appointmentId}")
|
||||
public void createAppointmentReport(
|
||||
@PathVariable String appointmentId, @RequestBody Report report) {
|
||||
adminApiService.createAppointmentReport(appointmentId, report);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Shouldn't a project be kept in history ? 2 different endpoints ?
|
||||
*
|
||||
* <p>Endpoint used to completely remove a project.
|
||||
*
|
||||
* @return the status code of the request
|
||||
*/
|
||||
@DeleteMapping("/admin/projects/remove/{projectId}")
|
||||
public void deleteProject(@PathVariable String projectId) {
|
||||
adminApiService.deleteProject(projectId);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user