From b87499ba73949e532262eee11b08e486e17b1f83 Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Fri, 18 Feb 2022 17:16:53 +0100 Subject: [PATCH 1/4] modification du controleur contact et du controler membre --- .../dto/controller/ContactController.java | 6 +++- .../dto/controller/MembreController.java | 34 ++----------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/main/java/fr/organizee/dto/controller/ContactController.java b/src/main/java/fr/organizee/dto/controller/ContactController.java index e9eeacc..3c2a0a3 100644 --- a/src/main/java/fr/organizee/dto/controller/ContactController.java +++ b/src/main/java/fr/organizee/dto/controller/ContactController.java @@ -20,6 +20,7 @@ public class ContactController { @Autowired private ContactRepository contactRepo; + //Récupère les infos d'un contact par son ID @GetMapping(value = "/{id}") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity findById(@PathVariable int id){ @@ -34,6 +35,7 @@ public class ContactController { return ResponseEntity.status(HttpStatus.OK).body(contact); } + //Récupère les infos d'un contact par la team ID @GetMapping(value = "team/{team_id}") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity findByTeamId(@PathVariable int team_id){ @@ -44,10 +46,10 @@ public class ContactController { } catch (Exception e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); } - return ResponseEntity.status(HttpStatus.OK).body(contacts); } + //Ajoute un nouveau contact @PostMapping(value="/add") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity addContact(@RequestBody Contact contact){ @@ -61,6 +63,7 @@ public class ContactController { return ResponseEntity.status(HttpStatus.CREATED).body(resultContact); } + //Mise à jour du contact par son ID @PutMapping("/update/{id}") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity updateContact(@RequestBody Contact contact, @PathVariable Integer id) throws Exception { @@ -75,6 +78,7 @@ public class ContactController { return ResponseEntity.status(HttpStatus.OK).body(resultContact); } + //Efface le contact par on ID @DeleteMapping(value = "/delete/{id}") //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteContact(@PathVariable int id){ diff --git a/src/main/java/fr/organizee/dto/controller/MembreController.java b/src/main/java/fr/organizee/dto/controller/MembreController.java index 5db618c..68ccb84 100644 --- a/src/main/java/fr/organizee/dto/controller/MembreController.java +++ b/src/main/java/fr/organizee/dto/controller/MembreController.java @@ -45,7 +45,7 @@ public class MembreController { // Récupère tout les membres de la base @GetMapping(value = "/all") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity getAll(){ List liste = null; try @@ -59,7 +59,7 @@ public class MembreController { } @GetMapping("/admin/all") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public List getAllAdminUsers() { return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList()); @@ -168,34 +168,4 @@ public class MembreController { return ResponseEntity.status(HttpStatus.OK).body(resultMembre); } - -// UPDATE SUR UN CHAMPS -// @PutMapping("/update/{id}") -// public ResponseEntity updateMembre(@RequestBody Membre membre, @PathVariable Integer id) throws Exception { -// Membre resultMembre = null; -// Membre oldMembre = membreRepo.getById(id); -// oldMembre.setNom(membre.getNom()); -// //Membre resultMembre = membreRepo.getById(id); -// try { -// resultMembre = membreRepo.save(oldMembre); -// -// } catch (Exception e) { -// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); -// } -// -// return ResponseEntity.status(HttpStatus.OK).body(resultMembre); -// } - -// @GetMapping(value = "/team/{id}") -// public ResponseEntity findTeamById(@PathVariable int id){ -// Optional liste = null; -// try -// { -// liste = teamRepo.findById(id); -// } catch (Exception e) { -// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); -// } -// -// return ResponseEntity.status(HttpStatus.OK).body(liste); -// } } From 623c744ee9b50107f2224dd35adb1020cb759b16 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:19:15 +0100 Subject: [PATCH 2/4] menus de la semaine --- .../fr/organizee/controller/MembreController.java | 2 +- .../fr/organizee/controller/MenuController.java | 8 ++++++-- src/main/java/fr/organizee/model/Menu.java | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 93df3d8..6fd0b3c 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -45,7 +45,7 @@ public class MembreController { // Récupère tout les membres de la base @GetMapping(value = "/all") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity getAll(){ List liste = null; try diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java index 0ea98e3..4b18a32 100644 --- a/src/main/java/fr/organizee/controller/MenuController.java +++ b/src/main/java/fr/organizee/controller/MenuController.java @@ -67,11 +67,15 @@ public class MenuController { } //Mise a jour d'un menu par son ID - @PutMapping("/update/{id}") + @PutMapping("/update/{team_id}/{id}") //@PreAuthorize("hasRole('ROLE_PARENT')") - public ResponseEntity updateMenu(@RequestBody Menu menu, @PathVariable Integer id) throws Exception { + public ResponseEntity updateMenu(@RequestBody Menu menu, @PathVariable Integer team_id, @PathVariable Integer id) throws Exception { Menu resultMenu = null; try { + menu.setId(menuRepository.findById(id).get().getId()); + Team team=new Team(); + team.setId(team_id); + menu.setTeam(team); resultMenu = menuRepository.save(menu); } catch (Exception e) { diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index 22a1ab1..458e80c 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -12,6 +12,7 @@ public class Menu { private int id; private String libelle; private LocalDate dateMenu; + private String repas; // private int validationProposition; @ManyToOne @JoinColumn(name="TEAM_ID") @@ -21,10 +22,10 @@ public class Menu { public Menu() { } - public Menu(String libelle, LocalDate dateMenu, Team team) { + public Menu(String libelle, LocalDate dateMenu,String repas, Team team) { this.libelle = libelle; this.dateMenu = dateMenu; - //this.validationProposition=validationProposition; + this.repas= repas; this.team = team; } @@ -52,6 +53,14 @@ public class Menu { this.dateMenu = dateMenu; } + public String getRepas() { + return repas; + } + + public void setRepas(String repas) { + this.repas = repas; + } + // public int getValidationProposition() { // return validationProposition; //} @@ -75,6 +84,7 @@ public class Menu { ", libelle='" + libelle + '\'' + ", dateMenu=" + dateMenu + ", team=" + team + + ", repas=" + repas + '}'; } } From 287deb99e508e16ce542c79990b5b95909e831be Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Fri, 18 Feb 2022 17:51:34 +0100 Subject: [PATCH 3/4] controler hors du dto --- .../java/fr/organizee/{dto => }/controller/ContactController.java | 0 .../fr/organizee/{dto => }/controller/EvenementController.java | 0 .../java/fr/organizee/{dto => }/controller/MailController.java | 0 .../java/fr/organizee/{dto => }/controller/MembreController.java | 0 .../java/fr/organizee/{dto => }/controller/MenuController.java | 0 .../java/fr/organizee/{dto => }/controller/TacheController.java | 0 .../java/fr/organizee/{dto => }/controller/TeamController.java | 0 .../fr/organizee/{dto => }/controller/TodoListController.java | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename src/main/java/fr/organizee/{dto => }/controller/ContactController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/EvenementController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/MailController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/MembreController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/MenuController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/TacheController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/TeamController.java (100%) rename src/main/java/fr/organizee/{dto => }/controller/TodoListController.java (100%) diff --git a/src/main/java/fr/organizee/dto/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/ContactController.java rename to src/main/java/fr/organizee/controller/ContactController.java diff --git a/src/main/java/fr/organizee/dto/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/EvenementController.java rename to src/main/java/fr/organizee/controller/EvenementController.java diff --git a/src/main/java/fr/organizee/dto/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/MailController.java rename to src/main/java/fr/organizee/controller/MailController.java diff --git a/src/main/java/fr/organizee/dto/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/MembreController.java rename to src/main/java/fr/organizee/controller/MembreController.java diff --git a/src/main/java/fr/organizee/dto/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/MenuController.java rename to src/main/java/fr/organizee/controller/MenuController.java diff --git a/src/main/java/fr/organizee/dto/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/TacheController.java rename to src/main/java/fr/organizee/controller/TacheController.java diff --git a/src/main/java/fr/organizee/dto/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/TeamController.java rename to src/main/java/fr/organizee/controller/TeamController.java diff --git a/src/main/java/fr/organizee/dto/controller/TodoListController.java b/src/main/java/fr/organizee/controller/TodoListController.java similarity index 100% rename from src/main/java/fr/organizee/dto/controller/TodoListController.java rename to src/main/java/fr/organizee/controller/TodoListController.java From bc5a22186f75f5b09af22a17a3a0324826dd17df Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Fri, 18 Feb 2022 17:56:52 +0100 Subject: [PATCH 4/4] push de a branch --- src/main/java/fr/organizee/controller/ContactController.java | 2 +- src/main/java/fr/organizee/controller/EvenementController.java | 2 +- src/main/java/fr/organizee/controller/MailController.java | 2 +- src/main/java/fr/organizee/controller/MembreController.java | 2 +- src/main/java/fr/organizee/controller/MenuController.java | 2 +- src/main/java/fr/organizee/controller/TacheController.java | 2 +- src/main/java/fr/organizee/controller/TeamController.java | 2 +- src/main/java/fr/organizee/controller/TodoListController.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/organizee/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java index 3c2a0a3..3e18da6 100644 --- a/src/main/java/fr/organizee/controller/ContactController.java +++ b/src/main/java/fr/organizee/controller/ContactController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.Contact; import fr.organizee.repository.ContactRepository; diff --git a/src/main/java/fr/organizee/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java index c1a3582..f6a32a8 100644 --- a/src/main/java/fr/organizee/controller/EvenementController.java +++ b/src/main/java/fr/organizee/controller/EvenementController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.Evenement; import fr.organizee.model.Menu; diff --git a/src/main/java/fr/organizee/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java index e89b43f..3543668 100644 --- a/src/main/java/fr/organizee/controller/MailController.java +++ b/src/main/java/fr/organizee/controller/MailController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.Mail; import fr.organizee.service.SendMailService; diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 68ccb84..12c4efe 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.dto.JsonWebToken; import fr.organizee.dto.MembreDto; diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java index 14cf8ba..4b18a32 100644 --- a/src/main/java/fr/organizee/controller/MenuController.java +++ b/src/main/java/fr/organizee/controller/MenuController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.Menu; import fr.organizee.model.Team; diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 224dd14..58e5ccc 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.Tache; import fr.organizee.model.TodoList; diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index 67f7907..1d96ae5 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.Team; import fr.organizee.repository.TeamRepository; diff --git a/src/main/java/fr/organizee/controller/TodoListController.java b/src/main/java/fr/organizee/controller/TodoListController.java index f166cf3..747eff9 100644 --- a/src/main/java/fr/organizee/controller/TodoListController.java +++ b/src/main/java/fr/organizee/controller/TodoListController.java @@ -1,4 +1,4 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.model.TodoList; import fr.organizee.repository.TodoListRepository;