73 lines
2.4 KiB
Java
73 lines
2.4 KiB
Java
package enseirb.myinpulse.service;
|
|
|
|
import enseirb.myinpulse.model.*;
|
|
import enseirb.myinpulse.service.database.AdministratorService;
|
|
import enseirb.myinpulse.service.database.ProjectService;
|
|
import enseirb.myinpulse.service.database.UserService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.server.ResponseStatusException;
|
|
|
|
@Service
|
|
public class AdminApiService {
|
|
|
|
private final ProjectService projectService;
|
|
private final UserService userService;
|
|
private final AdministratorService administratorService;
|
|
|
|
@Autowired
|
|
AdminApiService(
|
|
ProjectService projectService,
|
|
UserService userService,
|
|
AdministratorService administratorService) {
|
|
this.projectService = projectService;
|
|
this.userService = userService;
|
|
this.administratorService = administratorService;
|
|
}
|
|
|
|
// TODO: test
|
|
public Iterable<Project> getProjectsOfAdmin(String email) {
|
|
return projectService.getProjectsByAdminId(
|
|
administratorService.getAdministratorById(
|
|
this.userService.getUserByEmail(email).getIdUser()));
|
|
}
|
|
|
|
// TODO
|
|
public Iterable<Appointment> getUpcomingAppointments(String email) {
|
|
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
|
}
|
|
|
|
// TODO: test
|
|
public Iterable<Project> getPendingProjects() {
|
|
return this.projectService.getPendingProjects();
|
|
}
|
|
|
|
// TODO: test
|
|
public void validateProject(ProjectDecision decision) {
|
|
projectService.updateProject(
|
|
decision.projectId,
|
|
null,
|
|
null,
|
|
null,
|
|
"ACTIVE",
|
|
this.administratorService.getAdministratorById(decision.projectId));
|
|
}
|
|
|
|
// TODO: solve todo + test
|
|
public void addNewProject(Project project) {
|
|
projectService.addNewProject(project); // TODO: how can the front know the ID ?
|
|
}
|
|
|
|
// TODO
|
|
public void createAppointmentReport(String appointmentId, Report report, String email) {
|
|
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
|
}
|
|
|
|
// TODO: test
|
|
public void deleteProject(long projectId) {
|
|
this.projectService.deleteProjectById(projectId);
|
|
}
|
|
}
|