feat: implemented most of the backend api for administrator
This commit is contained in:
@ -1,16 +1,37 @@
|
||||
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 {
|
||||
// TODO
|
||||
public Iterable<Administrator> getProjects() {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
|
||||
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.getIdUserByEmail(email)));
|
||||
}
|
||||
|
||||
// TODO
|
||||
@ -18,19 +39,25 @@ public class AdminApiService {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
}
|
||||
|
||||
// TODO
|
||||
// TODO: test
|
||||
public Iterable<Project> getPendingProjects() {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
return this.projectService.getPendingProjects();
|
||||
}
|
||||
|
||||
// TODO
|
||||
// TODO: test
|
||||
public void validateProject(ProjectDecision decision) {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
projectService.updateProject(
|
||||
decision.projectId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"ACTIVE",
|
||||
this.administratorService.getAdministratorById(decision.projectId));
|
||||
}
|
||||
|
||||
// TODO
|
||||
// TODO: solve todo + test
|
||||
public void addNewProject(Project project) {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
projectService.addNewProject(project); // TODO: how can the user know the ID ?
|
||||
}
|
||||
|
||||
// TODO
|
||||
@ -38,8 +65,8 @@ public class AdminApiService {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
}
|
||||
|
||||
// TODO
|
||||
public void deleteProject(String projectId) {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||
// TODO: test
|
||||
public void deleteProject(long projectId) {
|
||||
this.projectService.deleteProjectById(projectId);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user