diff --git a/src/main/java/fr/organizee/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java index ef79042..e93e926 100644 --- a/src/main/java/fr/organizee/controller/ContactController.java +++ b/src/main/java/fr/organizee/controller/ContactController.java @@ -21,7 +21,7 @@ public class ContactController { private ContactRepository contactRepo; @GetMapping(value = "/{id}") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity findById(@PathVariable int id){ Optional contact = null; try @@ -35,7 +35,7 @@ public class ContactController { } @GetMapping(value = "team/{team_id}") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity findByTeamId(@PathVariable int team_id){ List contacts = null; try @@ -49,7 +49,7 @@ public class ContactController { } @PostMapping(value="/add") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity addContact(@RequestBody Contact contact){ Contact resultContact = null; try { @@ -62,7 +62,7 @@ public class ContactController { } @PutMapping("/update/{id}") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity updateContact(@RequestBody Contact contact, @PathVariable Integer id) throws Exception { Contact resultContact = null; try { @@ -76,7 +76,7 @@ public class ContactController { } @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteContact(@PathVariable int id){ try { contactRepo.delete(contactRepo.getById(id)); diff --git a/src/main/java/fr/organizee/model/Contact.java b/src/main/java/fr/organizee/model/Contact.java index 2c5ffb2..826b2db 100644 --- a/src/main/java/fr/organizee/model/Contact.java +++ b/src/main/java/fr/organizee/model/Contact.java @@ -1,5 +1,6 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; @@ -18,7 +19,7 @@ public class Contact { private LocalDate dateNaissance; @ManyToOne @JoinColumn(name="TEAM_ID") - @JsonIgnoreProperties("contact") + @JsonIgnoreProperties({"contact","membre"}) private Team team; public Contact() { diff --git a/src/main/java/fr/organizee/model/Evenement.java b/src/main/java/fr/organizee/model/Evenement.java index 15a355f..936cdaa 100644 --- a/src/main/java/fr/organizee/model/Evenement.java +++ b/src/main/java/fr/organizee/model/Evenement.java @@ -1,5 +1,6 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; @@ -14,13 +15,13 @@ public class Evenement { private LocalDateTime eventFin; private int allDay; private String libelle; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="MEMBRE_ID") @JsonIgnoreProperties("evenement") private Membre membre; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") - @JsonIgnoreProperties("evenement") + @JsonIgnoreProperties({"evenement", "membre"}) private Team team; public Evenement() { diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index e11cba4..dcc5cb0 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -15,7 +15,7 @@ public class Menu { private int validationProposition; @ManyToOne @JoinColumn(name="TEAM_ID") - @JsonIgnoreProperties("menu") + @JsonIgnoreProperties({"menu","membre"}) private Team team; public Menu() { diff --git a/src/main/java/fr/organizee/model/Team.java b/src/main/java/fr/organizee/model/Team.java index ded5837..14ff97e 100644 --- a/src/main/java/fr/organizee/model/Team.java +++ b/src/main/java/fr/organizee/model/Team.java @@ -1,5 +1,6 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; @@ -12,17 +13,24 @@ public class Team { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List membres = new ArrayList<>(); + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") + @JsonIgnore private List contacts = new ArrayList<>(); + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") + @JsonIgnore private List todolists = new ArrayList<>(); + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") + @JsonIgnore private List menus = new ArrayList<>(); public Team() { diff --git a/src/main/java/fr/organizee/model/TodoList.java b/src/main/java/fr/organizee/model/TodoList.java index 007e68a..f8ec979 100644 --- a/src/main/java/fr/organizee/model/TodoList.java +++ b/src/main/java/fr/organizee/model/TodoList.java @@ -1,5 +1,6 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javax.persistence.*; @@ -14,7 +15,7 @@ public class TodoList { private String nom; @ManyToOne @JoinColumn(name="TEAM_ID") - @JsonIgnoreProperties("todolist") + @JsonIgnoreProperties({"todolist","membre"}) private Team team; @OneToMany(mappedBy = "todolist", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("todolist")