Compare commits

..

2 Commits

Author SHA1 Message Date
Théo Le Lez
7a9955b781 fix: merged
All checks were successful
Format / formatting (push) Successful in 9s
CI / build (push) Successful in 15s
2025-02-12 10:19:31 +01:00
Théo Le Lez
1e97177777 fix: issue with foreign keys 2025-02-11 21:15:13 +01:00
20 changed files with 629 additions and 646 deletions

View File

@ -1,14 +1,13 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.Administrateurs;
import enseirb.myinpulse.postgres_db.repository.AdministrateursRepository; import enseirb.myinpulse.postgres_db.repository.AdministrateursRepository;
import java.util.Optional;
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.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.Administrateurs;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@RestController @RestController
public class AdministrateursController { public class AdministrateursController {
@ -24,8 +23,7 @@ public class AdministrateursController {
public Administrateurs getAdministrateursById(@PathVariable Long id) { public Administrateurs getAdministrateursById(@PathVariable Long id) {
Optional<Administrateurs> administrateur = this.administrateursRepository.findById(id); Optional<Administrateurs> administrateur = this.administrateursRepository.findById(id);
if (administrateur.isEmpty()) { if (administrateur.isEmpty()) {
throw new ResponseStatusException( throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet administrateur n'existe pas");
HttpStatus.NOT_FOUND, "Cet administrateur n'existe pas");
} }
return administrateur.get(); return administrateur.get();
} }

View File

@ -1,14 +1,13 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository; import enseirb.myinpulse.postgres_db.repository.ComptesRendusRepository;
import java.util.Optional;
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.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.ComptesRendus;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@RestController @RestController
public class ComptesRendusController { public class ComptesRendusController {

View File

@ -1,14 +1,13 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.Entrepreneurs;
import enseirb.myinpulse.postgres_db.repository.EntrepreneursRepository; import enseirb.myinpulse.postgres_db.repository.EntrepreneursRepository;
import java.util.Optional;
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.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.Entrepreneurs;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@RestController @RestController
public class EntrepreneursController { public class EntrepreneursController {
@ -24,8 +23,7 @@ public class EntrepreneursController {
public Entrepreneurs getEntrepreneursById(@PathVariable Long id) { public Entrepreneurs getEntrepreneursById(@PathVariable Long id) {
Optional<Entrepreneurs> entrepreneur = entrepreneursRepository.findById(id); Optional<Entrepreneurs> entrepreneur = entrepreneursRepository.findById(id);
if (entrepreneur.isEmpty()) { if (entrepreneur.isEmpty()) {
throw new ResponseStatusException( throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas");
HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas");
} }
return entrepreneur.get(); return entrepreneur.get();
} }
@ -40,8 +38,7 @@ public class EntrepreneursController {
@PathVariable Long id, String ecole, String filiere, Boolean status_snee) { @PathVariable Long id, String ecole, String filiere, Boolean status_snee) {
Optional<Entrepreneurs> entrepreneur = entrepreneursRepository.findById(id); Optional<Entrepreneurs> entrepreneur = entrepreneursRepository.findById(id);
if (entrepreneur.isEmpty()) { if (entrepreneur.isEmpty()) {
throw new ResponseStatusException( throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas");
HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas");
} }
if (ecole != null) { if (ecole != null) {
entrepreneur.get().setEcole(ecole); entrepreneur.get().setEcole(ecole);

View File

@ -1,15 +1,14 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.Projets;
import enseirb.myinpulse.postgres_db.repository.ProjetsRepository; import enseirb.myinpulse.postgres_db.repository.ProjetsRepository;
import java.time.LocalDate;
import java.util.Optional;
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.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.Projets;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.time.LocalDate;
import java.util.Optional;
@RestController @RestController
public class ProjetsController { public class ProjetsController {
@ -39,7 +38,7 @@ public class ProjetsController {
public Projets updateProjets( public Projets updateProjets(
@PathVariable Long id, @PathVariable Long id,
String nom_projet, String nom_projet,
Byte[] logo, byte[] logo,
LocalDate date_creation, LocalDate date_creation,
String status_projet) { String status_projet) {
Optional<Projets> projet = this.projetsRepository.findById(id); Optional<Projets> projet = this.projetsRepository.findById(id);

View File

@ -1,15 +1,14 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.repository.RendezVousRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.RendezVous; import enseirb.myinpulse.postgres_db.model.RendezVous;
import org.springframework.web.server.ResponseStatusException; import enseirb.myinpulse.postgres_db.repository.RendezVousRepository;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Optional; import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
@RestController @RestController
public class RendezVousController { public class RendezVousController {

View File

@ -1,15 +1,14 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.Sections;
import enseirb.myinpulse.postgres_db.repository.SectionsRepository; import enseirb.myinpulse.postgres_db.repository.SectionsRepository;
import java.time.LocalDateTime;
import java.util.Optional;
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.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.Sections;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.time.LocalDateTime;
import java.util.Optional;
@RestController @RestController
public class SectionsController { public class SectionsController {

View File

@ -1,14 +1,13 @@
package enseirb.myinpulse.postgres_db.controller; package enseirb.myinpulse.postgres_db.controller;
import enseirb.myinpulse.postgres_db.model.Utilisateurs;
import enseirb.myinpulse.postgres_db.repository.UtilisateursRepository; import enseirb.myinpulse.postgres_db.repository.UtilisateursRepository;
import java.util.Optional;
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.web.bind.annotation.*;
import enseirb.myinpulse.postgres_db.model.Utilisateurs;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
import java.util.Optional;
@RestController @RestController
public class UtilisateursController { public class UtilisateursController {

View File

@ -3,7 +3,6 @@ package enseirb.myinpulse.postgres_db.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.persistence.PrimaryKeyJoinColumn; import jakarta.persistence.PrimaryKeyJoinColumn;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -13,15 +12,15 @@ import java.util.List;
public class Administrateurs extends Utilisateurs { public class Administrateurs extends Utilisateurs {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Projets.id_projets") @JoinColumn(name = "id_projet")
private Projets projets; private Projets projetsAdministrateurs;
@OneToMany(mappedBy = "administrateurs", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "administrateursSections", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Sections> ListSections = new ArrayList<>(); private List<Sections> ListSections = new ArrayList<>();
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "RendezVous.id_rdv") @JoinColumn(name = "id_rdv")
private RendezVous rendezVous; private RendezVous rendezVousAdministrateurs;
public Administrateurs() {} public Administrateurs() {}

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.postgres_db.model;
import jakarta.persistence.Entity;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@ -18,8 +18,8 @@ public class ComptesRendus {
private String contenu_compte_rendu; private String contenu_compte_rendu;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "RendezVous.id_rdv") @JoinColumn(name = "id_rdv")
private RendezVous rendezVous; private RendezVous rendezVousComptesRendus;
public ComptesRendus() {} public ComptesRendus() {}

View File

@ -1,7 +1,7 @@
package enseirb.myinpulse.postgres_db.model; package enseirb.myinpulse.postgres_db.model;
import jakarta.persistence.Entity;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.persistence.Entity;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Entity @Entity
@ -18,16 +18,17 @@ public class Entrepreneurs extends Utilisateurs {
private boolean status_snee; private boolean status_snee;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Projets.id_projets") @JoinColumn(name = "id_projet_participation", referencedColumnName = "id_projet")
private Projets projets_participation; private Projets projetsParticipation;
// @Column(insertable=false, updatable=false)
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Projets.id_projets") @JoinColumn(name = "id_projet_propose", referencedColumnName = "id_projet")
private Projets projets_propose; private Projets projetsPropose;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "RendezVous.id_rdv") @JoinColumn(name = "id_rdv")
private RendezVous rendezVous; private RendezVous rendezVousEntrepreneurs;
public Entrepreneurs() {} public Entrepreneurs() {}

View File

@ -2,7 +2,6 @@ package enseirb.myinpulse.postgres_db.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -19,23 +18,23 @@ public class Projets {
@Column(length = 255) @Column(length = 255)
private String nom_projet; private String nom_projet;
private Byte[] logo; private byte[] logo;
private LocalDate date_creation; private LocalDate date_creation;
@Column(length = 255) @Column(length = 255)
private String status_projet; private String status_projet;
@OneToMany(mappedBy = "projets", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "projetsAdministrateurs", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Administrateurs> listAdministrateurs = new ArrayList<>(); private List<Administrateurs> listAdministrateurs = new ArrayList<>();
@OneToMany(mappedBy = "projets", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "projetsParticipation", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Entrepreneurs> ListEntrepreneursParticipation = new ArrayList<>(); private List<Entrepreneurs> ListEntrepreneursParticipation = new ArrayList<>();
@OneToOne(mappedBy = "projets", fetch = FetchType.LAZY, orphanRemoval = true) @OneToOne(mappedBy = "projetsPropose", fetch = FetchType.LAZY, orphanRemoval = true)
private Entrepreneurs entrepreneurs_propose; private Entrepreneurs entrepreneursPropose;
@OneToMany(mappedBy = "projets", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "projetsSections", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Sections> ListSections = new ArrayList<>(); private List<Sections> ListSections = new ArrayList<>();
// Hibernate expects entities to have a no-arg constructor, // Hibernate expects entities to have a no-arg constructor,
@ -46,7 +45,7 @@ public class Projets {
public Projets( public Projets(
Long id_projet, Long id_projet,
String nom_projet, String nom_projet,
Byte[] logo, byte[] logo,
LocalDate date_creation, LocalDate date_creation,
String status_projet) { String status_projet) {
this.id_projet = id_projet; this.id_projet = id_projet;
@ -72,11 +71,11 @@ public class Projets {
this.nom_projet = nom_projet; this.nom_projet = nom_projet;
} }
public Byte[] getLogo() { public byte[] getLogo() {
return logo; return logo;
} }
public void setLogo(Byte[] logo) { public void setLogo(byte[] logo) {
this.logo = logo; this.logo = logo;
} }

View File

@ -28,13 +28,13 @@ public class RendezVous {
private String sujet_rdv; private String sujet_rdv;
@OneToMany(mappedBy = "rendez_vous", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "rendezVousEntrepreneurs", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Entrepreneurs> ListEntrepreneurs = new ArrayList<>(); private List<Entrepreneurs> ListEntrepreneurs = new ArrayList<>();
@OneToMany(mappedBy = "rendez_vous", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "rendezVousAdministrateurs", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Administrateurs> ListAdministrateurs = new ArrayList<>(); private List<Administrateurs> ListAdministrateurs = new ArrayList<>();
@OneToMany(mappedBy = "rendez_vous", fetch = FetchType.LAZY, orphanRemoval = true) @OneToMany(mappedBy = "rendezVousComptesRendus", fetch = FetchType.LAZY, orphanRemoval = true)
private List<ComptesRendus> ListComptesRendus = new ArrayList<>(); private List<ComptesRendus> ListComptesRendus = new ArrayList<>();
@ManyToMany( @ManyToMany(
@ -43,7 +43,7 @@ public class RendezVous {
@JoinTable( @JoinTable(
name = "concerner", name = "concerner",
joinColumns = @JoinColumn(name = "id_rdv"), joinColumns = @JoinColumn(name = "id_rdv"),
inverseJoinColumns = @JoinColumn(name = "id_sections")) inverseJoinColumns = @JoinColumn(name = "id_section"))
List<Sections> ListSections = new ArrayList<>(); List<Sections> ListSections = new ArrayList<>();
public RendezVous() {} public RendezVous() {}

View File

@ -24,23 +24,20 @@ public class Sections {
private LocalDateTime date_modification; private LocalDateTime date_modification;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Projets.id_projets") @JoinColumn(name = "id_projet")
private Projets projets; private Projets projetsSections;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Administrateurs.id_admnistrateur") @JoinColumn(name = "id_admnistrateur")
private Administrateurs administrateurs; private Administrateurs administrateursSections;
@ManyToMany(mappedBy = "sections") @ManyToMany(mappedBy = "ListSections")
private List<RendezVous> rendezVous = new ArrayList<>(); private List<RendezVous> rendezVous = new ArrayList<>();
public Sections() {} public Sections() {}
public Sections( public Sections(
Long id_section, Long id_section, String titre, String contenu_section, LocalDateTime date_modification) {
String titre,
String contenu_section,
LocalDateTime date_modification) {
this.id_section = id_section; this.id_section = id_section;
this.titre = titre; this.titre = titre;
this.contenu_section = contenu_section; this.contenu_section = contenu_section;

View File

@ -2,7 +2,7 @@ spring.application.name=myinpulse
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:7080/realms/test/protocol/openid-connect/certs
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:7080/realms/test
logging.level.org.springframework.security=DEBUG logging.level.org.springframework.security=DEBUG
spring.datasource.url=jdbc:postgresql://localhost:5432/${MyINPulse_DB} spring.datasource.url=jdbc:postgresql://postgres/${POSTGRES_DB}
spring.datasource.username=${POSTGRES_USER} spring.datasource.username=${POSTGRES_USER}
spring.datasource.password=${POSTGRES_PASSWORD} spring.datasource.password=${POSTGRES_PASSWORD}
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update

View File

@ -4,7 +4,6 @@ INSERT INTO projets (nom_projet, logo, date_creation, status_projet) VALUES
('Débat concours', decode('022024abd5486e245c145dda65116f', 'hex'), TO_DATE('22-NOV-2023', 'DD-MON-YYYY'), 'Suspendu'), ('Débat concours', decode('022024abd5486e245c145dda65116f', 'hex'), TO_DATE('22-NOV-2023', 'DD-MON-YYYY'), 'Suspendu'),
('HDeirbMI', decode('ab548d6c1d595a2975e6476f544d14c55a', 'hex'), TO_DATE('07-DEC-2024', 'DD-MON-YYYY'), 'Lancement'); ('HDeirbMI', decode('ab548d6c1d595a2975e6476f544d14c55a', 'hex'), TO_DATE('07-DEC-2024', 'DD-MON-YYYY'), 'Lancement');
INSERT INTO utilisateurs (nom, prenom, mail_principal, mail_secondaire, numero_telephone) VALUES INSERT INTO utilisateurs (nom, prenom, mail_principal, mail_secondaire, numero_telephone) VALUES
('Dupont', 'Dupond', 'super@mail.fr', 'super2@mail.fr', '06 45 72 45 98'), ('Dupont', 'Dupond', 'super@mail.fr', 'super2@mail.fr', '06 45 72 45 98'),
('Martin', 'Matin', 'genial@mail.fr', 'genial2@mail.fr', '06 52 14 58 73'), ('Martin', 'Matin', 'genial@mail.fr', 'genial2@mail.fr', '06 52 14 58 73'),
@ -39,7 +38,6 @@ INSERT INTO rendez_vous (date_rdv, heure_rdv, duree_rdv, lieu_rdv, sujet_rdv) VA
(TO_DATE('23-JAN-2024', 'DD-MON-YYYY'), '12:56:27', '11:03:33', "Là où le vent nous porte", "Journée la plus importante de l'année"), (TO_DATE('23-JAN-2024', 'DD-MON-YYYY'), '12:56:27', '11:03:33', "Là où le vent nous porte", "Journée la plus importante de l'année"),
(TO_DATE('25-AUG-2025', 'DD-MON-YYYY'), '00:09:00', '01:00:00', "Euh c'est par où l'amphi 56 ?", "Rentrée scolaire (il fait trop froid c'est quoi ça on est en août)"); (TO_DATE('25-AUG-2025', 'DD-MON-YYYY'), '00:09:00', '01:00:00', "Euh c'est par où l'amphi 56 ?", "Rentrée scolaire (il fait trop froid c'est quoi ça on est en août)");
INSERT INTO comptes_rendus (contenu_compte_rendu) VALUES INSERT INTO comptes_rendus (contenu_compte_rendu) VALUES
("Ah oui ça c'est super, ah ouais j'aime bien, bien vu de penser à ça"), ("Ah oui ça c'est super, ah ouais j'aime bien, bien vu de penser à ça"),
("Bonne réunion"), ("Bonne réunion"),

View File

@ -17,7 +17,6 @@ date_creation DATE ,
status_projet VARCHAR(255) , status_projet VARCHAR(255) ,
CONSTRAINT pk_projet PRIMARY KEY (id_projet) ); CONSTRAINT pk_projet PRIMARY KEY (id_projet) );
CREATE TABLE utilisateurs CREATE TABLE utilisateurs
( (
id_utilisateur SERIAL NOT NULL, id_utilisateur SERIAL NOT NULL,