feat: renamex title to sectionId and added a new shared API call
Some checks failed
Format / formatting (push) Failing after 5s
CI / build (push) Successful in 11s

This commit is contained in:
Pierre Tellier
2025-02-26 15:55:33 +01:00
parent 8d4dc7916d
commit 5c3b2b138d
7 changed files with 61 additions and 108 deletions

View File

@ -1,10 +1,7 @@
package enseirb.myinpulse.service;
import enseirb.myinpulse.model.*;
import enseirb.myinpulse.service.database.AdministratorService;
import enseirb.myinpulse.service.database.EntrepreneurService;
import enseirb.myinpulse.service.database.ProjectService;
import enseirb.myinpulse.service.database.UserService;
import enseirb.myinpulse.service.database.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -22,17 +19,20 @@ public class SharedApiService {
private final UserService userService;
private final ProjectService projectService;
private final EntrepreneurService entrepreneurService;
private final SectionCellService sectionCellService;
@Autowired
SharedApiService(
AdministratorService administratorService,
UserService userService,
ProjectService projectService,
EntrepreneurService entrepreneurService) {
EntrepreneurService entrepreneurService,
SectionCellService sectionCellService) {
this.administratorService = administratorService;
this.userService = userService;
this.projectService = projectService;
this.entrepreneurService = entrepreneurService;
this.sectionCellService = sectionCellService;
}
// TODO: test
@ -58,13 +58,23 @@ public class SharedApiService {
return entrepreneur.getProjectParticipation() == project;
}
// TODO
public Iterable<SectionCell> getLCSection(
String projectId, String title, String date, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
// TODO filter this with date
public Iterable<SectionCell> getSectionCells(
long projectId, long sectionId, String date, String mail) {
if (!isAllowedToCheckProject(mail, projectId)) {
logger.warn(
"User {} tried to check section cells of the project {} but is not allowed to.",
mail,
projectId);
throw new ResponseStatusException(
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
}
Project project = this.projectService.getProjectById(projectId);
return this.sectionCellService.getSectionCellsByProject(project, sectionId);
}
// TODO: test, protect via email
// TODO: test
public Iterable<Entrepreneur> getEntrepreneursByProjectId(long projectId, String mail) {
if (!isAllowedToCheckProject(mail, projectId)) {
logger.warn(
@ -92,14 +102,17 @@ public class SharedApiService {
return project.getAdministrator();
}
// TODO
public Iterable<Appointment> getAppointmentsByProjectId(int projectId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public void getPDFReport(int appointmentId, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}
// TODO
public void createAppointmentRequest(Appointment appointment, String mail) {
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
}