backend-api #6

Merged
piair merged 107 commits from backend-api into main 2025-03-26 19:04:09 +01:00
11 changed files with 219 additions and 125 deletions
Showing only changes of commit f9de5ed6bf - Show all commits

View File

@ -79,4 +79,8 @@ public class SectionCell {
public void setModificationDate(LocalDateTime modificationDate) { public void setModificationDate(LocalDateTime modificationDate) {
this.modificationDate = modificationDate; this.modificationDate = modificationDate;
} }
public Project getProjectSectionCell() {
return projectSectionCell;
}
} }

View File

@ -6,4 +6,4 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource @RepositoryRestResource
public interface ReportRepository extends JpaRepository<Report, Integer> {} public interface ReportRepository extends JpaRepository<Report, Long> {}

View File

@ -1,10 +1,16 @@
package enseirb.myinpulse.service; package enseirb.myinpulse.service;
import enseirb.myinpulse.model.Entrepreneur;
import enseirb.myinpulse.model.Project; import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.model.SectionCell; import enseirb.myinpulse.model.SectionCell;
import enseirb.myinpulse.model.User;
import enseirb.myinpulse.service.database.EntrepreneurService;
import enseirb.myinpulse.service.database.ProjectService; import enseirb.myinpulse.service.database.ProjectService;
import enseirb.myinpulse.service.database.SectionCellService; import enseirb.myinpulse.service.database.SectionCellService;
import enseirb.myinpulse.service.database.UserService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,13 +19,31 @@ import org.springframework.web.server.ResponseStatusException;
@Service @Service
public class EntrepreneurApiService { public class EntrepreneurApiService {
protected static final Logger logger = LogManager.getLogger();
private final SectionCellService sectionCellService; private final SectionCellService sectionCellService;
private final ProjectService projectService; private final ProjectService projectService;
private final UserService userService;
private final EntrepreneurService entrepreneurService;
@Autowired @Autowired
EntrepreneurApiService(SectionCellService sectionCellService, ProjectService projectService) { EntrepreneurApiService(
SectionCellService sectionCellService,
ProjectService projectService,
UserService userService,
EntrepreneurService entrepreneurService) {
this.sectionCellService = sectionCellService; this.sectionCellService = sectionCellService;
this.projectService = projectService; this.projectService = projectService;
this.userService = userService;
this.entrepreneurService = entrepreneurService;
}
// Create utils file ?
Boolean isAllowedToCheckProject(String mail, long projectId) {
User user = this.userService.getUserByEmail(mail);
Entrepreneur entrepreneur = this.entrepreneurService.getEntrepreneurById(user.getIdUser());
Project project = this.projectService.getProjectById(projectId);
return entrepreneur.getProjectParticipation() == project;
} }
public void editSectionCell(Long sectionCellId, SectionCell sectionCell, String mail) { public void editSectionCell(Long sectionCellId, SectionCell sectionCell, String mail) {
@ -29,6 +53,20 @@ public class EntrepreneurApiService {
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas"); HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
} }
if (!isAllowedToCheckProject(mail, this.sectionCellService.getProjectId(sectionCellId))) {
logger.warn(
"User {} tried to edit section cells {} of the project {} but is not allowed to.",
mail,
sectionCellId,
this.sectionCellService.getProjectId(sectionCellId));
throw new ResponseStatusException(
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
}
logger.info(
"User {} edited section cell {} of the project with id {}",
mail,
sectionCellId,
this.sectionCellService.getProjectId(sectionCellId));
sectionCellService.updateSectionCell( sectionCellService.updateSectionCell(
sectionCellId, sectionCellId,
sectionCell.getSectionId(), sectionCell.getSectionId(),
@ -43,6 +81,20 @@ public class EntrepreneurApiService {
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas"); HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
} }
if (!isAllowedToCheckProject(mail, this.sectionCellService.getProjectId(sectionCellId))) {
logger.warn(
"User {} tried to remove section cells {} of the project {} but is not allowed to.",
mail,
sectionCellId,
this.sectionCellService.getSectionCellById(sectionCellId));
throw new ResponseStatusException(
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
}
logger.info(
"User {} removed section cell {} of the project with id {}",
mail,
sectionCellId,
this.sectionCellService.getProjectId(sectionCellId));
sectionCellService.removeSectionCellById(sectionCellId); sectionCellService.removeSectionCellById(sectionCellId);
} }
@ -52,14 +104,29 @@ public class EntrepreneurApiService {
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.BAD_REQUEST, "La cellule de section fournie est vide"); HttpStatus.BAD_REQUEST, "La cellule de section fournie est vide");
} }
if (!isAllowedToCheckProject(
mail, this.sectionCellService.getProjectId(sectionCell.getIdSectionCell()))) {
logger.warn(
"User {} tried to add a section cell to the project {} but is not allowed to.",
mail,
this.sectionCellService.getProjectId(sectionCell.getIdSectionCell()));
throw new ResponseStatusException(
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
}
logger.info(
"User {} added a new section cell {} to the project with id {}",
mail,
sectionCell.getIdSectionCell(),
this.sectionCellService.getProjectId(sectionCell.getIdSectionCell()));
sectionCellService.addNewSectionCell(sectionCell); sectionCellService.addNewSectionCell(sectionCell);
} }
public void requestNewProject(Project project, String mail) { public void requestNewProject(Project project, String mail) {
if (project == null) { if (project == null) {
System.err.println("Trying to request the creation of a null project"); logger.error("Trying to request the creation of a null project");
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Le projet fourni est vide"); throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Le projet fourni est vide");
} }
logger.info("User {} created a new project with id {}", mail, project.getIdProject());
project.setProjectStatus("PENDING"); project.setProjectStatus("PENDING");
projectService.addNewProject(project); projectService.addNewProject(project);
} }

View File

@ -3,6 +3,8 @@ package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.Annotation; import enseirb.myinpulse.model.Annotation;
import enseirb.myinpulse.repository.AnnotationRepository; import enseirb.myinpulse.repository.AnnotationRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,6 +15,8 @@ import java.util.Optional;
@Service @Service
public class AnnotationService { public class AnnotationService {
protected static final Logger logger = LogManager.getLogger();
private final AnnotationRepository annotationRepository; private final AnnotationRepository annotationRepository;
@Autowired @Autowired
@ -27,6 +31,7 @@ public class AnnotationService {
public Annotation getAnnotationById(Long id) { public Annotation getAnnotationById(Long id) {
Optional<Annotation> annotation = annotationRepository.findById(id); Optional<Annotation> annotation = annotationRepository.findById(id);
if (annotation.isEmpty()) { if (annotation.isEmpty()) {
logger.error("getAnnotationById : No annotation found with id {}", id);
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette annotation n'existe pas"); HttpStatus.NOT_FOUND, "Cette annotation n'existe pas");
} }
@ -44,7 +49,9 @@ public class AnnotationService {
public Annotation updateAnnotation(Long id, String comment) { public Annotation updateAnnotation(Long id, String comment) {
Optional<Annotation> annotation = annotationRepository.findById(id); Optional<Annotation> annotation = annotationRepository.findById(id);
if (annotation.isEmpty()) { if (annotation.isEmpty()) {
return null; logger.error("updateAnnotation : No annotation found with id {}", id);
throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette annotation n'existe pas");
} }
if (comment != null) { if (comment != null) {
annotation.get().setComment(comment); annotation.get().setComment(comment);

View File

@ -1,45 +1,54 @@
package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services; package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.Appointment; import enseirb.myinpulse.model.Appointment;
import enseirb.myinpulse.repository.AppointmentRepository; import enseirb.myinpulse.repository.AppointmentRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Optional; import java.util.Optional;
@RestController @Service
public class AppointmentController { public class AppointmentService {
@Autowired AppointmentRepository appointmentRepository; private static final Logger logger = LogManager.getLogger(AppointmentService.class);
@GetMapping("/Appointment") private AppointmentRepository appointmentRepository;
@ResponseBody
public Iterable<Appointment> allAppointments() { @Autowired
AppointmentService(AppointmentRepository appointmentRepository) {
this.appointmentRepository = appointmentRepository;
}
public Iterable<Appointment> getallAppointments() {
return this.appointmentRepository.findAll(); return this.appointmentRepository.findAll();
} }
@GetMapping("/Appointment/{id}") public Appointment getAppointmentById(Long id) {
public Appointment getAppointmentById(@PathVariable Long id) {
Optional<Appointment> appointment = this.appointmentRepository.findById(id); Optional<Appointment> appointment = this.appointmentRepository.findById(id);
if (appointment.isEmpty()) { if (appointment.isEmpty()) {
logger.error("getAppointmentById : No appointment found with id {}", id);
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce rendez vous n'existe pas"); throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce rendez vous n'existe pas");
} }
return appointment.get(); return appointment.get();
} }
@PostMapping("/Appointment") public Appointment addNewAppointment(Appointment appointment) {
public Appointment addAppointment(@RequestBody Appointment appointment) {
return this.appointmentRepository.save(appointment); return this.appointmentRepository.save(appointment);
} }
@PostMapping("/Appointment/{id}") public void deleteAppointmentById(Long id) {
this.appointmentRepository.deleteById(id);
}
public Appointment updateAppointment( public Appointment updateAppointment(
@PathVariable Long id, Long id,
LocalDate appointmentDate, LocalDate appointmentDate,
LocalTime appointmentTime, LocalTime appointmentTime,
LocalTime appointmentDuration, LocalTime appointmentDuration,
@ -47,6 +56,7 @@ public class AppointmentController {
String appointmentSubject) { String appointmentSubject) {
Optional<Appointment> appointment = this.appointmentRepository.findById(id); Optional<Appointment> appointment = this.appointmentRepository.findById(id);
if (appointment.isEmpty()) { if (appointment.isEmpty()) {
logger.error("updateAppointment : No appointment found with id {}", id);
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce rendez vous n'existe pas"); throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce rendez vous n'existe pas");
} }
if (appointmentDate != null) { if (appointmentDate != null) {

View File

@ -4,9 +4,10 @@ import enseirb.myinpulse.model.Entrepreneur;
import enseirb.myinpulse.model.Project; import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.repository.EntrepreneurRepository; import enseirb.myinpulse.repository.EntrepreneurRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.util.Optional; import java.util.Optional;
@ -14,6 +15,8 @@ import java.util.Optional;
@Service @Service
public class EntrepreneurService { public class EntrepreneurService {
protected static final Logger logger = LogManager.getLogger();
private final EntrepreneurRepository entrepreneurRepository; private final EntrepreneurRepository entrepreneurRepository;
EntrepreneurService(EntrepreneurRepository entrepreneurRepository) { EntrepreneurService(EntrepreneurRepository entrepreneurRepository) {
@ -27,6 +30,7 @@ public class EntrepreneurService {
public Entrepreneur getEntrepreneurById(Long id) { public Entrepreneur getEntrepreneurById(Long id) {
Optional<Entrepreneur> entrepreneur = entrepreneurRepository.findById(id); Optional<Entrepreneur> entrepreneur = entrepreneurRepository.findById(id);
if (entrepreneur.isEmpty()) { if (entrepreneur.isEmpty()) {
logger.error("getEntrepreneurById : No entrepreneur found with id {}", id);
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas"); HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas");
} }
@ -41,6 +45,7 @@ public class EntrepreneurService {
Long id, String school, String course, Boolean sneeStatus) { Long id, String school, String course, Boolean sneeStatus) {
Optional<Entrepreneur> entrepreneur = entrepreneurRepository.findById(id); Optional<Entrepreneur> entrepreneur = entrepreneurRepository.findById(id);
if (entrepreneur.isEmpty()) { if (entrepreneur.isEmpty()) {
logger.error("updateEntrepreneur : No entrepreneur found with id {}", id);
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas"); HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas");
} }

View File

@ -34,7 +34,7 @@ public class ProjectService {
public Project getProjectById(Long id) { public Project getProjectById(Long id) {
Optional<Project> project = this.projectRepository.findById(id); Optional<Project> project = this.projectRepository.findById(id);
if (project.isEmpty()) { if (project.isEmpty()) {
System.err.println("Project with id " + id + " not found"); logger.error("No project found with id {}", id);
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce projet n'existe pas"); throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce projet n'existe pas");
} }
return project.get(); return project.get();
@ -77,7 +77,7 @@ public class ProjectService {
if (projectStatus != null) { if (projectStatus != null) {
if (!validateStatus(projectStatus)) { if (!validateStatus(projectStatus)) {
System.err.println("updateProjectStatus: Invalid status " + projectStatus); logger.error("updateProjectStatus: Invalid status {}", projectStatus);
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_ACCEPTABLE, "Ce status n'est pas accepté"); HttpStatus.NOT_ACCEPTABLE, "Ce status n'est pas accepté");
} }

View File

@ -3,6 +3,8 @@ package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.Report; import enseirb.myinpulse.model.Report;
import enseirb.myinpulse.repository.ReportRepository; import enseirb.myinpulse.repository.ReportRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -12,6 +14,9 @@ import java.util.Optional;
@Service @Service
public class ReportService { public class ReportService {
protected static final Logger logger = LogManager.getLogger();
private final ReportRepository reportRepository; private final ReportRepository reportRepository;
@Autowired @Autowired
@ -19,16 +24,37 @@ public class ReportService {
this.reportRepository = reportRepository; this.reportRepository = reportRepository;
} }
Report getReportById(int id) { public Iterable<Report> getAllReports() {
Optional<Report> report = reportRepository.findById(id); return this.reportRepository.findAll();
}
public Report getReportById(Long id) {
Optional<Report> report = this.reportRepository.findById(id);
if (report.isEmpty()) { if (report.isEmpty()) {
logger.error("getReportById : No report found with id {}", id);
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas"); throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
} }
return report.get(); return report.get();
} }
// TODO: do some validation // TODO: do some validation
void saveReport(Report report) { public Report addNewReport(Report report) {
reportRepository.save(report); return this.reportRepository.save(report);
}
public void deleteReportById(Long id) {
this.reportRepository.deleteById(id);
}
public Report updateReport(Long id, String reportContent) {
Optional<Report> report = this.reportRepository.findById(id);
if (report.isEmpty()) {
logger.error("updateReport : No report found with id {}", id);
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
}
if (reportContent != null) {
report.get().setReportContent(reportContent);
}
return this.reportRepository.save(report.get());
} }
} }

View File

@ -4,6 +4,8 @@ import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.model.SectionCell; import enseirb.myinpulse.model.SectionCell;
import enseirb.myinpulse.repository.SectionCellRepository; import enseirb.myinpulse.repository.SectionCellRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -15,6 +17,8 @@ import java.util.Optional;
@Service @Service
public class SectionCellService { public class SectionCellService {
protected static final Logger logger = LogManager.getLogger();
private final SectionCellRepository sectionCellRepository; private final SectionCellRepository sectionCellRepository;
@Autowired @Autowired
@ -29,6 +33,7 @@ public class SectionCellService {
public SectionCell getSectionCellById(Long id) { public SectionCell getSectionCellById(Long id) {
Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id); Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id);
if (sectionCell.isEmpty()) { if (sectionCell.isEmpty()) {
logger.error("getSectionCellById : No sectionCell found with id {}", id);
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas"); HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
} }
@ -47,6 +52,7 @@ public class SectionCellService {
Long id, Long sectionId, String contentSectionCell, LocalDateTime modificationDate) { Long id, Long sectionId, String contentSectionCell, LocalDateTime modificationDate) {
Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id); Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id);
if (sectionCell.isEmpty()) { if (sectionCell.isEmpty()) {
logger.error("updateSectionCell : No sectionCell found with id {}", id);
throw new ResponseStatusException( throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas"); HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
} }
@ -65,4 +71,10 @@ public class SectionCellService {
public Iterable<SectionCell> getSectionCellsByProject(Project project, Long sectionId) { public Iterable<SectionCell> getSectionCellsByProject(Project project, Long sectionId) {
return this.sectionCellRepository.findByProjectSectionCellAndSectionId(project, sectionId); return this.sectionCellRepository.findByProjectSectionCellAndSectionId(project, sectionId);
} }
public Long getProjectId(Long sectionCellId) {
SectionCell sectionCell = getSectionCellById(sectionCellId);
Project sectionProject = sectionCell.getProjectSectionCell();
return sectionProject.getIdProject();
}
} }

View File

@ -3,6 +3,8 @@ package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.User; import enseirb.myinpulse.model.User;
import enseirb.myinpulse.repository.UserRepository; import enseirb.myinpulse.repository.UserRepository;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -14,6 +16,9 @@ import java.util.Optional;
@Service @Service
public class UserService { public class UserService {
protected static final Logger logger = LogManager.getLogger();
private final UserRepository userRepository; private final UserRepository userRepository;
@Autowired @Autowired
@ -30,8 +35,8 @@ public class UserService {
Optional<User> opt_user = this.userRepository.findByPrimaryMail(email); Optional<User> opt_user = this.userRepository.findByPrimaryMail(email);
if (opt_user.isEmpty()) { if (opt_user.isEmpty()) {
System.err.println("Couldn't find user with email " + email); logger.error("getUserByEmail : No user found with email {}", email);
throw new ResponseStatusException(HttpStatus.NOT_FOUND); throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet utilisateur n'existe pas");
} }
return opt_user.get(); return opt_user.get();
} }
@ -53,6 +58,7 @@ public class UserService {
String phoneNumber) { String phoneNumber) {
Optional<User> user = userRepository.findById(id); Optional<User> user = userRepository.findById(id);
if (user.isEmpty()) { if (user.isEmpty()) {
logger.error("updateUser : No user found with id {}", id);
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet utilisateur n'existe pas"); throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet utilisateur n'existe pas");
} }
if (userName != null) { if (userName != null) {

View File

@ -1,43 +0,0 @@
package enseirb.myinpulse.service.database.old_controllers_to_convert_to_services;
import org.springframework.web.bind.annotation.*;
@RestController
public class ReportController {
/*
private final ReportRepository reportRepository;
@Autowired
public ReportController(ReportRepository reportRepository) {
this.reportRepository = reportRepository;
}
@GetMapping("/Report")
@ResponseBody
public Iterable<Report> allReports() {
System.out.println("\n\n");
System.out.println(ReportRepository);
System.out.println("\n\n");
return this.reportRepository.findAll();
}
@PostMapping("/Report")
public Report addReport(@RequestBody Report report) {
return this.reportRepository.save(report);
}
@PostMapping("/Report/{id}")
public Report updateProject(@PathVariable Long id, String reportContent) {
Optional<Report> report = this.reportRepository.findById(id);
if (report.isEmpty()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce compte rendu n'existe pas");
}
if (reportContent != null) {
report.get().setReportContent(reportContent);
}
return this.reportRepository.save(report.get());
}
*/
}