From 4c700c979ed7365e38e14f1e8436496936376f77 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Thu, 20 Jan 2022 09:37:11 +0100 Subject: [PATCH 01/40] commit pour pull --- .idea/compiler.xml | 1 + .../controller/MembreController.java | 6 ++--- src/main/resources/data.sql | 24 +++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index a8c4885..6f8f4ad 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,6 +6,7 @@ + diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index d200dc3..c69d234 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -1,9 +1,9 @@ package fr.organizee.controller; import fr.organizee.model.Membre; -//import fr.organizee.model.Team; +import fr.organizee.model.Team; import fr.organizee.repository.MembreRepository; -//import fr.organizee.repository.TeamRepository; +import fr.organizee.repository.TeamRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -22,7 +22,7 @@ public class MembreController { @Autowired private MembreRepository membreRepo; -// @Autowired + // @Autowired // private TeamRepository teamRepo; // @RequestMapping("/membres") diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 298f168..3f92821 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -11,7 +11,7 @@ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; --- Export de la structure de la table jpa. contact +-- Export de la structure de la table organizee.contact CREATE TABLE IF NOT EXISTS `contact` ( `id` int(11) NOT NULL AUTO_INCREMENT, `adresse` varchar(255) DEFAULT NULL, @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( CONSTRAINT `FK7gyd9s84tx9eeuigeu3uv984x` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; --- Export de données de la table jpa.contact : ~0 rows (environ) +-- Export de données de la table organizee.contact : ~0 rows (environ) /*!40000 ALTER TABLE `contact` DISABLE KEYS */; INSERT INTO `contact` (`id`, `adresse`, `date_naissance`, `email`, `nom`, `prenom`, `telephone`, `team_id`) VALUES (1, '7554 Messerschmidt Center', '2021-01-24', 'oogleasane0@cargocollective.com', 'Ophelia', 'O\'Gleasane', '913-198-6499', 1), @@ -41,7 +41,7 @@ INSERT INTO `contact` (`id`, `adresse`, `date_naissance`, `email`, `nom`, `preno (10, '1 Westridge Road', '2021-03-11', 'emebs9@uol.com.br', 'Evered', 'Mebs', '898-483-6075', 4); /*!40000 ALTER TABLE `contact` ENABLE KEYS */; --- Export de la structure de la table jpa. membre +-- Export de la structure de la table organizee.membre CREATE TABLE IF NOT EXISTS `membre` ( `id` int(11) NOT NULL AUTO_INCREMENT, `couleur` varchar(255) DEFAULT NULL, @@ -58,7 +58,7 @@ CREATE TABLE IF NOT EXISTS `membre` ( CONSTRAINT `FKll5mmgkw1h2kmxnuo4885x2fn` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4; --- Export de données de la table jpa.membre : ~0 rows (environ) +-- Export de données de la table organizee.membre : ~0 rows (environ) /*!40000 ALTER TABLE `membre` DISABLE KEYS */; INSERT INTO `membre` (`id`, `couleur`, `date_naissance`, `email`, `is_admin`, `nom`, `password`, `prenom`, `smiley`, `team_id`) VALUES (1, '#fcba03', '2021-12-13', 'hedi@simplon.com', '0', 'SKYWALKER', 'toto', 'Hédi', NULL, 1), @@ -69,7 +69,7 @@ INSERT INTO `membre` (`id`, `couleur`, `date_naissance`, `email`, `is_admin`, `n (6, '#ed09de', '2021-10-29', 'cecile@simplon.com', '0', 'R2D2', 'loulou', 'Cecile', NULL, 4); /*!40000 ALTER TABLE `membre` ENABLE KEYS */; --- Export de la structure de la table jpa. menu +-- Export de la structure de la table organizee.menu CREATE TABLE IF NOT EXISTS `menu` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date_menu` date DEFAULT NULL, @@ -83,11 +83,11 @@ CREATE TABLE IF NOT EXISTS `menu` ( CONSTRAINT `FKky2j5l3syborv9dtqtprgpr28` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; --- Export de données de la table jpa.menu : ~0 rows (environ) +-- Export de données de la table organizee.menu : ~0 rows (environ) /*!40000 ALTER TABLE `menu` DISABLE KEYS */; /*!40000 ALTER TABLE `menu` ENABLE KEYS */; --- Export de la structure de la table jpa. tache +-- Export de la structure de la table organizee.tache CREATE TABLE IF NOT EXISTS `tache` ( `id` int(11) NOT NULL AUTO_INCREMENT, `etat` bit(1) DEFAULT NULL, @@ -98,7 +98,7 @@ CREATE TABLE IF NOT EXISTS `tache` ( CONSTRAINT `FK50q0ja9qvoud7ujsudc9jj9yk` FOREIGN KEY (`todolist_id`) REFERENCES `todo_list` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4; --- Export de données de la table jpa.tache : ~0 rows (environ) +-- Export de données de la table organizee.tache : ~0 rows (environ) /*!40000 ALTER TABLE `tache` DISABLE KEYS */; INSERT INTO `tache` (`id`, `etat`, `texte`, `todolist_id`) VALUES (1, b'0', 'Apprendre le PHP', 1), @@ -108,14 +108,14 @@ INSERT INTO `tache` (`id`, `etat`, `texte`, `todolist_id`) VALUES (5, b'0', 'Trouver un repas', 3); /*!40000 ALTER TABLE `tache` ENABLE KEYS */; --- Export de la structure de la table jpa. team +-- Export de la structure de la table organizee.team CREATE TABLE IF NOT EXISTS `team` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4; --- Export de données de la table jpa.team : ~0 rows (environ) +-- Export de données de la table organizee.team : ~0 rows (environ) /*!40000 ALTER TABLE `team` DISABLE KEYS */; INSERT INTO `team` (`id`, `nom`) VALUES (1, 'Team JAVA'), @@ -124,7 +124,7 @@ INSERT INTO `team` (`id`, `nom`) VALUES (4, 'Team Bancal'); /*!40000 ALTER TABLE `team` ENABLE KEYS */; --- Export de la structure de la table jpa. todo_list +-- Export de la structure de la table organizee.todo_list CREATE TABLE IF NOT EXISTS `todo_list` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) DEFAULT NULL, @@ -134,7 +134,7 @@ CREATE TABLE IF NOT EXISTS `todo_list` ( CONSTRAINT `FK6ty40hkdysbql7xaewhujsjg` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4; --- Export de données de la table jpa.todo_list : ~0 rows (environ) +-- Export de données de la table organizee.todo_list : ~0 rows (environ) /*!40000 ALTER TABLE `todo_list` DISABLE KEYS */; INSERT INTO `todo_list` (`id`, `nom`, `team_id`) VALUES (1, 'Pour Blandine', 1), From b874fb16a24c7c6eddd48715af03ae1cffa5cea4 Mon Sep 17 00:00:00 2001 From: AlineRinquin <90188226+AlineRinquin@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:37:14 +0100 Subject: [PATCH 02/40] commit pour pull --- .idea/Organizee.iml | 9 --------- .idea/compiler.xml | 2 ++ pom.xml | 13 +++++++------ 3 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 .idea/Organizee.iml diff --git a/.idea/Organizee.iml b/.idea/Organizee.iml deleted file mode 100644 index d6ebd48..0000000 --- a/.idea/Organizee.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index a8c4885..c75fd2a 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,11 +6,13 @@ + diff --git a/pom.xml b/pom.xml index 32eb628..9b437f5 100644 --- a/pom.xml +++ b/pom.xml @@ -2,12 +2,7 @@ 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.6.1 - - + fr.organizee organizee 0.0.1-SNAPSHOT @@ -16,6 +11,12 @@ 11 + + org.springframework.boot + spring-boot-starter-parent + 2.6.1 + + org.springframework.boot From 096e9074460454f59084cc91addb4f15d185eca8 Mon Sep 17 00:00:00 2001 From: Hedi Date: Thu, 20 Jan 2022 09:41:07 +0100 Subject: [PATCH 03/40] debut de tache controller --- .../controller/EvenementController.java | 37 ++++++ .../organizee/controller/TacheController.java | 85 ++++++++++++++ .../java/fr/organizee/model/Evenement.java | 107 ++++++++++++++++++ .../repository/EvenementRepository.java | 9 ++ .../organizee/repository/TacheRepository.java | 7 +- 5 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/organizee/controller/EvenementController.java create mode 100644 src/main/java/fr/organizee/controller/TacheController.java create mode 100644 src/main/java/fr/organizee/model/Evenement.java create mode 100644 src/main/java/fr/organizee/repository/EvenementRepository.java diff --git a/src/main/java/fr/organizee/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java new file mode 100644 index 0000000..a5c3673 --- /dev/null +++ b/src/main/java/fr/organizee/controller/EvenementController.java @@ -0,0 +1,37 @@ +package fr.organizee.controller; + +import fr.organizee.model.Evenement; +import fr.organizee.model.Membre; +import fr.organizee.model.Team; +import fr.organizee.repository.EvenementRepository; +import fr.organizee.repository.TeamRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Optional; + +@RestController +@CrossOrigin("*") +@RequestMapping("/evenements") +public class EvenementController { + + @Autowired + private EvenementRepository evenementRepo; + + // Recupérer tout les evenements pour une team {id} + @GetMapping(value = "/all/{id}") + public ResponseEntity getAll(){ + List liste = null; + try + { + liste = evenementRepo.findAll(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(liste); + } +} diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java new file mode 100644 index 0000000..8408ada --- /dev/null +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -0,0 +1,85 @@ +package fr.organizee.controller; + +import fr.organizee.model.Membre; +import fr.organizee.model.Tache; +import fr.organizee.repository.MembreRepository; +import fr.organizee.repository.TacheRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.persistence.EntityNotFoundException; +import java.util.List; +import java.util.Optional; + +@RestController +@CrossOrigin("*") +@RequestMapping("/taches") +public class TacheController { + @Autowired + private TacheRepository tacheRepo; + + @GetMapping(value = "/all") + public ResponseEntity getAll(){ + List liste = null; + try + { + liste = tacheRepo.findAll(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(liste); + } + + @GetMapping(value = "/{id}") + public ResponseEntity findById(@PathVariable int id){ + Optional tache = null; + try + { + tache = tacheRepo.findById(id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(tache); + } + + @DeleteMapping(value = "/delete/{id}") + public ResponseEntity deleteTache(@PathVariable int id){ + try { + tacheRepo.delete(tacheRepo.getById(id)); + return ResponseEntity.status(HttpStatus.OK).body("Tache effacée !"); + + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Tache introuvable !"); + } + } + + @PostMapping(value="/add", produces="application/json", consumes="application/json") + public ResponseEntity addTache(@RequestBody Tache tache){ + Tache resultTache = null; + try { + resultTache = tacheRepo.saveAndFlush(tache); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); + } + + @PutMapping("/update/{id}") + public ResponseEntity updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { + Tache resultTache = null; + try { + resultTache = tacheRepo.save(tache); + + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.OK).body(resultTache); + } +} diff --git a/src/main/java/fr/organizee/model/Evenement.java b/src/main/java/fr/organizee/model/Evenement.java new file mode 100644 index 0000000..15a355f --- /dev/null +++ b/src/main/java/fr/organizee/model/Evenement.java @@ -0,0 +1,107 @@ +package fr.organizee.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +public class Evenement { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + private LocalDateTime eventDebut; + private LocalDateTime eventFin; + private int allDay; + private String libelle; + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="MEMBRE_ID") + @JsonIgnoreProperties("evenement") + private Membre membre; + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="TEAM_ID") + @JsonIgnoreProperties("evenement") + private Team team; + + public Evenement() { + } + + public Evenement(int id, LocalDateTime eventDebut, LocalDateTime eventFin, int allDay, String libelle, Membre membre, Team team) { + this.id = id; + this.eventDebut = eventDebut; + this.eventFin = eventFin; + this.allDay = allDay; + this.libelle = libelle; + this.membre = membre; + this.team = team; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public LocalDateTime getEventDebut() { + return eventDebut; + } + + public void setEventDebut(LocalDateTime eventDebut) { + this.eventDebut = eventDebut; + } + + public LocalDateTime getEventFin() { + return eventFin; + } + + public void setEventFin(LocalDateTime eventFin) { + this.eventFin = eventFin; + } + + public int getAllDay() { + return allDay; + } + + public void setAllDay(int allDay) { + this.allDay = allDay; + } + + public String getLibelle() { + return libelle; + } + + public void setLibelle(String libelle) { + this.libelle = libelle; + } + + public Membre getMembre() { + return membre; + } + + public void setMembre(Membre membre) { + this.membre = membre; + } + + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team = team; + } + + @Override + public String toString() { + return "Evenement{" + + "id=" + id + + ", eventDebut=" + eventDebut + + ", eventFin=" + eventFin + + ", allDay=" + allDay + + ", libelle='" + libelle + '\'' + + ", membre=" + membre + + ", team=" + team + + '}'; + } +} diff --git a/src/main/java/fr/organizee/repository/EvenementRepository.java b/src/main/java/fr/organizee/repository/EvenementRepository.java new file mode 100644 index 0000000..51164c5 --- /dev/null +++ b/src/main/java/fr/organizee/repository/EvenementRepository.java @@ -0,0 +1,9 @@ +package fr.organizee.repository; + +import fr.organizee.model.Evenement; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EvenementRepository extends JpaRepository { +} diff --git a/src/main/java/fr/organizee/repository/TacheRepository.java b/src/main/java/fr/organizee/repository/TacheRepository.java index 17c22b8..2e52ef2 100644 --- a/src/main/java/fr/organizee/repository/TacheRepository.java +++ b/src/main/java/fr/organizee/repository/TacheRepository.java @@ -1,4 +1,9 @@ package fr.organizee.repository; -public interface TacheRepository { +import fr.organizee.model.Tache; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface TacheRepository extends JpaRepository { } From 63e8f73f4e1dc30bbd4b4c9caea80782ddae9328 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Thu, 20 Jan 2022 17:57:00 +0100 Subject: [PATCH 04/40] sign-up + forgot-password + rester-pwd non complet --- .../controller/MembreController.java | 39 +++++++++++++++++++ src/main/java/fr/organizee/model/Membre.java | 28 +------------ .../repository/MembreRepository.java | 9 +++++ .../fr/organizee/service/MembreService.java | 7 +++- .../organizee/service/MembreServiceImpl.java | 18 +++++++-- 5 files changed, 71 insertions(+), 30 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index e80f339..9c47b3f 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.*; import javax.persistence.EntityNotFoundException; @@ -32,6 +33,9 @@ public class MembreController { @Autowired private MembreService membreService; + @Autowired + private BCryptPasswordEncoder passwordEncoder; + // @Autowired // private TeamRepository teamRepo; @@ -66,6 +70,41 @@ public class MembreController { } + @GetMapping("/forgot-password") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + public ResponseEntity findUserByEmail(@RequestBody Membre findUserByEmail) + { + try { + + this.membreService.findUserByEmail(findUserByEmail); + return ResponseEntity.ok("ok"); + } catch(Exception e) + { + return ResponseEntity.notFound().build(); + } + } + + @PutMapping("/reset-password/{email}") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + public ResponseEntity updatePassword(@RequestBody String password, @PathVariable String email) throws Exception { + Membre resultMembre; + try { + resultMembre = this.membreService.chercheEmail(email); + + System.out.println(resultMembre); + + resultMembre.setPassword(passwordEncoder.encode(password)); + + this.membreRepo.save(resultMembre); + + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.OK).body(resultMembre); + } + + // @GetMapping(value = "/team/all") // public ResponseEntity getAllTeam(){ // List liste = null; diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index 5733712..2bb7e53 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -44,24 +44,16 @@ public class Membre { public Membre() { } - public Membre(String nom, String prenom, LocalDate dateNaissance, @NotNull String email, @NotNull String password, String isAdmin, String couleur, String smiley, Team team, List roleList) { + public Membre(String nom, String prenom, LocalDate dateNaissance, Team team, @NotNull String email, @NotNull String password, List roleList) { this.nom = nom; this.prenom = prenom; this.dateNaissance = dateNaissance; this.email = email; this.password = password; - this.isAdmin = isAdmin; - this.couleur = couleur; - this.smiley = smiley; this.team = team; this.roleList=roleList; } - public Membre(@NotNull String email, @NotNull String password, List roleList) { - this.email = email; - this.password = password; - this.roleList=roleList; - } public int getId() { @@ -114,23 +106,7 @@ public class Membre { this.team = team; } - public String getCouleur() { - return couleur; - } - - public void setCouleur(String couleur) { - this.couleur = couleur; - } - - public String getSmiley() { - return smiley; - } - - public void setSmiley(String smiley) { - this.smiley = smiley; - } - - public List getRoleList() { + public List getRoleList() { return roleList; } public void setRoleList(List roleList) { diff --git a/src/main/java/fr/organizee/repository/MembreRepository.java b/src/main/java/fr/organizee/repository/MembreRepository.java index f431da3..137f203 100644 --- a/src/main/java/fr/organizee/repository/MembreRepository.java +++ b/src/main/java/fr/organizee/repository/MembreRepository.java @@ -1,9 +1,13 @@ package fr.organizee.repository; +import fr.organizee.model.Contact; import fr.organizee.model.Membre; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository @@ -12,7 +16,12 @@ public interface MembreRepository extends JpaRepository { Optional findByEmail(String email); + @Query(value = "select * from membre where email = :email", nativeQuery = true) + Membre chercheEmail(@Param("email") String email); + boolean existsByEmail(String email); void deleteByEmail(String email); + + } diff --git a/src/main/java/fr/organizee/service/MembreService.java b/src/main/java/fr/organizee/service/MembreService.java index 4000c67..66d57be 100644 --- a/src/main/java/fr/organizee/service/MembreService.java +++ b/src/main/java/fr/organizee/service/MembreService.java @@ -29,6 +29,7 @@ public interface MembreService { */ String signup(Membre membre) throws ExistingUsernameException; + /** * Methode qui retourne tous les utilisateurs de la bd * @return the list of all application users. @@ -40,6 +41,10 @@ public interface MembreService { * @param email the username to look for. * @return an Optional object containing user if found, empty otherwise. */ - Optional findUserByEmail(String email); + Optional findUserByEmail(Membre membre); + Optional findByEmail(String email); + + Membre chercheEmail(String email); + } diff --git a/src/main/java/fr/organizee/service/MembreServiceImpl.java b/src/main/java/fr/organizee/service/MembreServiceImpl.java index 6304d86..2e23b02 100644 --- a/src/main/java/fr/organizee/service/MembreServiceImpl.java +++ b/src/main/java/fr/organizee/service/MembreServiceImpl.java @@ -48,7 +48,7 @@ public class MembreServiceImpl implements MembreService { @Override public String signup(Membre membre) throws ExistingUsernameException { if (!membreRepository.existsByEmail(membre.getEmail())) { - Membre membreToSave = new Membre(membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); + Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); membreRepository.save(membreToSave); return jwtTokenProvider.createToken(membre.getEmail(), membre.getRoleList()); } else { @@ -62,8 +62,20 @@ public class MembreServiceImpl implements MembreService { } @Override - public Optional findUserByEmail(String email) { - return membreRepository.findByEmail(email); + public Optional findUserByEmail(Membre membre) { + return this.membreRepository.findByEmail(membre.getEmail()); } + + @Override + public Optional findByEmail(String email) { + return this.membreRepository.findByEmail(email); + } + + @Override + public Membre chercheEmail(String email) { + return this.membreRepository.chercheEmail(email); + } + + } From 8d481cece84d26cf776f19f06a8142450a68bf17 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Fri, 21 Jan 2022 12:55:15 +0100 Subject: [PATCH 05/40] reset password fonctionne --- .../controller/MembreController.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 9c47b3f..0ff9b67 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -69,19 +69,20 @@ public class MembreController { return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList()); } - + //cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas @GetMapping("/forgot-password") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") - public ResponseEntity findUserByEmail(@RequestBody Membre findUserByEmail) - { - try { + public ResponseEntity findUserByEmail(@RequestBody Membre findUserByEmail) { + try { this.membreService.findUserByEmail(findUserByEmail); - return ResponseEntity.ok("ok"); - } catch(Exception e) - { - return ResponseEntity.notFound().build(); + return ResponseEntity.status(HttpStatus.OK).body("Email trouvé !"); + + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Email introuvable !"); } + } @PutMapping("/reset-password/{email}") @@ -95,7 +96,10 @@ public class MembreController { resultMembre.setPassword(passwordEncoder.encode(password)); + System.out.println(password); + this.membreRepo.save(resultMembre); + System.out.println(resultMembre.getPassword()); } catch (Exception e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); From 094a61951a934c45588f5980ab8e5fae7b618dc3 Mon Sep 17 00:00:00 2001 From: Hedi Date: Fri, 21 Jan 2022 14:45:37 +0100 Subject: [PATCH 06/40] fix: pb update en cascade, ajout de Tache et Todolist (class et repository) --- .idea/compiler.xml | 1 + .../controller/ContactController.java | 3 - .../controller/MembreController.java | 36 ++------- .../organizee/controller/MenuController.java | 18 +++-- .../organizee/controller/TacheController.java | 22 +++++- .../organizee/controller/TeamController.java | 3 +- .../controller/TodoListController.java | 75 +++++++++++++++++++ src/main/java/fr/organizee/model/Contact.java | 2 +- src/main/java/fr/organizee/model/Membre.java | 2 +- src/main/java/fr/organizee/model/Menu.java | 25 ++++++- src/main/java/fr/organizee/model/Tache.java | 2 +- src/main/java/fr/organizee/model/Team.java | 8 +- .../java/fr/organizee/model/TodoList.java | 24 +++++- .../organizee/repository/TacheRepository.java | 8 ++ .../repository/TodoListRepository.java | 7 ++ 15 files changed, 180 insertions(+), 56 deletions(-) create mode 100644 src/main/java/fr/organizee/controller/TodoListController.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index c75fd2a..a500b21 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,6 +7,7 @@ + diff --git a/src/main/java/fr/organizee/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java index 5186d12..ef79042 100644 --- a/src/main/java/fr/organizee/controller/ContactController.java +++ b/src/main/java/fr/organizee/controller/ContactController.java @@ -1,10 +1,7 @@ package fr.organizee.controller; import fr.organizee.model.Contact; -import fr.organizee.model.Membre; -import fr.organizee.model.Team; import fr.organizee.repository.ContactRepository; -import fr.organizee.repository.TeamRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index e80f339..b4a85db 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -5,9 +5,7 @@ import fr.organizee.dto.MembreDto; import fr.organizee.exception.ExistingUsernameException; import fr.organizee.exception.InvalidCredentialsException; import fr.organizee.model.Membre; -//import fr.organizee.model.Team; import fr.organizee.repository.MembreRepository; -//import fr.organizee.repository.TeamRepository; import fr.organizee.service.MembreService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -32,10 +30,6 @@ public class MembreController { @Autowired private MembreService membreService; -// @Autowired -// private TeamRepository teamRepo; - -// @RequestMapping("/membres") @ResponseBody public String home() { @@ -45,6 +39,7 @@ public class MembreController { return sb.toString(); } + // Récupère tout les membres de la base @GetMapping(value = "/all") @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity getAll(){ @@ -66,21 +61,9 @@ public class MembreController { } -// @GetMapping(value = "/team/all") -// public ResponseEntity getAllTeam(){ -// List liste = null; -// try -// { -// liste = teamRepo.findAll(); -// } catch (Exception e) { -// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); -// } -// -// return ResponseEntity.status(HttpStatus.OK).body(liste); -// } - + //Récupérer les informations d'un membre par son ID @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 membre = null; try @@ -93,13 +76,7 @@ public class MembreController { return ResponseEntity.status(HttpStatus.OK).body(membre); } -// @GetMapping(value = "/membres/delete/{id}") -// public void deleteMembreId(@PathVariable("id") Integer id) { -// -// membreRepo.deleteById(id); -// -// } - + //Efface un membre par son ID @DeleteMapping(value = "/delete/{id}") @PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteMembre(@PathVariable int id){ @@ -114,6 +91,7 @@ public class MembreController { } } + //Ajouter un membre et inscription @PostMapping("/sign-up") public ResponseEntity signUp(@RequestBody Membre membre) { try { @@ -123,6 +101,7 @@ public class MembreController { } } + //Login @PostMapping("/sign-in") public ResponseEntity signIn(@RequestBody Membre membre) { try { @@ -132,8 +111,9 @@ public class MembreController { } } + //Met a jour les informations d'un membre par son ID @PutMapping("/update/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity updateMembre(@RequestBody Membre membre, @PathVariable Integer id) throws Exception { Membre resultMembre = null; try { diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java index f4e4ec8..b7db085 100644 --- a/src/main/java/fr/organizee/controller/MenuController.java +++ b/src/main/java/fr/organizee/controller/MenuController.java @@ -1,6 +1,5 @@ package fr.organizee.controller; -import fr.organizee.model.Contact; import fr.organizee.model.Menu; import fr.organizee.repository.MenuRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -21,8 +20,9 @@ public class MenuController { @Autowired private MenuRepository menuRepository; + //Récupère les infos d'un menu par son ID @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 menu = null; try @@ -35,8 +35,9 @@ public class MenuController { return ResponseEntity.status(HttpStatus.OK).body(menu); } + //Récupère les infos des menus par la team ID @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 menus = null; try { @@ -47,8 +48,9 @@ public class MenuController { return ResponseEntity.status(HttpStatus.OK).body(menus); } + //Ajoute un nouveau menu @PostMapping(value="/add") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity addMenu(@RequestBody Menu menu){ Menu resultMenu = null; try { @@ -60,8 +62,9 @@ public class MenuController { return ResponseEntity.status(HttpStatus.CREATED).body(resultMenu); } + //Mise a jour d'un menu par son ID @PutMapping("/update/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity updateMenu(@RequestBody Menu menu, @PathVariable Integer id) throws Exception { Menu resultMenu = null; try { @@ -71,11 +74,12 @@ public class MenuController { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); } - return ResponseEntity.status(HttpStatus.OK).body(menuRepository); + return ResponseEntity.status(HttpStatus.OK).body(resultMenu); } + //Efface un menu par son ID @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteMenu(@PathVariable int id){ try { menuRepository.delete(menuRepository.getById(id)); diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 8408ada..681d760 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -1,12 +1,11 @@ package fr.organizee.controller; -import fr.organizee.model.Membre; import fr.organizee.model.Tache; -import fr.organizee.repository.MembreRepository; import fr.organizee.repository.TacheRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.persistence.EntityNotFoundException; @@ -20,6 +19,7 @@ public class TacheController { @Autowired private TacheRepository tacheRepo; + // Récupère toutes les taches de toutes la base toutes team confondu @GetMapping(value = "/all") public ResponseEntity getAll(){ List liste = null; @@ -33,6 +33,7 @@ public class TacheController { return ResponseEntity.status(HttpStatus.OK).body(liste); } + // Récupère les infos d'une tache avec son ID @GetMapping(value = "/{id}") public ResponseEntity findById(@PathVariable int id){ Optional tache = null; @@ -46,6 +47,7 @@ public class TacheController { return ResponseEntity.status(HttpStatus.OK).body(tache); } + // Efface une tache avec son ID @DeleteMapping(value = "/delete/{id}") public ResponseEntity deleteTache(@PathVariable int id){ try { @@ -58,6 +60,7 @@ public class TacheController { } } + // Ajoute une tache @PostMapping(value="/add", produces="application/json", consumes="application/json") public ResponseEntity addTache(@RequestBody Tache tache){ Tache resultTache = null; @@ -70,6 +73,7 @@ public class TacheController { return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); } + //Met a jour les informations d'une date avec son ID @PutMapping("/update/{id}") public ResponseEntity updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { Tache resultTache = null; @@ -82,4 +86,18 @@ public class TacheController { return ResponseEntity.status(HttpStatus.OK).body(resultTache); } + + //A revoir, résultat a chier, passez par la todolist + @GetMapping(value = "team/{team_id}") + public ResponseEntity findByTeamId(@PathVariable int team_id){ + List taches = null; + try + { + taches = tacheRepo.FindTachesByTeam(team_id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(taches); + } } diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index f8766ca..7b6d9d3 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -1,6 +1,5 @@ package fr.organizee.controller; -import fr.organizee.model.Membre; import fr.organizee.model.Team; import fr.organizee.repository.TeamRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +47,7 @@ public class TeamController { } @GetMapping(value = "/{id}") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity findTeamById(@PathVariable int id){ Optional liste = null; try diff --git a/src/main/java/fr/organizee/controller/TodoListController.java b/src/main/java/fr/organizee/controller/TodoListController.java new file mode 100644 index 0000000..747eff9 --- /dev/null +++ b/src/main/java/fr/organizee/controller/TodoListController.java @@ -0,0 +1,75 @@ +package fr.organizee.controller; + +import fr.organizee.model.TodoList; +import fr.organizee.repository.TodoListRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.persistence.EntityNotFoundException; +import java.util.List; + +@RestController +@CrossOrigin("*") +@RequestMapping("/todolist") +public class TodoListController { + + @Autowired + private TodoListRepository todolistRepo; + + @GetMapping(value = "/all") + public ResponseEntity getAll(){ + List liste = null; + try + { + liste = todolistRepo.findAll(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(liste); + } + + @DeleteMapping(value = "/delete/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT')") + public ResponseEntity deleteTodolist(@PathVariable int id){ + try { + todolistRepo.delete(todolistRepo.getById(id)); + //membreRepo.deleteById(id); + return ResponseEntity.status(HttpStatus.OK).body("Todolist effacée !"); + + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Todolist introuvable !"); + } + } + + @GetMapping(value = "/team/{team_id}") + public ResponseEntity findByTeamId(@PathVariable int team_id){ + List todoLists = null; + try + { + todoLists = todolistRepo.FindTodolistByTeam(team_id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(todoLists); + } + + //Met a jour les informations d'une date avec son ID + @PutMapping("/update/{id}") + public ResponseEntity updateTodolist(@RequestBody TodoList todolist, @PathVariable Integer id) throws Exception { + TodoList resultTodolist = null; + try { + resultTodolist = todolistRepo.save(todolist); + + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.OK).body(resultTodolist); + } +} diff --git a/src/main/java/fr/organizee/model/Contact.java b/src/main/java/fr/organizee/model/Contact.java index ccd14c6..2c5ffb2 100644 --- a/src/main/java/fr/organizee/model/Contact.java +++ b/src/main/java/fr/organizee/model/Contact.java @@ -16,7 +16,7 @@ public class Contact { private String email; private String adresse; private LocalDate dateNaissance; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("contact") private Team team; diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index 5733712..d54a360 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -36,7 +36,7 @@ public class Membre { // @ManyToOne // @JoinColumn(name="TEAM_ID") // @JsonIgnore - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("membre") private Team team; diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index b486e2b..e11cba4 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -13,20 +13,19 @@ public class Menu { private String libelle; private LocalDate dateMenu; private int validationProposition; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("menu") private Team team; - @ManyToOne - private Membre membre; public Menu() { } - public Menu(String libelle, LocalDate dateMenu, int validationProposition) { + public Menu(String libelle, LocalDate dateMenu, int validationProposition, Team team) { this.libelle = libelle; this.dateMenu = dateMenu; this.validationProposition=validationProposition; + this.team = team; } public int getId() { @@ -53,12 +52,30 @@ public class Menu { this.dateMenu = dateMenu; } + public int getValidationProposition() { + return validationProposition; + } + + public void setValidationProposition(int validationProposition) { + this.validationProposition = validationProposition; + } + + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team = team; + } + @Override public String toString() { return "Menu{" + "id=" + id + ", libelle='" + libelle + '\'' + ", dateMenu=" + dateMenu + + ", validationProposition=" + validationProposition + + ", team=" + team + '}'; } } diff --git a/src/main/java/fr/organizee/model/Tache.java b/src/main/java/fr/organizee/model/Tache.java index e3d9d03..a21965a 100644 --- a/src/main/java/fr/organizee/model/Tache.java +++ b/src/main/java/fr/organizee/model/Tache.java @@ -11,7 +11,7 @@ public class Tache { private int id; private String texte; private Boolean etat; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TODOLIST_ID") @JsonIgnoreProperties("tache") private TodoList todolist; diff --git a/src/main/java/fr/organizee/model/Team.java b/src/main/java/fr/organizee/model/Team.java index 1da65d5..ded5837 100644 --- a/src/main/java/fr/organizee/model/Team.java +++ b/src/main/java/fr/organizee/model/Team.java @@ -12,16 +12,16 @@ public class Team { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List membres = new ArrayList<>(); - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List contacts = new ArrayList<>(); - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List todolists = new ArrayList<>(); - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List menus = new ArrayList<>(); diff --git a/src/main/java/fr/organizee/model/TodoList.java b/src/main/java/fr/organizee/model/TodoList.java index 01f0328..007e68a 100644 --- a/src/main/java/fr/organizee/model/TodoList.java +++ b/src/main/java/fr/organizee/model/TodoList.java @@ -12,10 +12,13 @@ public class TodoList { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("todolist") private Team team; + @OneToMany(mappedBy = "todolist", fetch=FetchType.LAZY, cascade = CascadeType.ALL) + @JsonIgnoreProperties("todolist") + private List taches = new ArrayList<>(); public TodoList() { } @@ -40,11 +43,26 @@ public class TodoList { this.nom = nom; } + public List getTaches() { + return taches; + } + + public void setTaches(List taches) { + this.taches = taches; + } + + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team = team; + } + @Override public String toString() { return "TodoList{" + "id=" + id + - ", nom='" + nom + '\'' + - '}'; + ", nom='" + nom + ", taches='" + taches + "}"; } } diff --git a/src/main/java/fr/organizee/repository/TacheRepository.java b/src/main/java/fr/organizee/repository/TacheRepository.java index 2e52ef2..a9ac6f9 100644 --- a/src/main/java/fr/organizee/repository/TacheRepository.java +++ b/src/main/java/fr/organizee/repository/TacheRepository.java @@ -2,8 +2,16 @@ package fr.organizee.repository; import fr.organizee.model.Tache; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface TacheRepository extends JpaRepository { + + // N'est plus utilisé normalement + @Query(value = "select * from todo_list, tache where todo_list.team_id = :team_id and todo_list.id = tache.todolist_id", nativeQuery = true) + List FindTachesByTeam(@Param("team_id") int team_id); } diff --git a/src/main/java/fr/organizee/repository/TodoListRepository.java b/src/main/java/fr/organizee/repository/TodoListRepository.java index 32a2e63..c922953 100644 --- a/src/main/java/fr/organizee/repository/TodoListRepository.java +++ b/src/main/java/fr/organizee/repository/TodoListRepository.java @@ -1,9 +1,16 @@ package fr.organizee.repository; +import fr.organizee.model.Menu; import fr.organizee.model.TodoList; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface TodoListRepository extends JpaRepository { + @Query(value = "select * from todo_list where team_id = :team_id", nativeQuery = true) + List FindTodolistByTeam(@Param("team_id") int team_id); } From 657a31cc63114529fdb7aa849215082ae0361941 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Fri, 21 Jan 2022 14:47:59 +0100 Subject: [PATCH 07/40] modif methode sign-up et controller membre et model membre --- src/main/java/fr/organizee/model/Membre.java | 9 ++++++++- .../java/fr/organizee/service/MembreServiceImpl.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index 2bb7e53..3cabf24 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -44,9 +44,10 @@ public class Membre { public Membre() { } - public Membre(String nom, String prenom, LocalDate dateNaissance, Team team, @NotNull String email, @NotNull String password, List roleList) { + public Membre(String nom, String prenom, String couleur, LocalDate dateNaissance, Team team, @NotNull String email, @NotNull String password, List roleList) { this.nom = nom; this.prenom = prenom; + this.couleur = couleur; this.dateNaissance = dateNaissance; this.email = email; this.password = password; @@ -65,6 +66,12 @@ public class Membre { public String getNom() { return nom; } + public String getCouleur() { + return couleur; + } + public void setCouleur(String couleur) { + this.couleur = couleur; + } public void setNom(String nom) { this.nom = nom; } diff --git a/src/main/java/fr/organizee/service/MembreServiceImpl.java b/src/main/java/fr/organizee/service/MembreServiceImpl.java index 2e23b02..2197bbc 100644 --- a/src/main/java/fr/organizee/service/MembreServiceImpl.java +++ b/src/main/java/fr/organizee/service/MembreServiceImpl.java @@ -48,7 +48,7 @@ public class MembreServiceImpl implements MembreService { @Override public String signup(Membre membre) throws ExistingUsernameException { if (!membreRepository.existsByEmail(membre.getEmail())) { - Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); + Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getCouleur(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); membreRepository.save(membreToSave); return jwtTokenProvider.createToken(membre.getEmail(), membre.getRoleList()); } else { From 5af749ddb2d933802621fe408f50ddc4d6972704 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Fri, 21 Jan 2022 14:53:13 +0100 Subject: [PATCH 08/40] push obligatoire ne pas merger ma branche --- .idea/compiler.xml | 5 ----- .../fr/organizee/controller/MembreController.java | 12 ++---------- .../java/fr/organizee/controller/TeamController.java | 2 +- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index b197f48..6f8f4ad 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,17 +6,12 @@ -<<<<<<< HEAD -======= - ->>>>>>> b147bc406c22caa9c817c7189a325058d8550a69 diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 20af2fb..20102fa 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -5,14 +5,10 @@ import fr.organizee.dto.MembreDto; import fr.organizee.exception.ExistingUsernameException; import fr.organizee.exception.InvalidCredentialsException; import fr.organizee.model.Membre; -import fr.organizee.model.Team; +//import fr.organizee.model.Team; import fr.organizee.repository.MembreRepository; -<<<<<<< HEAD -import fr.organizee.repository.TeamRepository; -======= //import fr.organizee.repository.TeamRepository; import fr.organizee.service.MembreService; ->>>>>>> b147bc406c22caa9c817c7189a325058d8550a69 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -34,9 +30,6 @@ public class MembreController { @Autowired private MembreRepository membreRepo; -<<<<<<< HEAD - // @Autowired -======= @Autowired private MembreService membreService; @@ -44,10 +37,9 @@ public class MembreController { private BCryptPasswordEncoder passwordEncoder; // @Autowired ->>>>>>> b147bc406c22caa9c817c7189a325058d8550a69 // private TeamRepository teamRepo; -// @RequestMapping("/membres") + // @RequestMapping("/membres") @ResponseBody public String home() { diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index f8766ca..6429e22 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -22,7 +22,7 @@ public class TeamController { @Autowired private TeamRepository teamRepo; -// @RequestMapping("/teams") + // @RequestMapping("/teams") @ResponseBody public String home() { From fbc5d8378045000da45d523a9e7151683b456450 Mon Sep 17 00:00:00 2001 From: Hedi Date: Fri, 21 Jan 2022 18:33:37 +0100 Subject: [PATCH 09/40] fix merge bis --- .../java/fr/organizee/controller/MembreController.java | 2 +- src/main/java/fr/organizee/controller/TeamController.java | 8 ++++---- src/main/java/fr/organizee/model/Membre.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 90c1433..93df3d8 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -121,7 +121,7 @@ public class MembreController { //Efface un membre par son ID @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteMembre(@PathVariable int id){ try { membreRepo.delete(membreRepo.getById(id)); diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index 7b6d9d3..1d96ae5 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -33,7 +33,7 @@ public class TeamController { // Récupération de toutes les teams @GetMapping(value = "/all") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity getAllTeam(){ List liste = null; try @@ -61,7 +61,7 @@ public class TeamController { } @PostMapping(value="/add", produces="application/json", consumes="application/json") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity addTeam(@RequestBody Team team){ Team resultTeam = null; try { @@ -74,7 +74,7 @@ public class TeamController { } @PutMapping("/update/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity updateTeam(@RequestBody Team team, @PathVariable Integer id) throws Exception { Team resultTeam = null; try { @@ -88,7 +88,7 @@ public class TeamController { } @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteTeam(@PathVariable int id){ try { teamRepo.delete(teamRepo.getById(id)); diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index 231359d..c8cc3d8 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -36,7 +36,7 @@ public class Membre { // @ManyToOne // @JoinColumn(name="TEAM_ID") // @JsonIgnore - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("membre") private Team team; From 6c69774bb1a42b4536be6a075120078267fbe789 Mon Sep 17 00:00:00 2001 From: Hedi Date: Thu, 20 Jan 2022 09:41:07 +0100 Subject: [PATCH 10/40] debut de tache controller --- .../controller/EvenementController.java | 37 ++++++ .../organizee/controller/TacheController.java | 85 ++++++++++++++ .../java/fr/organizee/model/Evenement.java | 107 ++++++++++++++++++ .../repository/EvenementRepository.java | 9 ++ .../organizee/repository/TacheRepository.java | 7 +- 5 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/organizee/controller/EvenementController.java create mode 100644 src/main/java/fr/organizee/controller/TacheController.java create mode 100644 src/main/java/fr/organizee/model/Evenement.java create mode 100644 src/main/java/fr/organizee/repository/EvenementRepository.java diff --git a/src/main/java/fr/organizee/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java new file mode 100644 index 0000000..a5c3673 --- /dev/null +++ b/src/main/java/fr/organizee/controller/EvenementController.java @@ -0,0 +1,37 @@ +package fr.organizee.controller; + +import fr.organizee.model.Evenement; +import fr.organizee.model.Membre; +import fr.organizee.model.Team; +import fr.organizee.repository.EvenementRepository; +import fr.organizee.repository.TeamRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Optional; + +@RestController +@CrossOrigin("*") +@RequestMapping("/evenements") +public class EvenementController { + + @Autowired + private EvenementRepository evenementRepo; + + // Recupérer tout les evenements pour une team {id} + @GetMapping(value = "/all/{id}") + public ResponseEntity getAll(){ + List liste = null; + try + { + liste = evenementRepo.findAll(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(liste); + } +} diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java new file mode 100644 index 0000000..8408ada --- /dev/null +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -0,0 +1,85 @@ +package fr.organizee.controller; + +import fr.organizee.model.Membre; +import fr.organizee.model.Tache; +import fr.organizee.repository.MembreRepository; +import fr.organizee.repository.TacheRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.persistence.EntityNotFoundException; +import java.util.List; +import java.util.Optional; + +@RestController +@CrossOrigin("*") +@RequestMapping("/taches") +public class TacheController { + @Autowired + private TacheRepository tacheRepo; + + @GetMapping(value = "/all") + public ResponseEntity getAll(){ + List liste = null; + try + { + liste = tacheRepo.findAll(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(liste); + } + + @GetMapping(value = "/{id}") + public ResponseEntity findById(@PathVariable int id){ + Optional tache = null; + try + { + tache = tacheRepo.findById(id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(tache); + } + + @DeleteMapping(value = "/delete/{id}") + public ResponseEntity deleteTache(@PathVariable int id){ + try { + tacheRepo.delete(tacheRepo.getById(id)); + return ResponseEntity.status(HttpStatus.OK).body("Tache effacée !"); + + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Tache introuvable !"); + } + } + + @PostMapping(value="/add", produces="application/json", consumes="application/json") + public ResponseEntity addTache(@RequestBody Tache tache){ + Tache resultTache = null; + try { + resultTache = tacheRepo.saveAndFlush(tache); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); + } + + @PutMapping("/update/{id}") + public ResponseEntity updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { + Tache resultTache = null; + try { + resultTache = tacheRepo.save(tache); + + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.OK).body(resultTache); + } +} diff --git a/src/main/java/fr/organizee/model/Evenement.java b/src/main/java/fr/organizee/model/Evenement.java new file mode 100644 index 0000000..15a355f --- /dev/null +++ b/src/main/java/fr/organizee/model/Evenement.java @@ -0,0 +1,107 @@ +package fr.organizee.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.*; +import java.time.LocalDateTime; + +@Entity +public class Evenement { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + private LocalDateTime eventDebut; + private LocalDateTime eventFin; + private int allDay; + private String libelle; + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="MEMBRE_ID") + @JsonIgnoreProperties("evenement") + private Membre membre; + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="TEAM_ID") + @JsonIgnoreProperties("evenement") + private Team team; + + public Evenement() { + } + + public Evenement(int id, LocalDateTime eventDebut, LocalDateTime eventFin, int allDay, String libelle, Membre membre, Team team) { + this.id = id; + this.eventDebut = eventDebut; + this.eventFin = eventFin; + this.allDay = allDay; + this.libelle = libelle; + this.membre = membre; + this.team = team; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public LocalDateTime getEventDebut() { + return eventDebut; + } + + public void setEventDebut(LocalDateTime eventDebut) { + this.eventDebut = eventDebut; + } + + public LocalDateTime getEventFin() { + return eventFin; + } + + public void setEventFin(LocalDateTime eventFin) { + this.eventFin = eventFin; + } + + public int getAllDay() { + return allDay; + } + + public void setAllDay(int allDay) { + this.allDay = allDay; + } + + public String getLibelle() { + return libelle; + } + + public void setLibelle(String libelle) { + this.libelle = libelle; + } + + public Membre getMembre() { + return membre; + } + + public void setMembre(Membre membre) { + this.membre = membre; + } + + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team = team; + } + + @Override + public String toString() { + return "Evenement{" + + "id=" + id + + ", eventDebut=" + eventDebut + + ", eventFin=" + eventFin + + ", allDay=" + allDay + + ", libelle='" + libelle + '\'' + + ", membre=" + membre + + ", team=" + team + + '}'; + } +} diff --git a/src/main/java/fr/organizee/repository/EvenementRepository.java b/src/main/java/fr/organizee/repository/EvenementRepository.java new file mode 100644 index 0000000..51164c5 --- /dev/null +++ b/src/main/java/fr/organizee/repository/EvenementRepository.java @@ -0,0 +1,9 @@ +package fr.organizee.repository; + +import fr.organizee.model.Evenement; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EvenementRepository extends JpaRepository { +} diff --git a/src/main/java/fr/organizee/repository/TacheRepository.java b/src/main/java/fr/organizee/repository/TacheRepository.java index 17c22b8..2e52ef2 100644 --- a/src/main/java/fr/organizee/repository/TacheRepository.java +++ b/src/main/java/fr/organizee/repository/TacheRepository.java @@ -1,4 +1,9 @@ package fr.organizee.repository; -public interface TacheRepository { +import fr.organizee.model.Tache; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface TacheRepository extends JpaRepository { } From c33d1282c7f1cc6fc59fa4da1a3ff41b9834d6ba Mon Sep 17 00:00:00 2001 From: Hedi Date: Fri, 21 Jan 2022 14:45:37 +0100 Subject: [PATCH 11/40] fix: pb update en cascade, ajout de Tache et Todolist (class et repository) --- .idea/compiler.xml | 1 + .../controller/ContactController.java | 3 - .../organizee/controller/MenuController.java | 18 +++-- .../organizee/controller/TacheController.java | 22 +++++- .../organizee/controller/TeamController.java | 3 +- .../controller/TodoListController.java | 75 +++++++++++++++++++ src/main/java/fr/organizee/model/Contact.java | 2 +- src/main/java/fr/organizee/model/Membre.java | 2 +- src/main/java/fr/organizee/model/Menu.java | 25 ++++++- src/main/java/fr/organizee/model/Tache.java | 2 +- src/main/java/fr/organizee/model/Team.java | 8 +- .../java/fr/organizee/model/TodoList.java | 24 +++++- .../organizee/repository/TacheRepository.java | 8 ++ .../repository/TodoListRepository.java | 7 ++ 14 files changed, 172 insertions(+), 28 deletions(-) create mode 100644 src/main/java/fr/organizee/controller/TodoListController.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index c75fd2a..a500b21 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,6 +7,7 @@ + diff --git a/src/main/java/fr/organizee/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java index 5186d12..ef79042 100644 --- a/src/main/java/fr/organizee/controller/ContactController.java +++ b/src/main/java/fr/organizee/controller/ContactController.java @@ -1,10 +1,7 @@ package fr.organizee.controller; import fr.organizee.model.Contact; -import fr.organizee.model.Membre; -import fr.organizee.model.Team; import fr.organizee.repository.ContactRepository; -import fr.organizee.repository.TeamRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java index f4e4ec8..b7db085 100644 --- a/src/main/java/fr/organizee/controller/MenuController.java +++ b/src/main/java/fr/organizee/controller/MenuController.java @@ -1,6 +1,5 @@ package fr.organizee.controller; -import fr.organizee.model.Contact; import fr.organizee.model.Menu; import fr.organizee.repository.MenuRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -21,8 +20,9 @@ public class MenuController { @Autowired private MenuRepository menuRepository; + //Récupère les infos d'un menu par son ID @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 menu = null; try @@ -35,8 +35,9 @@ public class MenuController { return ResponseEntity.status(HttpStatus.OK).body(menu); } + //Récupère les infos des menus par la team ID @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 menus = null; try { @@ -47,8 +48,9 @@ public class MenuController { return ResponseEntity.status(HttpStatus.OK).body(menus); } + //Ajoute un nouveau menu @PostMapping(value="/add") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity addMenu(@RequestBody Menu menu){ Menu resultMenu = null; try { @@ -60,8 +62,9 @@ public class MenuController { return ResponseEntity.status(HttpStatus.CREATED).body(resultMenu); } + //Mise a jour d'un menu par son ID @PutMapping("/update/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity updateMenu(@RequestBody Menu menu, @PathVariable Integer id) throws Exception { Menu resultMenu = null; try { @@ -71,11 +74,12 @@ public class MenuController { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); } - return ResponseEntity.status(HttpStatus.OK).body(menuRepository); + return ResponseEntity.status(HttpStatus.OK).body(resultMenu); } + //Efface un menu par son ID @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteMenu(@PathVariable int id){ try { menuRepository.delete(menuRepository.getById(id)); diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 8408ada..681d760 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -1,12 +1,11 @@ package fr.organizee.controller; -import fr.organizee.model.Membre; import fr.organizee.model.Tache; -import fr.organizee.repository.MembreRepository; import fr.organizee.repository.TacheRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import javax.persistence.EntityNotFoundException; @@ -20,6 +19,7 @@ public class TacheController { @Autowired private TacheRepository tacheRepo; + // Récupère toutes les taches de toutes la base toutes team confondu @GetMapping(value = "/all") public ResponseEntity getAll(){ List liste = null; @@ -33,6 +33,7 @@ public class TacheController { return ResponseEntity.status(HttpStatus.OK).body(liste); } + // Récupère les infos d'une tache avec son ID @GetMapping(value = "/{id}") public ResponseEntity findById(@PathVariable int id){ Optional tache = null; @@ -46,6 +47,7 @@ public class TacheController { return ResponseEntity.status(HttpStatus.OK).body(tache); } + // Efface une tache avec son ID @DeleteMapping(value = "/delete/{id}") public ResponseEntity deleteTache(@PathVariable int id){ try { @@ -58,6 +60,7 @@ public class TacheController { } } + // Ajoute une tache @PostMapping(value="/add", produces="application/json", consumes="application/json") public ResponseEntity addTache(@RequestBody Tache tache){ Tache resultTache = null; @@ -70,6 +73,7 @@ public class TacheController { return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); } + //Met a jour les informations d'une date avec son ID @PutMapping("/update/{id}") public ResponseEntity updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { Tache resultTache = null; @@ -82,4 +86,18 @@ public class TacheController { return ResponseEntity.status(HttpStatus.OK).body(resultTache); } + + //A revoir, résultat a chier, passez par la todolist + @GetMapping(value = "team/{team_id}") + public ResponseEntity findByTeamId(@PathVariable int team_id){ + List taches = null; + try + { + taches = tacheRepo.FindTachesByTeam(team_id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(taches); + } } diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index f8766ca..7b6d9d3 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -1,6 +1,5 @@ package fr.organizee.controller; -import fr.organizee.model.Membre; import fr.organizee.model.Team; import fr.organizee.repository.TeamRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +47,7 @@ public class TeamController { } @GetMapping(value = "/{id}") - @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") public ResponseEntity findTeamById(@PathVariable int id){ Optional liste = null; try diff --git a/src/main/java/fr/organizee/controller/TodoListController.java b/src/main/java/fr/organizee/controller/TodoListController.java new file mode 100644 index 0000000..747eff9 --- /dev/null +++ b/src/main/java/fr/organizee/controller/TodoListController.java @@ -0,0 +1,75 @@ +package fr.organizee.controller; + +import fr.organizee.model.TodoList; +import fr.organizee.repository.TodoListRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.persistence.EntityNotFoundException; +import java.util.List; + +@RestController +@CrossOrigin("*") +@RequestMapping("/todolist") +public class TodoListController { + + @Autowired + private TodoListRepository todolistRepo; + + @GetMapping(value = "/all") + public ResponseEntity getAll(){ + List liste = null; + try + { + liste = todolistRepo.findAll(); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(liste); + } + + @DeleteMapping(value = "/delete/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT')") + public ResponseEntity deleteTodolist(@PathVariable int id){ + try { + todolistRepo.delete(todolistRepo.getById(id)); + //membreRepo.deleteById(id); + return ResponseEntity.status(HttpStatus.OK).body("Todolist effacée !"); + + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Todolist introuvable !"); + } + } + + @GetMapping(value = "/team/{team_id}") + public ResponseEntity findByTeamId(@PathVariable int team_id){ + List todoLists = null; + try + { + todoLists = todolistRepo.FindTodolistByTeam(team_id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + + return ResponseEntity.status(HttpStatus.OK).body(todoLists); + } + + //Met a jour les informations d'une date avec son ID + @PutMapping("/update/{id}") + public ResponseEntity updateTodolist(@RequestBody TodoList todolist, @PathVariable Integer id) throws Exception { + TodoList resultTodolist = null; + try { + resultTodolist = todolistRepo.save(todolist); + + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.OK).body(resultTodolist); + } +} diff --git a/src/main/java/fr/organizee/model/Contact.java b/src/main/java/fr/organizee/model/Contact.java index ccd14c6..2c5ffb2 100644 --- a/src/main/java/fr/organizee/model/Contact.java +++ b/src/main/java/fr/organizee/model/Contact.java @@ -16,7 +16,7 @@ public class Contact { private String email; private String adresse; private LocalDate dateNaissance; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("contact") private Team team; diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index 2bb7e53..c0dda4c 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -36,7 +36,7 @@ public class Membre { // @ManyToOne // @JoinColumn(name="TEAM_ID") // @JsonIgnore - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("membre") private Team team; diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index b486e2b..e11cba4 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -13,20 +13,19 @@ public class Menu { private String libelle; private LocalDate dateMenu; private int validationProposition; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("menu") private Team team; - @ManyToOne - private Membre membre; public Menu() { } - public Menu(String libelle, LocalDate dateMenu, int validationProposition) { + public Menu(String libelle, LocalDate dateMenu, int validationProposition, Team team) { this.libelle = libelle; this.dateMenu = dateMenu; this.validationProposition=validationProposition; + this.team = team; } public int getId() { @@ -53,12 +52,30 @@ public class Menu { this.dateMenu = dateMenu; } + public int getValidationProposition() { + return validationProposition; + } + + public void setValidationProposition(int validationProposition) { + this.validationProposition = validationProposition; + } + + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team = team; + } + @Override public String toString() { return "Menu{" + "id=" + id + ", libelle='" + libelle + '\'' + ", dateMenu=" + dateMenu + + ", validationProposition=" + validationProposition + + ", team=" + team + '}'; } } diff --git a/src/main/java/fr/organizee/model/Tache.java b/src/main/java/fr/organizee/model/Tache.java index e3d9d03..a21965a 100644 --- a/src/main/java/fr/organizee/model/Tache.java +++ b/src/main/java/fr/organizee/model/Tache.java @@ -11,7 +11,7 @@ public class Tache { private int id; private String texte; private Boolean etat; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TODOLIST_ID") @JsonIgnoreProperties("tache") private TodoList todolist; diff --git a/src/main/java/fr/organizee/model/Team.java b/src/main/java/fr/organizee/model/Team.java index 1da65d5..ded5837 100644 --- a/src/main/java/fr/organizee/model/Team.java +++ b/src/main/java/fr/organizee/model/Team.java @@ -12,16 +12,16 @@ public class Team { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List membres = new ArrayList<>(); - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List contacts = new ArrayList<>(); - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List todolists = new ArrayList<>(); - @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL) @JsonIgnoreProperties("team") private List menus = new ArrayList<>(); diff --git a/src/main/java/fr/organizee/model/TodoList.java b/src/main/java/fr/organizee/model/TodoList.java index 01f0328..007e68a 100644 --- a/src/main/java/fr/organizee/model/TodoList.java +++ b/src/main/java/fr/organizee/model/TodoList.java @@ -12,10 +12,13 @@ public class TodoList { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; - @ManyToOne(cascade = CascadeType.MERGE) + @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("todolist") private Team team; + @OneToMany(mappedBy = "todolist", fetch=FetchType.LAZY, cascade = CascadeType.ALL) + @JsonIgnoreProperties("todolist") + private List taches = new ArrayList<>(); public TodoList() { } @@ -40,11 +43,26 @@ public class TodoList { this.nom = nom; } + public List getTaches() { + return taches; + } + + public void setTaches(List taches) { + this.taches = taches; + } + + public Team getTeam() { + return team; + } + + public void setTeam(Team team) { + this.team = team; + } + @Override public String toString() { return "TodoList{" + "id=" + id + - ", nom='" + nom + '\'' + - '}'; + ", nom='" + nom + ", taches='" + taches + "}"; } } diff --git a/src/main/java/fr/organizee/repository/TacheRepository.java b/src/main/java/fr/organizee/repository/TacheRepository.java index 2e52ef2..a9ac6f9 100644 --- a/src/main/java/fr/organizee/repository/TacheRepository.java +++ b/src/main/java/fr/organizee/repository/TacheRepository.java @@ -2,8 +2,16 @@ package fr.organizee.repository; import fr.organizee.model.Tache; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface TacheRepository extends JpaRepository { + + // N'est plus utilisé normalement + @Query(value = "select * from todo_list, tache where todo_list.team_id = :team_id and todo_list.id = tache.todolist_id", nativeQuery = true) + List FindTachesByTeam(@Param("team_id") int team_id); } diff --git a/src/main/java/fr/organizee/repository/TodoListRepository.java b/src/main/java/fr/organizee/repository/TodoListRepository.java index 32a2e63..c922953 100644 --- a/src/main/java/fr/organizee/repository/TodoListRepository.java +++ b/src/main/java/fr/organizee/repository/TodoListRepository.java @@ -1,9 +1,16 @@ package fr.organizee.repository; +import fr.organizee.model.Menu; import fr.organizee.model.TodoList; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface TodoListRepository extends JpaRepository { + @Query(value = "select * from todo_list where team_id = :team_id", nativeQuery = true) + List FindTodolistByTeam(@Param("team_id") int team_id); } From 865a5847ccc96aa8c158ac2830a3774bcf65e68d Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Fri, 21 Jan 2022 14:47:59 +0100 Subject: [PATCH 12/40] modif methode sign-up et controller membre et model membre --- src/main/java/fr/organizee/model/Membre.java | 9 ++++++++- .../java/fr/organizee/service/MembreServiceImpl.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index c0dda4c..a314ef2 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -44,9 +44,10 @@ public class Membre { public Membre() { } - public Membre(String nom, String prenom, LocalDate dateNaissance, Team team, @NotNull String email, @NotNull String password, List roleList) { + public Membre(String nom, String prenom, String couleur, LocalDate dateNaissance, Team team, @NotNull String email, @NotNull String password, List roleList) { this.nom = nom; this.prenom = prenom; + this.couleur = couleur; this.dateNaissance = dateNaissance; this.email = email; this.password = password; @@ -65,6 +66,12 @@ public class Membre { public String getNom() { return nom; } + public String getCouleur() { + return couleur; + } + public void setCouleur(String couleur) { + this.couleur = couleur; + } public void setNom(String nom) { this.nom = nom; } diff --git a/src/main/java/fr/organizee/service/MembreServiceImpl.java b/src/main/java/fr/organizee/service/MembreServiceImpl.java index 2e23b02..2197bbc 100644 --- a/src/main/java/fr/organizee/service/MembreServiceImpl.java +++ b/src/main/java/fr/organizee/service/MembreServiceImpl.java @@ -48,7 +48,7 @@ public class MembreServiceImpl implements MembreService { @Override public String signup(Membre membre) throws ExistingUsernameException { if (!membreRepository.existsByEmail(membre.getEmail())) { - Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); + Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getCouleur(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); membreRepository.save(membreToSave); return jwtTokenProvider.createToken(membre.getEmail(), membre.getRoleList()); } else { From 165da077289eab1e677564bdd3719c7b6929bec0 Mon Sep 17 00:00:00 2001 From: Hedi Date: Fri, 21 Jan 2022 18:33:37 +0100 Subject: [PATCH 13/40] fix merge bis --- .../java/fr/organizee/controller/MembreController.java | 2 +- src/main/java/fr/organizee/controller/TeamController.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 0ff9b67..89f9a3f 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -144,7 +144,7 @@ public class MembreController { // } @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteMembre(@PathVariable int id){ try { membreRepo.delete(membreRepo.getById(id)); diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index 7b6d9d3..1d96ae5 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -33,7 +33,7 @@ public class TeamController { // Récupération de toutes les teams @GetMapping(value = "/all") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity getAllTeam(){ List liste = null; try @@ -61,7 +61,7 @@ public class TeamController { } @PostMapping(value="/add", produces="application/json", consumes="application/json") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity addTeam(@RequestBody Team team){ Team resultTeam = null; try { @@ -74,7 +74,7 @@ public class TeamController { } @PutMapping("/update/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity updateTeam(@RequestBody Team team, @PathVariable Integer id) throws Exception { Team resultTeam = null; try { @@ -88,7 +88,7 @@ public class TeamController { } @DeleteMapping(value = "/delete/{id}") - @PreAuthorize("hasRole('ROLE_PARENT')") + //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteTeam(@PathVariable int id){ try { teamRepo.delete(teamRepo.getById(id)); From b47c3fdf6d61b46ee3a71847c036ae20fe28afc0 Mon Sep 17 00:00:00 2001 From: Hedi Date: Mon, 24 Jan 2022 23:06:27 +0100 Subject: [PATCH 14/40] feat(mail):ajout d'envoi de mail au format text, HTML, avec piece jointe --- pom.xml | 5 +- .../organizee/controller/MailController.java | 40 +++++++++++ src/main/java/fr/organizee/model/Mail.java | 41 +++++++++++ .../fr/organizee/service/SendMailService.java | 15 ++++ .../service/SendMailServiceImpl.java | 68 +++++++++++++++++++ 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/organizee/controller/MailController.java create mode 100644 src/main/java/fr/organizee/model/Mail.java create mode 100644 src/main/java/fr/organizee/service/SendMailService.java create mode 100644 src/main/java/fr/organizee/service/SendMailServiceImpl.java diff --git a/pom.xml b/pom.xml index dbaf653..0d03dbb 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,10 @@ org.springframework.boot spring-boot-starter-web - + + org.springframework.boot + spring-boot-starter-mail + mysql mysql-connector-java diff --git a/src/main/java/fr/organizee/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java new file mode 100644 index 0000000..ad07b51 --- /dev/null +++ b/src/main/java/fr/organizee/controller/MailController.java @@ -0,0 +1,40 @@ +package fr.organizee.controller; + +import fr.organizee.model.Mail; +import fr.organizee.service.SendMailService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.mail.MessagingException; + +@RestController +@RequestMapping("/mail") +public class MailController { + SendMailService service; + + public MailController(SendMailService service) { + this.service = service; + } + + @PostMapping("/send") + public ResponseEntity sendMail(@RequestBody Mail mail) { + service.sendMail(mail); + return new ResponseEntity<>("Email Sent successfully", HttpStatus.OK); + } + + @PostMapping("/html") + public ResponseEntity sendMailHTML(@RequestBody Mail mail) throws MessagingException { + service.sendMailHTML(mail); + return new ResponseEntity<>("HTML mail sent successfully", HttpStatus.OK); + } + + @PostMapping("/attachment") + public ResponseEntity sendAttachmentEmail(@RequestBody Mail mail) throws MessagingException { + service.sendMailWithAttachments(mail); + return new ResponseEntity<>("Attachment mail sent successfully", HttpStatus.OK); + } +} \ No newline at end of file diff --git a/src/main/java/fr/organizee/model/Mail.java b/src/main/java/fr/organizee/model/Mail.java new file mode 100644 index 0000000..cbd551b --- /dev/null +++ b/src/main/java/fr/organizee/model/Mail.java @@ -0,0 +1,41 @@ +package fr.organizee.model; + +public class Mail { + private String recipient; + private String subject; + private String message; + + public Mail() { + } + + public Mail(String recipient, String subject, String message) { + this.recipient = recipient; + this.subject = subject; + this.message = message; + } + + public String getRecipient() { + return recipient; + } + + public void setRecipient(String recipient) { + this.recipient = recipient; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} + diff --git a/src/main/java/fr/organizee/service/SendMailService.java b/src/main/java/fr/organizee/service/SendMailService.java new file mode 100644 index 0000000..9437b10 --- /dev/null +++ b/src/main/java/fr/organizee/service/SendMailService.java @@ -0,0 +1,15 @@ +package fr.organizee.service; + +import fr.organizee.model.Mail; + +import javax.mail.MessagingException; + +public interface SendMailService { + void sendMail(Mail mail); + + void sendMailHTML(Mail mail) throws MessagingException; + + void sendMailWithAttachments(Mail mail) throws MessagingException; +} + + diff --git a/src/main/java/fr/organizee/service/SendMailServiceImpl.java b/src/main/java/fr/organizee/service/SendMailServiceImpl.java new file mode 100644 index 0000000..c77f675 --- /dev/null +++ b/src/main/java/fr/organizee/service/SendMailServiceImpl.java @@ -0,0 +1,68 @@ +package fr.organizee.service; + + +import fr.organizee.model.Mail; +import org.springframework.core.io.ClassPathResource; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.stereotype.Service; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +@Service +public class SendMailServiceImpl implements SendMailService { + private final JavaMailSender javaMailSender; + + public SendMailServiceImpl(JavaMailSender javaMailSender) { + this.javaMailSender = javaMailSender; + } + + @Override + public void sendMail(Mail mail) { + + SimpleMailMessage msg = new SimpleMailMessage(); + msg.setTo(mail.getRecipient(), mail.getRecipient()); + + msg.setSubject(mail.getSubject()); + msg.setText(mail.getMessage()); + + javaMailSender.send(msg); + } + + @Override + public void sendMailHTML(Mail mail) throws MessagingException { + MimeMessage msg = javaMailSender.createMimeMessage(); + + MimeMessageHelper helper = new MimeMessageHelper(msg, true, "utf-8"); + + helper.setTo(mail.getRecipient()); + + helper.setSubject(mail.getSubject()); + + String htmlMsg = "

Im testing send a HTML email

" + +""; + + msg.setContent(htmlMsg, "text/html"); + + javaMailSender.send(msg); + } + + @Override + public void sendMailWithAttachments(Mail mail) throws MessagingException { + MimeMessage msg = javaMailSender.createMimeMessage(); + + MimeMessageHelper helper = new MimeMessageHelper(msg, true); + + helper.setTo("to_@email"); + + helper.setSubject("Testing from Spring Boot"); + + helper.setText("Find the attached image", true); + + helper.addAttachment("hero.jpg", new ClassPathResource("hero.jpg")); + + javaMailSender.send(msg); + } +} \ No newline at end of file From f23b0fbb87809fad823cc5df0e8d8e3adff9cd9f Mon Sep 17 00:00:00 2001 From: Hedi Date: Fri, 28 Jan 2022 12:08:49 +0100 Subject: [PATCH 15/40] modif route controller mail --- src/main/java/fr/organizee/controller/MailController.java | 4 ++-- src/main/java/fr/organizee/service/SendMailServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java index ad07b51..c78984d 100644 --- a/src/main/java/fr/organizee/controller/MailController.java +++ b/src/main/java/fr/organizee/controller/MailController.java @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.mail.MessagingException; @RestController -@RequestMapping("/mail") +@RequestMapping("/sendmail") public class MailController { SendMailService service; @@ -20,7 +20,7 @@ public class MailController { this.service = service; } - @PostMapping("/send") + @PostMapping("/text") public ResponseEntity sendMail(@RequestBody Mail mail) { service.sendMail(mail); return new ResponseEntity<>("Email Sent successfully", HttpStatus.OK); diff --git a/src/main/java/fr/organizee/service/SendMailServiceImpl.java b/src/main/java/fr/organizee/service/SendMailServiceImpl.java index c77f675..ebb8f65 100644 --- a/src/main/java/fr/organizee/service/SendMailServiceImpl.java +++ b/src/main/java/fr/organizee/service/SendMailServiceImpl.java @@ -41,7 +41,7 @@ public class SendMailServiceImpl implements SendMailService { helper.setSubject(mail.getSubject()); - String htmlMsg = "

Im testing send a HTML email

" + String htmlMsg = "

Test d'envoi de mail au format HTML

" +""; msg.setContent(htmlMsg, "text/html"); From aece88e2a81f299f84ee7585b1493be153559609 Mon Sep 17 00:00:00 2001 From: Hedi Date: Sun, 30 Jan 2022 19:15:01 +0100 Subject: [PATCH 16/40] =?UTF-8?q?fix=20des=20class=20pour=20eviter=20la=20?= =?UTF-8?q?recursivit=C3=A9=20de=20certain=20en=20json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/organizee/controller/ContactController.java | 10 +++++----- src/main/java/fr/organizee/model/Contact.java | 3 ++- src/main/java/fr/organizee/model/Evenement.java | 7 ++++--- src/main/java/fr/organizee/model/Menu.java | 2 +- src/main/java/fr/organizee/model/Team.java | 8 ++++++++ src/main/java/fr/organizee/model/TodoList.java | 3 ++- 6 files changed, 22 insertions(+), 11 deletions(-) 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") From 382b1052d46418071d23f25f8272a68a4f4af265 Mon Sep 17 00:00:00 2001 From: Hedi MJID Date: Tue, 1 Feb 2022 09:17:11 +0100 Subject: [PATCH 17/40] commentaires --- src/main/java/fr/organizee/controller/MailController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/fr/organizee/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java index c78984d..3543668 100644 --- a/src/main/java/fr/organizee/controller/MailController.java +++ b/src/main/java/fr/organizee/controller/MailController.java @@ -20,18 +20,21 @@ public class MailController { this.service = service; } + // Envoi de mail en text brut @PostMapping("/text") public ResponseEntity sendMail(@RequestBody Mail mail) { service.sendMail(mail); return new ResponseEntity<>("Email Sent successfully", HttpStatus.OK); } + // Envoi de mail au format HTML @PostMapping("/html") public ResponseEntity sendMailHTML(@RequestBody Mail mail) throws MessagingException { service.sendMailHTML(mail); return new ResponseEntity<>("HTML mail sent successfully", HttpStatus.OK); } + // Envoi du mail avec une piece jointe @PostMapping("/attachment") public ResponseEntity sendAttachmentEmail(@RequestBody Mail mail) throws MessagingException { service.sendMailWithAttachments(mail); From ce88e646fddb7c6e7f4d0874720083865b073aed Mon Sep 17 00:00:00 2001 From: Hedi MJID Date: Tue, 1 Feb 2022 16:06:16 +0100 Subject: [PATCH 18/40] fix destinataire mail --- src/main/java/fr/organizee/service/SendMailServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/organizee/service/SendMailServiceImpl.java b/src/main/java/fr/organizee/service/SendMailServiceImpl.java index ebb8f65..c9974ca 100644 --- a/src/main/java/fr/organizee/service/SendMailServiceImpl.java +++ b/src/main/java/fr/organizee/service/SendMailServiceImpl.java @@ -55,7 +55,7 @@ public class SendMailServiceImpl implements SendMailService { MimeMessageHelper helper = new MimeMessageHelper(msg, true); - helper.setTo("to_@email"); + helper.setTo("destinataire@email"); helper.setSubject("Testing from Spring Boot"); From 7c352cad951c30a96cbb39937766896865ef5969 Mon Sep 17 00:00:00 2001 From: Hedi Date: Sat, 5 Feb 2022 15:36:35 +0100 Subject: [PATCH 19/40] calendrier : modif model + repository + controller --- .../controller/EvenementController.java | 55 ++++++++++++++++--- .../java/fr/organizee/model/Evenement.java | 44 +++++++-------- .../repository/EvenementRepository.java | 7 +++ src/main/resources/data.sql | 9 ++- 4 files changed, 84 insertions(+), 31 deletions(-) diff --git a/src/main/java/fr/organizee/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java index a5c3673..f6a32a8 100644 --- a/src/main/java/fr/organizee/controller/EvenementController.java +++ b/src/main/java/fr/organizee/controller/EvenementController.java @@ -1,15 +1,14 @@ package fr.organizee.controller; import fr.organizee.model.Evenement; -import fr.organizee.model.Membre; -import fr.organizee.model.Team; +import fr.organizee.model.Menu; import fr.organizee.repository.EvenementRepository; -import fr.organizee.repository.TeamRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import javax.persistence.EntityNotFoundException; import java.util.List; import java.util.Optional; @@ -21,17 +20,59 @@ public class EvenementController { @Autowired private EvenementRepository evenementRepo; - // Recupérer tout les evenements pour une team {id} - @GetMapping(value = "/all/{id}") - public ResponseEntity getAll(){ + // Recupérer tout les evenements pour une team {team_id} + @GetMapping(value = "/team/{team_id}") + public ResponseEntity findByTeamId(@PathVariable int team_id){ List liste = null; try { - liste = evenementRepo.findAll(); + liste = evenementRepo.FindEvenementsByTeam(team_id); } catch (Exception e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); } return ResponseEntity.status(HttpStatus.OK).body(liste); } + + // Ajoute un evenement au calendrier + @PostMapping(value="/add", produces="application/json", consumes="application/json") + public ResponseEntity addTache(@RequestBody Evenement event){ + Evenement resultEvent = null; + try { + resultEvent = evenementRepo.saveAndFlush(event); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.CREATED).body(resultEvent); + } + + //Mise a jour d'un evenement par son ID + @PutMapping("/update/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT')") + public ResponseEntity updateEvenement(@RequestBody Evenement event, @PathVariable Integer id) throws Exception { + Evenement resultEvenement = null; + try { + resultEvenement = evenementRepo.save(event); + + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.OK).body(resultEvenement); + } + + //Efface un evenement par son ID + @DeleteMapping(value = "/delete/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT')") + public ResponseEntity deleteEvenement(@PathVariable int id){ + try { + evenementRepo.delete(evenementRepo.getById(id)); + return ResponseEntity.status(HttpStatus.OK).body("Evenement effacé !"); + + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Evenement introuvable !"); + } + } } diff --git a/src/main/java/fr/organizee/model/Evenement.java b/src/main/java/fr/organizee/model/Evenement.java index 936cdaa..f2f83fd 100644 --- a/src/main/java/fr/organizee/model/Evenement.java +++ b/src/main/java/fr/organizee/model/Evenement.java @@ -11,10 +11,10 @@ public class Evenement { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; - private LocalDateTime eventDebut; - private LocalDateTime eventFin; + private LocalDateTime start; + private LocalDateTime end; private int allDay; - private String libelle; + private String text; @ManyToOne @JoinColumn(name="MEMBRE_ID") @JsonIgnoreProperties("evenement") @@ -27,12 +27,12 @@ public class Evenement { public Evenement() { } - public Evenement(int id, LocalDateTime eventDebut, LocalDateTime eventFin, int allDay, String libelle, Membre membre, Team team) { + public Evenement(int id, LocalDateTime start, LocalDateTime end, int allDay, String text, Membre membre, Team team) { this.id = id; - this.eventDebut = eventDebut; - this.eventFin = eventFin; + this.start = start; + this.end = end; this.allDay = allDay; - this.libelle = libelle; + this.text = text; this.membre = membre; this.team = team; } @@ -45,20 +45,20 @@ public class Evenement { this.id = id; } - public LocalDateTime getEventDebut() { - return eventDebut; + public LocalDateTime getStart() { + return start; } - public void setEventDebut(LocalDateTime eventDebut) { - this.eventDebut = eventDebut; + public void setStart(LocalDateTime start) { + this.start = start; } - public LocalDateTime getEventFin() { - return eventFin; + public LocalDateTime getEnd() { + return end; } - public void setEventFin(LocalDateTime eventFin) { - this.eventFin = eventFin; + public void setEnd(LocalDateTime end) { + this.end = end; } public int getAllDay() { @@ -69,12 +69,12 @@ public class Evenement { this.allDay = allDay; } - public String getLibelle() { - return libelle; + public String getText() { + return text; } - public void setLibelle(String libelle) { - this.libelle = libelle; + public void setText(String text) { + this.text = text; } public Membre getMembre() { @@ -97,10 +97,10 @@ public class Evenement { public String toString() { return "Evenement{" + "id=" + id + - ", eventDebut=" + eventDebut + - ", eventFin=" + eventFin + + ", start=" + start + + ", end=" + end + ", allDay=" + allDay + - ", libelle='" + libelle + '\'' + + ", text='" + text + '\'' + ", membre=" + membre + ", team=" + team + '}'; diff --git a/src/main/java/fr/organizee/repository/EvenementRepository.java b/src/main/java/fr/organizee/repository/EvenementRepository.java index 51164c5..e8663ee 100644 --- a/src/main/java/fr/organizee/repository/EvenementRepository.java +++ b/src/main/java/fr/organizee/repository/EvenementRepository.java @@ -2,8 +2,15 @@ package fr.organizee.repository; import fr.organizee.model.Evenement; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; + + @Repository public interface EvenementRepository extends JpaRepository { + @Query(value = "select * from evenement where team_id = :team_id", nativeQuery = true) + List FindEvenementsByTeam(@Param("team_id") int team_id); } diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 0af0130..4bc52c5 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -37,5 +37,10 @@ INSERT INTO `tache` (`id`, `etat`, `texte`, `todolist_id`) VALUES (4, 0, 'Acheter un sapin', 3), (5, 0, 'Trouver un repas', 3); -INSERT INTO `evenement` (`id`, `all_day`, `event_debut`, `event_fin`, `libelle`, `membre_id`, `team_id`) VALUES - (1, 0, '2022-01-13 09:00:33', '2022-01-13 13:04:38', 'Simplon', 1, 1); \ No newline at end of file +INSERT INTO `evenement` (`id`, `all_day`, `start`, `end`, `text`, `membre_id`, `team_id`) VALUES + (1, 0, '2022-02-04 09:00:00', '2022-02-04 13:00:00', 'Simplon', 1, 1), + (2, 0, '2022-02-03 12:00:00', '2022-02-03 13:00:00', 'Footing', 2, 1); + +INSERT INTO `menu` (`id`, `date_menu`, `libelle`, `validation_proposition`, `team_id`) VALUES + (1, '2022-01-13', 'Lasagnes', 1, 1), + (2, '2022-01-03', 'Kebab', 1, 1); \ No newline at end of file From e5bd6709981c3f707baf4c1a9f7e785ff7cb7ce0 Mon Sep 17 00:00:00 2001 From: Hedi Date: Sun, 6 Feb 2022 22:50:59 +0100 Subject: [PATCH 20/40] jwt : ajout du userId et du teamId dans le token --- src/main/java/fr/organizee/security/JwtTokenProvider.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/fr/organizee/security/JwtTokenProvider.java b/src/main/java/fr/organizee/security/JwtTokenProvider.java index 9ec508d..502f9a7 100644 --- a/src/main/java/fr/organizee/security/JwtTokenProvider.java +++ b/src/main/java/fr/organizee/security/JwtTokenProvider.java @@ -27,6 +27,8 @@ import io.jsonwebtoken.JwtException; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; +import fr.organizee.repository.MembreRepository; + /** * JWT : classe utilitaire chargée de fournir le Jeton (Token) et les vérifications */ @@ -44,6 +46,8 @@ public class JwtTokenProvider { @Autowired private UserDetailsService userDetailsService; + @Autowired + private MembreRepository membreRepo; /** * Cette méthode d'initialisation s'exécute avant le constructeur * Elle encode notre code secret en base64 pour la transmission dans le header @@ -104,6 +108,10 @@ public class JwtTokenProvider { public String createToken(String email, List roles){ Claims claims = Jwts.claims().setSubject(email); + claims.put("userId", membreRepo.findByEmail(email).get().getId()); + if(membreRepo.findByEmail(email).get().getTeam() != null){ + claims.put("teamId", membreRepo.findByEmail(email).get().getTeam().getId()); + } claims.put("auth", roles.stream().map(s -> new SimpleGrantedAuthority(s.getAuthority())).filter(Objects::nonNull).collect(Collectors.toList())); System.out.println("claims = "+claims); From 8a96240fd691befe8beea99d2ec4c3256b952252 Mon Sep 17 00:00:00 2001 From: AlineRinquin <90188226+AlineRinquin@users.noreply.github.com> Date: Sun, 13 Feb 2022 14:39:49 +0100 Subject: [PATCH 21/40] =?UTF-8?q?ALINE:controller=20contact=20blocage=20pr?= =?UTF-8?q?=C3=A9authorize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/organizee/controller/ContactController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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)); From 31ec70f02e5f46174536ed4797f10e78061587be Mon Sep 17 00:00:00 2001 From: HarmandI Date: Tue, 15 Feb 2022 15:39:35 +0100 Subject: [PATCH 22/40] addTache --- .../java/fr/organizee/controller/TacheController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 681d760..82ce274 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -1,6 +1,7 @@ package fr.organizee.controller; import fr.organizee.model.Tache; +import fr.organizee.model.TodoList; import fr.organizee.repository.TacheRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -61,10 +62,13 @@ public class TacheController { } // Ajoute une tache - @PostMapping(value="/add", produces="application/json", consumes="application/json") - public ResponseEntity addTache(@RequestBody Tache tache){ + @PostMapping(value="/add/{idTodoList}", produces="application/json", consumes="application/json") + public ResponseEntity addTache(@RequestBody Tache tache,@PathVariable Integer idTodoList){ Tache resultTache = null; try { + TodoList todolist=new TodoList(); + todolist.setId(idTodoList); + tache.setTodolist(todolist); resultTache = tacheRepo.saveAndFlush(tache); } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); From 54bf69a436d93b28c1d014c108a8d597022fbada Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Thu, 17 Feb 2022 10:40:56 +0100 Subject: [PATCH 23/40] modification des contact ajout couleur --- .idea/misc.xml | 3 +++ src/main/java/fr/organizee/model/Contact.java | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 06e8b35..2289c27 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,4 +11,7 @@ + + \ No newline at end of file diff --git a/src/main/java/fr/organizee/model/Contact.java b/src/main/java/fr/organizee/model/Contact.java index 826b2db..25b2d2d 100644 --- a/src/main/java/fr/organizee/model/Contact.java +++ b/src/main/java/fr/organizee/model/Contact.java @@ -11,6 +11,7 @@ public class Contact { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + private String couleur; private String nom; private String prenom; private String telephone; @@ -18,14 +19,15 @@ public class Contact { private String adresse; private LocalDate dateNaissance; @ManyToOne - @JoinColumn(name="TEAM_ID") - @JsonIgnoreProperties({"contact","membre"}) + @JoinColumn(name = "TEAM_ID") + @JsonIgnoreProperties({"contact", "membre"}) private Team team; public Contact() { } - public Contact(String nom, String prenom, String telephone, String email, String adresse, LocalDate dateNaissance, Team team) { + public Contact(String couleur, String nom, String prenom, String telephone, String email, String adresse, LocalDate dateNaissance, Team team) { + this.couleur = couleur; this.nom = nom; this.prenom = prenom; this.telephone = telephone; @@ -43,6 +45,14 @@ public class Contact { this.id = id; } + public String getCouleur() { + return couleur; + } + + public void setCouleur(String couleur) { + this.couleur = couleur; + } + public String getNom() { return nom; } @@ -94,6 +104,7 @@ public class Contact { public Team getTeam() { return team; } + public void setTeam(Team team) { this.team = team; } @@ -102,6 +113,7 @@ public class Contact { public String toString() { return "Contact{" + "id=" + id + + ", couleur='" + couleur + '\'' + ", nom='" + nom + '\'' + ", prenom='" + prenom + '\'' + ", telephone='" + telephone + '\'' + From eb7b7777ec8b3a755b31784f947825923a4f8589 Mon Sep 17 00:00:00 2001 From: HarmandI Date: Thu, 17 Feb 2022 11:38:46 +0100 Subject: [PATCH 24/40] update tache --- src/main/java/fr/organizee/controller/TacheController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 82ce274..58e5ccc 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -77,11 +77,14 @@ public class TacheController { return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); } - //Met a jour les informations d'une date avec son ID + //Met a jour les informations d'une tache avec son ID @PutMapping("/update/{id}") public ResponseEntity updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { Tache resultTache = null; try { + TodoList todolist=new TodoList(); + todolist.setId(tacheRepo.findById(tache.getId()).get().getTodolist().getId()); + tache.setTodolist(todolist); resultTache = tacheRepo.save(tache); } catch (Exception e) { From 9c72f95494b2d845fc6f0d5076a9ce9941e4d1b9 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Thu, 17 Feb 2022 11:42:52 +0100 Subject: [PATCH 25/40] addMenu --- .../organizee/controller/MenuController.java | 8 ++++++-- src/main/java/fr/organizee/model/Menu.java | 19 +++++++++---------- .../organizee/repository/MenuRepository.java | 1 + 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java index b7db085..0ea98e3 100644 --- a/src/main/java/fr/organizee/controller/MenuController.java +++ b/src/main/java/fr/organizee/controller/MenuController.java @@ -1,6 +1,7 @@ package fr.organizee.controller; import fr.organizee.model.Menu; +import fr.organizee.model.Team; import fr.organizee.repository.MenuRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -49,11 +50,14 @@ public class MenuController { } //Ajoute un nouveau menu - @PostMapping(value="/add") + @PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") - public ResponseEntity addMenu(@RequestBody Menu menu){ + public ResponseEntity addMenu(@RequestBody Menu menu, @PathVariable Integer team_id){ Menu resultMenu = null; try { + Team team=new Team(); + team.setId(team_id); + menu.setTeam(team); resultMenu = menuRepository.saveAndFlush(menu); } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index dcc5cb0..22a1ab1 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -12,7 +12,7 @@ public class Menu { private int id; private String libelle; private LocalDate dateMenu; - private int validationProposition; + // private int validationProposition; @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties({"menu","membre"}) @@ -21,10 +21,10 @@ public class Menu { public Menu() { } - public Menu(String libelle, LocalDate dateMenu, int validationProposition, Team team) { + public Menu(String libelle, LocalDate dateMenu, Team team) { this.libelle = libelle; this.dateMenu = dateMenu; - this.validationProposition=validationProposition; + //this.validationProposition=validationProposition; this.team = team; } @@ -52,13 +52,13 @@ public class Menu { this.dateMenu = dateMenu; } - public int getValidationProposition() { - return validationProposition; - } + // public int getValidationProposition() { + // return validationProposition; + //} - public void setValidationProposition(int validationProposition) { - this.validationProposition = validationProposition; - } + //public void setValidationProposition(int validationProposition) { + // this.validationProposition = validationProposition; + // } public Team getTeam() { return team; @@ -74,7 +74,6 @@ public class Menu { "id=" + id + ", libelle='" + libelle + '\'' + ", dateMenu=" + dateMenu + - ", validationProposition=" + validationProposition + ", team=" + team + '}'; } diff --git a/src/main/java/fr/organizee/repository/MenuRepository.java b/src/main/java/fr/organizee/repository/MenuRepository.java index 1f22d7d..7c5d0cb 100644 --- a/src/main/java/fr/organizee/repository/MenuRepository.java +++ b/src/main/java/fr/organizee/repository/MenuRepository.java @@ -14,4 +14,5 @@ public interface MenuRepository extends JpaRepository { @Query(value = "select * from menu where team_id = :team_id", nativeQuery = true) List FindMenusByTeam(@Param("team_id") int team_id); + } From 34722797eea8cb3de5cdcf4c531302f9fdbc171a Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Thu, 17 Feb 2022 14:40:45 +0100 Subject: [PATCH 26/40] re push pull du projet avec les modfs --- .../fr/organizee/{ => dto}/controller/ContactController.java | 2 +- .../fr/organizee/{ => dto}/controller/EvenementController.java | 2 +- .../java/fr/organizee/{ => dto}/controller/MailController.java | 2 +- .../fr/organizee/{ => dto}/controller/MembreController.java | 2 +- .../java/fr/organizee/{ => dto}/controller/MenuController.java | 2 +- .../java/fr/organizee/{ => dto}/controller/TacheController.java | 2 +- .../java/fr/organizee/{ => dto}/controller/TeamController.java | 2 +- .../fr/organizee/{ => dto}/controller/TodoListController.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/fr/organizee/{ => dto}/controller/ContactController.java (98%) rename src/main/java/fr/organizee/{ => dto}/controller/EvenementController.java (98%) rename src/main/java/fr/organizee/{ => dto}/controller/MailController.java (97%) rename src/main/java/fr/organizee/{ => dto}/controller/MembreController.java (99%) rename src/main/java/fr/organizee/{ => dto}/controller/MenuController.java (98%) rename src/main/java/fr/organizee/{ => dto}/controller/TacheController.java (99%) rename src/main/java/fr/organizee/{ => dto}/controller/TeamController.java (98%) rename src/main/java/fr/organizee/{ => dto}/controller/TodoListController.java (98%) diff --git a/src/main/java/fr/organizee/controller/ContactController.java b/src/main/java/fr/organizee/dto/controller/ContactController.java similarity index 98% rename from src/main/java/fr/organizee/controller/ContactController.java rename to src/main/java/fr/organizee/dto/controller/ContactController.java index e93e926..e9eeacc 100644 --- a/src/main/java/fr/organizee/controller/ContactController.java +++ b/src/main/java/fr/organizee/dto/controller/ContactController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/EvenementController.java similarity index 98% rename from src/main/java/fr/organizee/controller/EvenementController.java rename to src/main/java/fr/organizee/dto/controller/EvenementController.java index f6a32a8..c1a3582 100644 --- a/src/main/java/fr/organizee/controller/EvenementController.java +++ b/src/main/java/fr/organizee/dto/controller/EvenementController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/MailController.java similarity index 97% rename from src/main/java/fr/organizee/controller/MailController.java rename to src/main/java/fr/organizee/dto/controller/MailController.java index 3543668..e89b43f 100644 --- a/src/main/java/fr/organizee/controller/MailController.java +++ b/src/main/java/fr/organizee/dto/controller/MailController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/MembreController.java similarity index 99% rename from src/main/java/fr/organizee/controller/MembreController.java rename to src/main/java/fr/organizee/dto/controller/MembreController.java index 93df3d8..5db618c 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/dto/controller/MembreController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/MenuController.java similarity index 98% rename from src/main/java/fr/organizee/controller/MenuController.java rename to src/main/java/fr/organizee/dto/controller/MenuController.java index 0ea98e3..c0b5c3b 100644 --- a/src/main/java/fr/organizee/controller/MenuController.java +++ b/src/main/java/fr/organizee/dto/controller/MenuController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/TacheController.java similarity index 99% rename from src/main/java/fr/organizee/controller/TacheController.java rename to src/main/java/fr/organizee/dto/controller/TacheController.java index 58e5ccc..224dd14 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/dto/controller/TacheController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/TeamController.java similarity index 98% rename from src/main/java/fr/organizee/controller/TeamController.java rename to src/main/java/fr/organizee/dto/controller/TeamController.java index 1d96ae5..67f7907 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/dto/controller/TeamController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.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/dto/controller/TodoListController.java similarity index 98% rename from src/main/java/fr/organizee/controller/TodoListController.java rename to src/main/java/fr/organizee/dto/controller/TodoListController.java index 747eff9..f166cf3 100644 --- a/src/main/java/fr/organizee/controller/TodoListController.java +++ b/src/main/java/fr/organizee/dto/controller/TodoListController.java @@ -1,4 +1,4 @@ -package fr.organizee.controller; +package fr.organizee.dto.controller; import fr.organizee.model.TodoList; import fr.organizee.repository.TodoListRepository; From b9d3288a283f1efc8119bc3223a7c5a89e2ed3bd Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Fri, 18 Feb 2022 12:01:55 +0100 Subject: [PATCH 27/40] commit to merge --- src/main/java/fr/organizee/controller/MembreController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b87499ba73949e532262eee11b08e486e17b1f83 Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Fri, 18 Feb 2022 17:16:53 +0100 Subject: [PATCH 28/40] 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 29/40] 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 c189362601565d682ffb6a06d106ebb1d1761b98 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Fri, 18 Feb 2022 17:21:07 +0100 Subject: [PATCH 30/40] Membre --- .../controller/ContactController.java | 2 +- .../controller/EvenementController.java | 2 +- .../{dto => }/controller/MailController.java | 2 +- .../controller/MembreController.java | 235 ++++++++++-------- .../{dto => }/controller/MenuController.java | 2 +- .../{dto => }/controller/TacheController.java | 2 +- .../{dto => }/controller/TeamController.java | 2 +- .../controller/TodoListController.java | 2 +- .../exception/MembreNotFoundAdvice.java | 13 + .../exception/MembreNotFoundException.java | 7 + 10 files changed, 155 insertions(+), 114 deletions(-) rename src/main/java/fr/organizee/{dto => }/controller/ContactController.java (98%) rename src/main/java/fr/organizee/{dto => }/controller/EvenementController.java (98%) rename src/main/java/fr/organizee/{dto => }/controller/MailController.java (97%) rename src/main/java/fr/organizee/{dto => }/controller/MembreController.java (59%) rename src/main/java/fr/organizee/{dto => }/controller/MenuController.java (98%) rename src/main/java/fr/organizee/{dto => }/controller/TacheController.java (99%) rename src/main/java/fr/organizee/{dto => }/controller/TeamController.java (98%) rename src/main/java/fr/organizee/{dto => }/controller/TodoListController.java (98%) create mode 100644 src/main/java/fr/organizee/exception/MembreNotFoundAdvice.java create mode 100644 src/main/java/fr/organizee/exception/MembreNotFoundException.java diff --git a/src/main/java/fr/organizee/dto/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java similarity index 98% rename from src/main/java/fr/organizee/dto/controller/ContactController.java rename to src/main/java/fr/organizee/controller/ContactController.java index e9eeacc..e93e926 100644 --- a/src/main/java/fr/organizee/dto/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/dto/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java similarity index 98% rename from src/main/java/fr/organizee/dto/controller/EvenementController.java rename to src/main/java/fr/organizee/controller/EvenementController.java index c1a3582..f6a32a8 100644 --- a/src/main/java/fr/organizee/dto/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/dto/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java similarity index 97% rename from src/main/java/fr/organizee/dto/controller/MailController.java rename to src/main/java/fr/organizee/controller/MailController.java index e89b43f..3543668 100644 --- a/src/main/java/fr/organizee/dto/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/dto/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java similarity index 59% rename from src/main/java/fr/organizee/dto/controller/MembreController.java rename to src/main/java/fr/organizee/controller/MembreController.java index 0bfa9f5..a9d0fe8 100644 --- a/src/main/java/fr/organizee/dto/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -1,9 +1,10 @@ -package fr.organizee.dto.controller; +package fr.organizee.controller; import fr.organizee.dto.JsonWebToken; import fr.organizee.dto.MembreDto; import fr.organizee.exception.ExistingUsernameException; import fr.organizee.exception.InvalidCredentialsException; +import fr.organizee.exception.MembreNotFoundException; import fr.organizee.model.Membre; import fr.organizee.repository.MembreRepository; import fr.organizee.service.MembreService; @@ -19,21 +20,21 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -/* toto */ + @RestController @CrossOrigin("*") -@RequestMapping("/membres") +@RequestMapping(value="/membres") public class MembreController { @Autowired private MembreRepository membreRepo; - @Autowired private MembreService membreService; - @Autowired private BCryptPasswordEncoder passwordEncoder; + public MembreController() {} + @ResponseBody public String home() { @@ -43,27 +44,140 @@ public class MembreController { return sb.toString(); } - // Récupère tout les membres de la base + /** + * Rechercher tous les membres + * @return + * http://localhost:8088/membres/all + */ @GetMapping(value = "/all") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") - public ResponseEntity getAll(){ - List liste = null; + public ResponseEntity getAllMembres(){ + List listeMembres; try { - liste = membreRepo.findAll(); + listeMembres = membreRepo.findAll(); } catch (Exception e) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + MembreNotFoundException commandeNotFoundException = new MembreNotFoundException(); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(commandeNotFoundException.getMessage()); } - return ResponseEntity.status(HttpStatus.OK).body(liste); + return ResponseEntity.status(HttpStatus.OK).body(listeMembres); } - @GetMapping("/admin/all") + /** + * Rechercher tous les membres admin + * @return + * http://localhost:8088/membres/admin/all + */ + + @GetMapping(value="/admin/all") @PreAuthorize("hasRole('ROLE_PARENT')") public List getAllAdminUsers() { - return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList()); - + return membreService.findAllUsers().stream().map(appUser -> + new MembreDto(appUser.getEmail(), + appUser.getRoleList())).collect(Collectors.toList()); } + + /** + * Rechercher un membre par son Id + * @return + * http://localhost:8088/membres/1 + */ + + @GetMapping(value="/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + public ResponseEntity getMembreById(@PathVariable int id) { + Optional membre; + try { + membre = membreRepo.findById(id); + if (membre.isPresent()) { + return ResponseEntity.status(HttpStatus.OK).body(membre); + } else { + MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); + } + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); + } + } + + /** + * Ajouter un membre et inscription + * @return + * http://localhost:8088/membres/sign-up + */ + + @PostMapping(value="/sign-up") + public ResponseEntity signUp(@RequestBody Membre membre) { + try { + return ResponseEntity.ok(new JsonWebToken(membreService.signup(membre))); + } catch (ExistingUsernameException ex) { + return ResponseEntity.badRequest().build(); + } + } + + /** + * Modifier une commande par son Id + * @return + * http://localhost:8088/membres/update/1 + * + */ + @PutMapping("/update/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT')") + public ResponseEntity updateMembre(@RequestBody Membre membre, @PathVariable int id){ + Optional membreUpdate; + try { + membreUpdate = membreRepo.findById(id); + // membre trouvé + if(membreUpdate.isPresent()){ + membre.setId(membreUpdate.get().getId()); + membreRepo.save(membre); + } + //membre inconnu + else{ + MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); + } + //gestion de l'erreur + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); + } + // retour membre + return ResponseEntity.status(HttpStatus.OK).body(membre); + } + + /** + * Supprimer un membre par son Id + * @return + * http://localhost:8088/membres/delete/1 + */ + @DeleteMapping(value = "/delete/{id}") + //@PreAuthorize("hasRole('ROLE_PARENT')") + public ResponseEntity deleteMembre(@PathVariable int id){ + try { + membreRepo.getById(id); + membreRepo.deleteById(id); + return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !"); + } catch (Exception e) { + MembreNotFoundException membreNotFoundException = new membreNotFoundException(id); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); + } + } + + + /**************************** Login / Se connceter ****************************/ + @PostMapping("/sign-in") + public ResponseEntity signIn(@RequestBody Membre membre) { + try { + return ResponseEntity.ok(new JsonWebToken(membreService.signin(membre.getEmail(), membre.getPassword()))); + } catch (InvalidCredentialsException ex) { + return ResponseEntity.badRequest().build(); + } + } + + /********************* Gestion Mot de Passe ************************************/ + + //cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas @GetMapping("/forgot-password") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") @@ -104,98 +218,5 @@ public class MembreController { } - //Récupérer les informations d'un membre par son ID - @GetMapping(value = "/{id}") - //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") - public ResponseEntity findById(@PathVariable int id){ - Optional membre = null; - try - { - membre = membreRepo.findById(id); - } catch (Exception e) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); - } - return ResponseEntity.status(HttpStatus.OK).body(membre); - } - - //Efface un membre par son ID - @DeleteMapping(value = "/delete/{id}") - //@PreAuthorize("hasRole('ROLE_PARENT')") - public ResponseEntity deleteMembre(@PathVariable int id){ - try { - membreRepo.delete(membreRepo.getById(id)); - //membreRepo.deleteById(id); - return ResponseEntity.status(HttpStatus.OK).body("Membre effacé !"); - - } catch (EntityNotFoundException e) { - - return ResponseEntity.status(HttpStatus.OK).body("Membre introuvable !"); - } - } - - //Ajouter un membre et inscription - @PostMapping("/sign-up") - public ResponseEntity signUp(@RequestBody Membre membre) { - try { - return ResponseEntity.ok(new JsonWebToken(membreService.signup(membre))); - } catch (ExistingUsernameException ex) { - return ResponseEntity.badRequest().build(); - } - } - - //Login - @PostMapping("/sign-in") - public ResponseEntity signIn(@RequestBody Membre membre) { - try { - return ResponseEntity.ok(new JsonWebToken(membreService.signin(membre.getEmail(), membre.getPassword()))); - } catch (InvalidCredentialsException ex) { - return ResponseEntity.badRequest().build(); - } - } - - //Met a jour les informations d'un membre par son ID - @PutMapping("/update/{id}") - //@PreAuthorize("hasRole('ROLE_PARENT')") - public ResponseEntity updateMembre(@RequestBody Membre membre, @PathVariable Integer id) throws Exception { - Membre resultMembre = null; - try { - resultMembre = membreRepo.save(membre); - - } catch (Exception e) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); - } - - 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); -// } } diff --git a/src/main/java/fr/organizee/dto/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java similarity index 98% rename from src/main/java/fr/organizee/dto/controller/MenuController.java rename to src/main/java/fr/organizee/controller/MenuController.java index c0b5c3b..0ea98e3 100644 --- a/src/main/java/fr/organizee/dto/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/dto/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java similarity index 99% rename from src/main/java/fr/organizee/dto/controller/TacheController.java rename to src/main/java/fr/organizee/controller/TacheController.java index 224dd14..58e5ccc 100644 --- a/src/main/java/fr/organizee/dto/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/dto/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java similarity index 98% rename from src/main/java/fr/organizee/dto/controller/TeamController.java rename to src/main/java/fr/organizee/controller/TeamController.java index b791776..9ec47d3 100644 --- a/src/main/java/fr/organizee/dto/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/dto/controller/TodoListController.java b/src/main/java/fr/organizee/controller/TodoListController.java similarity index 98% rename from src/main/java/fr/organizee/dto/controller/TodoListController.java rename to src/main/java/fr/organizee/controller/TodoListController.java index f166cf3..747eff9 100644 --- a/src/main/java/fr/organizee/dto/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; diff --git a/src/main/java/fr/organizee/exception/MembreNotFoundAdvice.java b/src/main/java/fr/organizee/exception/MembreNotFoundAdvice.java new file mode 100644 index 0000000..f50edba --- /dev/null +++ b/src/main/java/fr/organizee/exception/MembreNotFoundAdvice.java @@ -0,0 +1,13 @@ +package fr.organizee.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +public class MembreNotFoundAdvice { + @ResponseBody + @ExceptionHandler(MembreNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + String membreNotFoundHandler(MembreNotFoundException ex){return ex.getMessage();} +} diff --git a/src/main/java/fr/organizee/exception/MembreNotFoundException.java b/src/main/java/fr/organizee/exception/MembreNotFoundException.java new file mode 100644 index 0000000..fda48c0 --- /dev/null +++ b/src/main/java/fr/organizee/exception/MembreNotFoundException.java @@ -0,0 +1,7 @@ +package fr.organizee.exception; + + +public class MembreNotFoundException extends RuntimeException{ + public MembreNotFoundException(int id){ super("Membre" + id + " introuvable");} + public MembreNotFoundException(){ super("Membres introuvables");} +} From 287deb99e508e16ce542c79990b5b95909e831be Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Fri, 18 Feb 2022 17:51:34 +0100 Subject: [PATCH 31/40] 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 32/40] 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; From 87bbec1ba18c0e2e1d9728c5c5aba18adb5ab9b7 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Thu, 24 Feb 2022 12:14:50 +0100 Subject: [PATCH 33/40] changement back sur le menu --- .../controller/MembreController.java | 2 +- src/main/java/fr/organizee/model/Menu.java | 44 ++++++++----------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 6c088c4..4164834 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -160,7 +160,7 @@ public class MembreController { membreRepo.deleteById(id); return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !"); } catch (Exception e) { - MembreNotFoundException membreNotFoundException = new membreNotFoundException(id); + MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); } } diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index 458e80c..4be974c 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -10,10 +10,9 @@ public class Menu { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; - private String libelle; private LocalDate dateMenu; - private String repas; - // private int validationProposition; + private String repasMidi; + private String repasSoir; @ManyToOne @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties({"menu","membre"}) @@ -22,10 +21,10 @@ public class Menu { public Menu() { } - public Menu(String libelle, LocalDate dateMenu,String repas, Team team) { - this.libelle = libelle; + public Menu(LocalDate dateMenu,String repasMidi, String repasSoir, Team team) { this.dateMenu = dateMenu; - this.repas= repas; + this.repasMidi= repasMidi; + this.repasSoir= repasSoir; this.team = team; } @@ -37,14 +36,6 @@ public class Menu { this.id = id; } - public String getLibelle() { - return libelle; - } - - public void setLibelle(String libelle) { - this.libelle = libelle; - } - public LocalDate getDateMenu() { return dateMenu; } @@ -53,21 +44,21 @@ public class Menu { this.dateMenu = dateMenu; } - public String getRepas() { - return repas; + public String getRepasMidi() { + return repasMidi; } - public void setRepas(String repas) { - this.repas = repas; + public void setRepasMidi(String repasMidi) { + this.repasMidi = repasMidi; } - // public int getValidationProposition() { - // return validationProposition; - //} + public String getRepasSoir() { + return repasSoir; + } - //public void setValidationProposition(int validationProposition) { - // this.validationProposition = validationProposition; - // } + public void setRepasSoir(String repasSoir) { + this.repasSoir = repasSoir; + } public Team getTeam() { return team; @@ -77,14 +68,15 @@ public class Menu { this.team = team; } + @Override public String toString() { return "Menu{" + "id=" + id + - ", libelle='" + libelle + '\'' + ", dateMenu=" + dateMenu + + ", repasMidi='" + repasMidi + '\'' + + ", repasSoir='" + repasSoir + '\'' + ", team=" + team + - ", repas=" + repas + '}'; } } From 45cecb0079a6c73a06e799efd15a45c4f4d7573f Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Thu, 24 Feb 2022 13:35:05 +0100 Subject: [PATCH 34/40] mise a jour fichier sana --- src/main/java/fr/organizee/controller/MembreController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 6c088c4..4164834 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -160,7 +160,7 @@ public class MembreController { membreRepo.deleteById(id); return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !"); } catch (Exception e) { - MembreNotFoundException membreNotFoundException = new membreNotFoundException(id); + MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); } } From 03c8a9dfc3588297c3419dc3e7beac75ae2dbd4a Mon Sep 17 00:00:00 2001 From: AlineRinquin Date: Thu, 24 Feb 2022 14:59:51 +0100 Subject: [PATCH 35/40] data sql menu ajour --- src/main/resources/data.sql | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 4bc52c5..148a508 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -41,6 +41,12 @@ INSERT INTO `evenement` (`id`, `all_day`, `start`, `end`, `text`, `membre_id`, ` (1, 0, '2022-02-04 09:00:00', '2022-02-04 13:00:00', 'Simplon', 1, 1), (2, 0, '2022-02-03 12:00:00', '2022-02-03 13:00:00', 'Footing', 2, 1); -INSERT INTO `menu` (`id`, `date_menu`, `libelle`, `validation_proposition`, `team_id`) VALUES - (1, '2022-01-13', 'Lasagnes', 1, 1), - (2, '2022-01-03', 'Kebab', 1, 1); \ No newline at end of file + +INSERT INTO menu (id, date_menu, repas_midi, team_id, repas_soir) VALUES +(1, '2022-02-21', 'canard à l orange', 4, 'pâtes au beurre'), +(4, '2022-02-22', 'lasagnes', 4, 'riz sauté'), +(11, '2022-02-23', 'roti de dinde orloff', 4, 'choucroute'), +(13, '2022-02-24', 'hachis parmentier', 4, 'salade composée'), +(15, '2022-02-25', 'legumes', 4, 'croque monsieurs'), +(17, '2022-02-26', 'sauté de veau', 4, 'soupe et jambon'), +(21, '2022-02-27', 'lasagnes', 4, 'pizza'); \ No newline at end of file From e7d0757d4907809e69215ca0230b637cb4a1942a Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Thu, 24 Feb 2022 15:01:56 +0100 Subject: [PATCH 36/40] commit to merge --- src/main/java/fr/organizee/controller/MembreController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 6c088c4..c779742 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -41,7 +41,7 @@ public class MembreController { { StringBuilder sb = new StringBuilder(); sb.append("

Affichages des membres

"); - sb.append("
  • Liste des membres
  • "); + sb.append("
    • Liste des membres
    • "); return sb.toString(); } @@ -160,7 +160,7 @@ public class MembreController { membreRepo.deleteById(id); return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !"); } catch (Exception e) { - MembreNotFoundException membreNotFoundException = new membreNotFoundException(id); + MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); } } From 695d3c10785a91adb2985b2b930dcce57fb617a5 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Fri, 25 Feb 2022 09:54:59 +0100 Subject: [PATCH 37/40] ajout post add membre en plus de signup et modifs repo et service --- .../controller/MembreController.java | 43 ++++++++++++++++++- .../repository/MembreRepository.java | 5 +++ .../organizee/service/MembreServiceImpl.java | 4 +- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index c779742..e611f83 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -6,6 +6,8 @@ import fr.organizee.exception.ExistingUsernameException; import fr.organizee.exception.InvalidCredentialsException; import fr.organizee.exception.MembreNotFoundException; import fr.organizee.model.Membre; +import fr.organizee.model.Menu; +import fr.organizee.model.Team; import fr.organizee.repository.MembreRepository; import fr.organizee.service.MembreService; import org.springframework.beans.factory.annotation.Autowired; @@ -103,7 +105,24 @@ public class MembreController { } /** - * Ajouter un membre et inscription + * Rechercher un membre par l'Id de sa team + * @return + * http://localhost:8088/membres/1 + */ + @GetMapping(value = "team/{team_id}") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + public ResponseEntity findByTeamId(@PathVariable int team_id) { + List membres = null; + try { + membres = membreRepo.FindMembresByTeam(team_id); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + return ResponseEntity.status(HttpStatus.OK).body(membres); + } + + /** + * Inscription * @return * http://localhost:8088/membres/sign-up */ @@ -117,6 +136,28 @@ public class MembreController { } } + /** + * Ajout d'un membre + * @return + * http://localhost:8088/membres/add + */ + @PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + public ResponseEntity addMembre(@RequestBody Membre membre, @PathVariable Integer team_id){ + Membre resultMembre = null; + try{ + Team team = new Team(); + team.setId(team_id); + membre.setTeam(team); + //resultMembre = membreRepo.saveAndFlush(membre); + return ResponseEntity.ok(new JsonWebToken(membreService.signup(membre))); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + //return ResponseEntity.status(HttpStatus.CREATED).body(resultMembre); + } + /** * Modifier une commande par son Id * @return diff --git a/src/main/java/fr/organizee/repository/MembreRepository.java b/src/main/java/fr/organizee/repository/MembreRepository.java index 137f203..5a6cf22 100644 --- a/src/main/java/fr/organizee/repository/MembreRepository.java +++ b/src/main/java/fr/organizee/repository/MembreRepository.java @@ -2,6 +2,7 @@ package fr.organizee.repository; import fr.organizee.model.Contact; import fr.organizee.model.Membre; +import fr.organizee.model.Menu; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -12,6 +13,10 @@ import java.util.Optional; @Repository public interface MembreRepository extends JpaRepository { + + @Query(value = "select * from membre where team_id = :team_id", nativeQuery = true) + List FindMembresByTeam(@Param("team_id") int team_id); + Membre findByNom(String nom); Optional findByEmail(String email); diff --git a/src/main/java/fr/organizee/service/MembreServiceImpl.java b/src/main/java/fr/organizee/service/MembreServiceImpl.java index 2197bbc..e04c48e 100644 --- a/src/main/java/fr/organizee/service/MembreServiceImpl.java +++ b/src/main/java/fr/organizee/service/MembreServiceImpl.java @@ -48,7 +48,9 @@ public class MembreServiceImpl implements MembreService { @Override public String signup(Membre membre) throws ExistingUsernameException { if (!membreRepository.existsByEmail(membre.getEmail())) { - Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getCouleur(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); + Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getCouleur(), + membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), + passwordEncoder.encode(membre.getPassword()), membre.getRoleList()); membreRepository.save(membreToSave); return jwtTokenProvider.createToken(membre.getEmail(), membre.getRoleList()); } else { From c6e0aa036a232d17e5d121e35810d5cd2f8c627d Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Fri, 25 Feb 2022 18:53:57 +0100 Subject: [PATCH 38/40] ajout crossOrgins sur mail --- src/main/java/fr/organizee/controller/MailController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java index 3543668..5df737e 100644 --- a/src/main/java/fr/organizee/controller/MailController.java +++ b/src/main/java/fr/organizee/controller/MailController.java @@ -4,14 +4,12 @@ import fr.organizee.model.Mail; import fr.organizee.service.SendMailService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.mail.MessagingException; @RestController +@CrossOrigin("*") @RequestMapping("/sendmail") public class MailController { SendMailService service; From d56a795854946de59801bd3004708eb85aec8dab Mon Sep 17 00:00:00 2001 From: Hedi MJID Date: Sat, 26 Feb 2022 19:21:50 +0100 Subject: [PATCH 39/40] refacto forget/reset password --- .../controller/MembreController.java | 35 ++++++++----------- .../repository/MembreRepository.java | 3 ++ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index e611f83..a498165 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*; import javax.persistence.EntityNotFoundException; import java.util.List; import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; @@ -219,14 +220,16 @@ public class MembreController { /********************* Gestion Mot de Passe ************************************/ //cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas - @GetMapping("/forgot-password") + @PostMapping("/forgot-password") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") - public ResponseEntity findUserByEmail(@RequestBody Membre findUserByEmail) { - + public ResponseEntity findUserByEmail(@RequestBody Membre membre) { + Membre resultMembre = null; try { - this.membreService.findUserByEmail(findUserByEmail); - return ResponseEntity.status(HttpStatus.OK).body("Email trouvé !"); - + resultMembre = membreRepo.chercheEmail(membre.getEmail()); + String uuid = UUID.randomUUID().toString(); + resultMembre.setPassword(uuid); + membreRepo.saveAndFlush(resultMembre); + return ResponseEntity.status(HttpStatus.OK).body(uuid); } catch (EntityNotFoundException e) { return ResponseEntity.status(HttpStatus.OK).body("Email introuvable !"); @@ -234,22 +237,14 @@ public class MembreController { } - @PutMapping("/reset-password/{email}") + @PutMapping("/reset-password/{uuid}") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") - public ResponseEntity updatePassword(@RequestBody String password, @PathVariable String email) throws Exception { - Membre resultMembre; + public ResponseEntity updatePassword(@RequestBody Membre membre, @PathVariable String uuid) throws Exception { + Membre resultMembre = null; try { - resultMembre = this.membreService.chercheEmail(email); - - System.out.println(resultMembre); - - resultMembre.setPassword(passwordEncoder.encode(password)); - - System.out.println(password); - - this.membreRepo.save(resultMembre); - System.out.println(resultMembre.getPassword()); - + resultMembre = membreRepo.findByUUID(uuid); + resultMembre.setPassword(passwordEncoder.encode(membre.getPassword())); + membreRepo.saveAndFlush(resultMembre); } catch (Exception e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); } diff --git a/src/main/java/fr/organizee/repository/MembreRepository.java b/src/main/java/fr/organizee/repository/MembreRepository.java index 5a6cf22..cc84635 100644 --- a/src/main/java/fr/organizee/repository/MembreRepository.java +++ b/src/main/java/fr/organizee/repository/MembreRepository.java @@ -21,6 +21,9 @@ public interface MembreRepository extends JpaRepository { Optional findByEmail(String email); + @Query(value = "select * from membre where password = :uuid", nativeQuery = true) + Membre findByUUID(@Param("uuid") String uuid); + @Query(value = "select * from membre where email = :email", nativeQuery = true) Membre chercheEmail(@Param("email") String email); From 4f7834a9a633aaa9ef103ea55b3ff78ac468220b Mon Sep 17 00:00:00 2001 From: HarmandI Date: Sun, 27 Feb 2022 17:27:47 +0100 Subject: [PATCH 40/40] add to do list --- .../controller/MembreController.java | 2 +- .../controller/TodoListController.java | 19 +++++++++++++++++++ .../organizee/repository/TacheRepository.java | 3 ++- .../organizee/service/MembreServiceImpl.java | 3 ++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 6c088c4..4164834 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -160,7 +160,7 @@ public class MembreController { membreRepo.deleteById(id); return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !"); } catch (Exception e) { - MembreNotFoundException membreNotFoundException = new membreNotFoundException(id); + MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage()); } } diff --git a/src/main/java/fr/organizee/controller/TodoListController.java b/src/main/java/fr/organizee/controller/TodoListController.java index 747eff9..8733fdc 100644 --- a/src/main/java/fr/organizee/controller/TodoListController.java +++ b/src/main/java/fr/organizee/controller/TodoListController.java @@ -1,6 +1,7 @@ package fr.organizee.controller; import fr.organizee.model.TodoList; +import fr.organizee.model.Team; import fr.organizee.repository.TodoListRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -19,6 +20,7 @@ public class TodoListController { @Autowired private TodoListRepository todolistRepo; + @GetMapping(value = "/all") public ResponseEntity getAll(){ List liste = null; @@ -32,6 +34,23 @@ public class TodoListController { return ResponseEntity.status(HttpStatus.OK).body(liste); } + //Ajoute une nouvelle ToDoList + @PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json") + //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") + public ResponseEntity addTodolist(@RequestBody TodoList todolist, @PathVariable Integer team_id) { + TodoList resultTodolist = null; + try { + Team team = new Team(); + team.setId(team_id); + todolist.setTeam(team); + resultTodolist = todolistRepo.saveAndFlush(todolist); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.CREATED).body(resultTodolist); + } + @DeleteMapping(value = "/delete/{id}") //@PreAuthorize("hasRole('ROLE_PARENT')") public ResponseEntity deleteTodolist(@PathVariable int id){ diff --git a/src/main/java/fr/organizee/repository/TacheRepository.java b/src/main/java/fr/organizee/repository/TacheRepository.java index a9ac6f9..0c2e1bf 100644 --- a/src/main/java/fr/organizee/repository/TacheRepository.java +++ b/src/main/java/fr/organizee/repository/TacheRepository.java @@ -9,7 +9,8 @@ import org.springframework.stereotype.Repository; import java.util.List; @Repository -public interface TacheRepository extends JpaRepository { +public interface +TacheRepository extends JpaRepository { // N'est plus utilisé normalement @Query(value = "select * from todo_list, tache where todo_list.team_id = :team_id and todo_list.id = tache.todolist_id", nativeQuery = true) diff --git a/src/main/java/fr/organizee/service/MembreServiceImpl.java b/src/main/java/fr/organizee/service/MembreServiceImpl.java index 2197bbc..a8ecc87 100644 --- a/src/main/java/fr/organizee/service/MembreServiceImpl.java +++ b/src/main/java/fr/organizee/service/MembreServiceImpl.java @@ -17,7 +17,8 @@ import fr.organizee.repository.MembreRepository; import fr.organizee.security.JwtTokenProvider; @Service -public class MembreServiceImpl implements MembreService { +public class +MembreServiceImpl implements MembreService { @Autowired private MembreRepository membreRepository; // permet communication avec la BD