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,5 +1,6 @@
package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.model.SectionCell;
import enseirb.myinpulse.repository.SectionCellRepository;
@ -43,14 +44,14 @@ public class SectionCellService {
}
public SectionCell updateSectionCell(
Long id, String title, String contentSectionCell, LocalDateTime modificationDate) {
Long id, Long sectionId, String contentSectionCell, LocalDateTime modificationDate) {
Optional<SectionCell> sectionCell = this.sectionCellRepository.findById(id);
if (sectionCell.isEmpty()) {
throw new ResponseStatusException(
HttpStatus.NOT_FOUND, "Cette cellule de section n'existe pas");
}
if (title != null) {
sectionCell.get().setTitle(title);
if (sectionId != null) {
sectionCell.get().setSectionId(sectionId);
}
if (contentSectionCell != null) {
sectionCell.get().setContentSectionCell(contentSectionCell);
@ -60,4 +61,8 @@ public class SectionCellService {
}
return this.sectionCellRepository.save(sectionCell.get());
}
public Iterable<SectionCell> getSectionCellsByProject(Project project, Long sectionId) {
return this.sectionCellRepository.findByProjectSectionCellAndSectionId(project, sectionId);
}
}