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);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package enseirb.myinpulse.controller;
|
||||
|
||||
import enseirb.myinpulse.model.LCSection;
|
||||
import enseirb.myinpulse.model.Project;
|
||||
import enseirb.myinpulse.service.EntrepreneurApiService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
public class EntrepreneurApi {
|
||||
|
||||
private final EntrepreneurApiService entrepreneurApiService;
|
||||
|
||||
@Autowired
|
||||
EntrepreneurApi(EntrepreneurApiService entrepreneurApiService) {
|
||||
this.entrepreneurApiService = entrepreneurApiService;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: check return type
|
||||
*
|
||||
* <p>Endpoint used to update a LC section.
|
||||
*
|
||||
* @return status code
|
||||
*/
|
||||
@PutMapping("/entrepreneur/lcsection/modify/{sectionId}")
|
||||
public void editLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {
|
||||
entrepreneurApiService.editLCSection(sectionId, section);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: checkReturn Type
|
||||
*
|
||||
* <p>Endpoint used to delete a LC section
|
||||
*
|
||||
* @return status code
|
||||
*/
|
||||
@DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}")
|
||||
public void removeLCSection(@PathVariable String sectionId) {
|
||||
entrepreneurApiService.removeLCSection(sectionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: check return type
|
||||
*
|
||||
* <p>Endpoint used to create a new LC section
|
||||
*
|
||||
* @return status code
|
||||
*/
|
||||
@PostMapping("/entrepreneur/lcsection/add/{sectionId}")
|
||||
public void addLCSection(@PathVariable String sectionId, @RequestBody LCSection section) {
|
||||
entrepreneurApiService.addLCSection(sectionId, section);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: check return type
|
||||
*
|
||||
* <p>Endpoint used to request the creation of a new project
|
||||
*
|
||||
* @return status code
|
||||
*/
|
||||
@PostMapping("/entrepreneur/project/request")
|
||||
public void requestNewProject(@RequestBody Project project) {
|
||||
entrepreneurApiService.requestNewProject(project);
|
||||
}
|
||||
}
|
@ -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