fix (kinda) : refactored update of data, still trying to fix bug
Some checks failed
Format / formatting (push) Successful in 6s
Build / build (push) Failing after 39s
CI / build (push) Successful in 11s

from EntrepreneurApiServiceTests (code is a bit messy with prints and comments dw)
This commit is contained in:
Théo Le Lez
2025-04-06 19:22:18 +02:00
parent 9b9cfbdb2e
commit aaa6e46d0c
14 changed files with 327 additions and 59 deletions

View File

@ -1,6 +1,7 @@
package enseirb.myinpulse.service.database;
import enseirb.myinpulse.model.Entrepreneur;
import enseirb.myinpulse.model.MakeAppointment;
import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.repository.EntrepreneurRepository;
@ -41,8 +42,56 @@ public class EntrepreneurService {
return this.entrepreneurRepository.save(entrepreneur);
}
public void updateEntrepreneurSchool(long idEntrepreneur, String school) {
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
entrepreneur.setSchool(school);
this.entrepreneurRepository.save(entrepreneur);
}
public void updateEntrepreneurCourse(long idEntrepreneur, String course) {
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
entrepreneur.setCourse(course);
this.entrepreneurRepository.save(entrepreneur);
}
public void updateEntrepreneurSneeStatus(long idEntrepreneur, boolean status) {
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
entrepreneur.setSneeStatus(status);
this.entrepreneurRepository.save(entrepreneur);
}
public void updateEntrepreneurProjectParticipation(
long idEntrepreneur, Project projectParticipation) {
System.out.println("expected");
System.out.println(getEntrepreneurById(idEntrepreneur));
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
System.out.println("test");
System.out.println(entrepreneur);
entrepreneur.setProjectParticipation(projectParticipation);
this.entrepreneurRepository.save(entrepreneur);
}
public void updateEntrepreneurProjectProposed(long idEntrepreneur, Project projectProposed) {
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
entrepreneur.setProjectParticipation(projectProposed);
this.entrepreneurRepository.save(entrepreneur);
}
public void updateEntrepreneurMakeAppointment(
long idEntrepreneur, MakeAppointment makeAppointment) {
Entrepreneur entrepreneur = getEntrepreneurById(idEntrepreneur);
entrepreneur.setMakeAppointment(makeAppointment);
this.entrepreneurRepository.save(entrepreneur);
}
public Entrepreneur updateEntrepreneur(
Long id, String school, String course, Boolean sneeStatus) {
Long id,
String school,
String course,
Boolean sneeStatus,
Project projectParticipation,
Project projectProposed,
MakeAppointment makeAppointment) {
Optional<Entrepreneur> entrepreneur = entrepreneurRepository.findById(id);
if (entrepreneur.isEmpty()) {
logger.error("updateEntrepreneur : No entrepreneur found with id {}", id);
@ -58,6 +107,15 @@ public class EntrepreneurService {
if (sneeStatus != null) {
entrepreneur.get().setSneeStatus(sneeStatus);
}
if (projectParticipation != null) {
entrepreneur.get().setProjectParticipation(projectParticipation);
}
if (projectProposed != null) {
entrepreneur.get().setProjectParticipation(projectProposed);
}
if (makeAppointment != null) {
entrepreneur.get().setMakeAppointment(makeAppointment);
}
return this.entrepreneurRepository.save(entrepreneur.get());
}