From af3700e99ad0d50ef98355b78ae0358b6de8b201 Mon Sep 17 00:00:00 2001 From: Hedi Date: Wed, 22 Dec 2021 10:40:06 +0100 Subject: [PATCH 1/5] Modif class Membre : modification de la jointure Modif Controller Membre : ajout de methode delete et add --- .gitignore | 3 +- .../controller/MembreController.java | 34 +- src/main/java/fr/organizee/model/Membre.java | 14 +- src/main/resources/application.properties | 1 + src/main/resources/data.sql | 299 ++++++++---------- 5 files changed, 180 insertions(+), 171 deletions(-) diff --git a/.gitignore b/.gitignore index 2ea2eec..ee31714 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ build/ ### VS Code ### .vscode/ /.idea/ -/src/main/resources/ +/.idea/ +/.mvn/ diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index d96e0a9..135413e 100644 --- a/src/main/java/fr/organizee/controller/MembreController.java +++ b/src/main/java/fr/organizee/controller/MembreController.java @@ -9,6 +9,7 @@ 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; @@ -23,7 +24,7 @@ public class MembreController { @Autowired private TeamRepository teamRepo; - @GetMapping("/") + @RequestMapping("/") @ResponseBody public String home() { @@ -72,11 +73,36 @@ public class MembreController { return ResponseEntity.status(HttpStatus.OK).body(membre); } - @GetMapping(value = "/membres/delete/{id}") - public void deleteMembreId(@PathVariable("id") Integer id) { +// @GetMapping(value = "/membres/delete/{id}") +// public void deleteMembreId(@PathVariable("id") Integer id) { +// +// membreRepo.deleteById(id); +// +// } - membreRepo.deleteById(id); + @DeleteMapping(value = "/delete/{id}") + public ResponseEntity deleteMembre(@PathVariable int id){ + try { + membreRepo.delete(membreRepo.getById(id)); + //membreRepo.deleteById(id); + return ResponseEntity.status(HttpStatus.OK).body("Membre effacée !"); + } catch (EntityNotFoundException e) { + + return ResponseEntity.status(HttpStatus.OK).body("Membre introuvable !"); + } + } + + @PostMapping(value="/add", produces="application/json", consumes="application/json") + public ResponseEntity addMembre(@RequestBody Membre membre){ + Membre resultMembre = null; + try { + resultMembre = membreRepo.saveAndFlush(membre); + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.CREATED).body(resultMembre); } @GetMapping(value = "/team/{id}") diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index 7924e70..c41d870 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -1,5 +1,8 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.*; import java.time.LocalDate; @@ -17,9 +20,14 @@ public class Membre { private String isAdmin; private String couleur; private String smiley; - @ManyToOne +// @ManyToOne +// @JoinColumn(name="TEAM_ID") +// @JsonIgnore + + @ManyToOne(cascade = CascadeType.MERGE) @JoinColumn(name="TEAM_ID") - private Team team; + @JsonIgnoreProperties("membre") + private Team team; public Membre() { } @@ -33,7 +41,7 @@ public class Membre { this.isAdmin = isAdmin; this.couleur = couleur; this.smiley = smiley; -/* this.team = team;*/ + this.team = team; } public int getId() { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 65eea51..f53eb5c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -20,3 +20,4 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDial # Permet d'exécuter le data.sql # =============================== #spring.datasource.initialization-mode=always +server.port=4567 diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 1461cab..995f262 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -1,20 +1,42 @@ +-- -------------------------------------------------------- +-- Hôte : 192.168.1.16 +-- Version du serveur: 10.3.32-MariaDB-0ubuntu0.20.04.1 - Ubuntu 20.04 +-- SE du serveur: debian-linux-gnu +-- HeidiSQL Version: 9.5.0.5196 +-- -------------------------------------------------------- --- Export de la structure de la table jpa. team -CREATE TABLE IF NOT EXISTS `team` ( +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8mb4 */; +/*!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 +CREATE TABLE IF NOT EXISTS `contact` ( `id` int(11) NOT NULL AUTO_INCREMENT, + `adresse` varchar(255) DEFAULT NULL, + `date_naissance` date DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, `nom` varchar(255) DEFAULT NULL, + `prenom` varchar(255) DEFAULT NULL, + `telephone` 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) -/*!40000 ALTER TABLE `team` DISABLE KEYS */; -INSERT INTO `team` (`id`, `nom`) VALUES - (1, 'Team JAVA'), - (2, 'Team Angular'), - (3, 'Team PHP'), - (4, 'Team Bancal'); -/*!40000 ALTER TABLE `team` ENABLE KEYS */; +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4; +-- Export de données de la table jpa.contact : ~0 rows (environ) +/*!40000 ALTER TABLE `contact` DISABLE KEYS */; +INSERT INTO `contact` (`id`, `adresse`, `date_naissance`, `email`, `nom`, `prenom`, `telephone`) VALUES + (1, '7554 Messerschmidt Center', '2021-01-24', 'oogleasane0@cargocollective.com', 'Ophelia', 'O\'Gleasane', '913-198-6499'), + (2, '534 Jay Way', '2021-03-26', 'fmowett1@ocn.ne.jp', 'Fiann', 'Mowett', '248-224-7233'), + (3, '077 Buell Place', '2021-06-24', 'vlewknor2@spotify.com', 'Vladamir', 'Lewknor', '922-822-3626'), + (4, '6226 Esker Street', '2021-04-13', 'jbarmadier3@opensource.org', 'Jervis', 'Barmadier', '838-581-8112'), + (5, '28531 Luster Circle', '2021-06-15', 'tmee4@ameblo.jp', 'Tuesday', 'Mee', '761-975-7324'), + (6, '96 Hallows Avenue', '2021-08-13', 'tcolvine5@elegantthemes.com', 'Toni', 'Colvine', '348-778-7679'), + (7, '6401 Jay Crossing', '2021-01-14', 'rrielly6@netlog.com', 'Riane', 'Rielly', '740-571-0835'), + (8, '3273 Cascade Pass', '2021-03-22', 'jlauder7@rambler.ru', 'Juieta', 'Lauder', '928-408-6855'), + (9, '1170 Burning Wood Road', '2021-05-31', 'tbolver8@google.ca', 'Thibaut', 'Bolver', '681-860-8291'), + (10, '1 Westridge Road', '2021-03-11', 'emebs9@uol.com.br', 'Evered', 'Mebs', '898-483-6075'); +/*!40000 ALTER TABLE `contact` ENABLE KEYS */; -- Export de la structure de la table jpa. membre CREATE TABLE IF NOT EXISTS `membre` ( @@ -26,6 +48,7 @@ CREATE TABLE IF NOT EXISTS `membre` ( `nom` varchar(255) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `prenom` varchar(255) DEFAULT NULL, + `smiley` varchar(255) DEFAULT NULL, `team_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `FKll5mmgkw1h2kmxnuo4885x2fn` (`team_id`), @@ -34,169 +57,31 @@ CREATE TABLE IF NOT EXISTS `membre` ( -- Export de données de la table jpa.membre : ~0 rows (environ) /*!40000 ALTER TABLE `membre` DISABLE KEYS */; -INSERT INTO `membre` (`id`, `couleur`, `date_naissance`, `email`, `is_admin`, `nom`, `password`, `prenom`, `team_id`) VALUES - (1, '#fcba03', '2021-12-13', 'hedi@simplon.com', '0', 'SKYWALKER', 'toto', 'Hédi', 1), - (2, '#8df505', '2021-07-03', 'aline@simplon.com', '0', 'FETT', 'tata', 'Aline', 1), - (3, '#091ced', '2021-01-20', 'isabelle@simplon.com', '0', 'SOLO', 'titi', 'Isabelle', 2), - (4, '#ed09de', '2021-06-29', 'blandine@simplon.com', '0', 'VADER', 'tutu', 'Blandine', 3); +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), + (2, '#8df505', '2021-07-03', 'aline@simplon.com', '0', 'FETT', 'tata', 'Aline', NULL, 1), + (3, '#091ced', '2021-01-20', 'isabelle@simplon.com', '0', 'SOLO', 'titi', 'Isabelle', NULL, 2), + (4, '#ed09de', '2021-06-29', 'blandine@simplon.com', '0', 'VADER', 'tutu', 'Blandine', NULL, 3); /*!40000 ALTER TABLE `membre` ENABLE KEYS */; - --- Export de la structure de la table jpa. team_membres -CREATE TABLE IF NOT EXISTS `team_membres` ( - `team_id` int(11) NOT NULL, - `membres_id` int(11) NOT NULL, - UNIQUE KEY `UK_9e71olu3b26ah1kdrljr5i004` (`membres_id`), - KEY `FK83yf7h5v4bhum1i9bsj8io105` (`team_id`), - CONSTRAINT `FK7w6e9srma4vxmthpdvo9130qp` FOREIGN KEY (`membres_id`) REFERENCES `membre` (`id`), - CONSTRAINT `FK83yf7h5v4bhum1i9bsj8io105` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.team_membres : ~0 rows (environ) -/*!40000 ALTER TABLE `team_membres` DISABLE KEYS */; -INSERT INTO `team_membres` (`team_id`, `membres_id`) VALUES - (1, 1), - (1, 2), - (2, 3), - (3, 4); -/*!40000 ALTER TABLE `team_membres` ENABLE KEYS */; - - --- Export de la structure de la table jpa. todo_list -CREATE TABLE IF NOT EXISTS `todo_list` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `nom` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.todo_list : ~0 rows (environ) -/*!40000 ALTER TABLE `todo_list` DISABLE KEYS */; -INSERT INTO `todo_list` (`id`, `nom`) VALUES - (1, 'Pour Blandine'), - (2, 'Corvées'), - (3, 'Noel'); -/*!40000 ALTER TABLE `todo_list` ENABLE KEYS */; - --- Export de la structure de la table jpa. tache -CREATE TABLE IF NOT EXISTS `tache` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `etat` bit(1) NOT NULL, - `texte` varchar(255) DEFAULT NULL, - `todolist_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FK50q0ja9qvoud7ujsudc9jj9yk` (`todolist_id`), - 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) -/*!40000 ALTER TABLE `tache` DISABLE KEYS */; -INSERT INTO `tache` (`id`, `etat`, `texte`, `todolist_id`) VALUES - (1, b'0', 'Apprendre le PHP', 1), - (2, b'0', 'Revoir CRUD', 1), - (3, b'0', 'Acheter des guirlandes', 3), - (4, b'0', 'Acheter un sapin', 3), - (5, b'0', 'Trouver un repas', 3); -/*!40000 ALTER TABLE `tache` ENABLE KEYS */; - --- Export de la structure de la table jpa. team_todolist -CREATE TABLE IF NOT EXISTS `team_todolist` ( - `team_id` int(11) NOT NULL, - `todolists_id` int(11) NOT NULL, - UNIQUE KEY `UK_fjwjvprqqeeugglduq8rdhsyw` (`todolists_id`), - KEY `FK7jh4kgpji05rll7nagp4dsago` (`team_id`), - CONSTRAINT `FK4ntj6ub8hheh7f4w79qy3ql40` FOREIGN KEY (`todolists_id`) REFERENCES `todo_list` (`id`), - CONSTRAINT `FK7jh4kgpji05rll7nagp4dsago` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.team_todolist : ~0 rows (environ) -/*!40000 ALTER TABLE `team_todolist` DISABLE KEYS */; -INSERT INTO `team_todolist` (`team_id`, `todolists_id`) VALUES - (2, 2), - (2, 3), - (3, 1); -/*!40000 ALTER TABLE `team_todolist` ENABLE KEYS */; - --- Export de la structure de la table jpa. smiley -CREATE TABLE IF NOT EXISTS `smiley` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `smiley_url` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.smiley : ~0 rows (environ) -/*!40000 ALTER TABLE `smiley` DISABLE KEYS */; -INSERT INTO `smiley` (`id`, `smiley_url`) VALUES - (1, 'https://assets.wprock.fr/emoji/joypixels/512/1f600.png'), - (2, 'https://assets.wprock.fr/emoji/joypixels/512/1f618.png'), - (3, 'https://assets.wprock.fr/emoji/joypixels/512/1f92e.png'), - (4, 'https://assets.wprock.fr/emoji/joypixels/512/1f92c.png'); -/*!40000 ALTER TABLE `smiley` ENABLE KEYS */; - - --- Export de la structure de la table jpa. smiley_membres -CREATE TABLE IF NOT EXISTS `smiley_membres` ( - `smiley_id` int(11) NOT NULL, - `membres_id` int(11) NOT NULL, - UNIQUE KEY `UK_haqfbvq4lbo8rb77uew2yvwuw` (`membres_id`), - KEY `FK9msxvne1uolrrrg8aq9p53sc4` (`smiley_id`), - CONSTRAINT `FK4fj42p25xaldnw9koqktnhil2` FOREIGN KEY (`membres_id`) REFERENCES `membre` (`id`), - CONSTRAINT `FK9msxvne1uolrrrg8aq9p53sc4` FOREIGN KEY (`smiley_id`) REFERENCES `smiley` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.smiley_membres : ~0 rows (environ) -/*!40000 ALTER TABLE `smiley_membres` DISABLE KEYS */; -INSERT INTO `smiley_membres` (`smiley_id`, `membres_id`) VALUES - (1, 3), - (3, 2), - (4, 1); -/*!40000 ALTER TABLE `smiley_membres` ENABLE KEYS */; - - -- Export de la structure de la table jpa. menu CREATE TABLE IF NOT EXISTS `menu` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date_menu` date DEFAULT NULL, `libelle` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) + `membre_id` int(11) DEFAULT NULL, + `team_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK9k2sad7pn2qsivwavhptvm3u6` (`membre_id`), + KEY `FKky2j5l3syborv9dtqtprgpr28` (`team_id`), + CONSTRAINT `FK9k2sad7pn2qsivwavhptvm3u6` FOREIGN KEY (`membre_id`) REFERENCES `membre` (`id`), + 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) /*!40000 ALTER TABLE `menu` DISABLE KEYS */; /*!40000 ALTER TABLE `menu` ENABLE KEYS */; - --- Export de la structure de la table jpa. contact -CREATE TABLE IF NOT EXISTS `contact` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `adresse` varchar(255) DEFAULT NULL, - `date_naissance` date DEFAULT NULL, - `email` varchar(255) DEFAULT NULL, - `nom` varchar(255) DEFAULT NULL, - `prenom` varchar(255) DEFAULT NULL, - `telephone` varchar(255) DEFAULT NULL, - `team_id` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `FK7gyd9s84tx9eeuigeu3uv984x` (`team_id`), - 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) -/*!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), - (2, '534 Jay Way', '2021-03-26', 'fmowett1@ocn.ne.jp', 'Fiann', 'Mowett', '248-224-7233', 1), - (3, '077 Buell Place', '2021-06-24', 'vlewknor2@spotify.com', 'Vladamir', 'Lewknor', '922-822-3626', 1), - (4, '6226 Esker Street', '2021-04-13', 'jbarmadier3@opensource.org', 'Jervis', 'Barmadier', '838-581-8112', 1), - (5, '28531 Luster Circle', '2021-06-15', 'tmee4@ameblo.jp', 'Tuesday', 'Mee', '761-975-7324', 2), - (6, '96 Hallows Avenue', '2021-08-13', 'tcolvine5@elegantthemes.com', 'Toni', 'Colvine', '348-778-7679', 2), - (7, '6401 Jay Crossing', '2021-01-14', 'rrielly6@netlog.com', 'Riane', 'Rielly', '740-571-0835', 2), - (8, '3273 Cascade Pass', '2021-03-22', 'jlauder7@rambler.ru', 'Juieta', 'Lauder', '928-408-6855', 2), - (9, '1170 Burning Wood Road', '2021-05-31', 'tbolver8@google.ca', 'Thibaut', 'Bolver', '681-860-8291', 3), - (10, '1 Westridge Road', '2021-03-11', 'emebs9@uol.com.br', 'Evered', 'Mebs', '898-483-6075', 3); -/*!40000 ALTER TABLE `contact` ENABLE KEYS */; - - - -- Export de la structure de la table jpa. repertoire CREATE TABLE IF NOT EXISTS `repertoire` ( `team_id` int(11) NOT NULL, @@ -220,4 +105,92 @@ INSERT INTO `repertoire` (`team_id`, `contacts_id`) VALUES (2, 8), (3, 9), (3, 10); -/*!40000 ALTER TABLE `repertoire` ENABLE KEYS */; \ No newline at end of file +/*!40000 ALTER TABLE `repertoire` ENABLE KEYS */; + +-- Export de la structure de la table jpa. tache +CREATE TABLE IF NOT EXISTS `tache` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `etat` bit(1) NOT NULL, + `texte` varchar(255) DEFAULT NULL, + `todolist_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK50q0ja9qvoud7ujsudc9jj9yk` (`todolist_id`), + 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) +/*!40000 ALTER TABLE `tache` DISABLE KEYS */; +INSERT INTO `tache` (`id`, `etat`, `texte`, `todolist_id`) VALUES + (1, b'0', 'Apprendre le PHP', 1), + (2, b'0', 'Revoir CRUD', 1), + (3, b'0', 'Acheter des guirlandes', 3), + (4, b'0', 'Acheter un sapin', 3), + (5, b'0', 'Trouver un repas', 3); +/*!40000 ALTER TABLE `tache` ENABLE KEYS */; + +-- Export de la structure de la table jpa. 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) +/*!40000 ALTER TABLE `team` DISABLE KEYS */; +INSERT INTO `team` (`id`, `nom`) VALUES + (1, 'Team JAVA'), + (2, 'Team Angular'), + (3, 'Team PHP'), + (4, 'Team Bancal'); +/*!40000 ALTER TABLE `team` ENABLE KEYS */; + +-- Export de la structure de la table jpa. team_menu +CREATE TABLE IF NOT EXISTS `team_menu` ( + `team_id` int(11) NOT NULL, + `menus_id` int(11) NOT NULL, + UNIQUE KEY `UK_bct73pef90yxrapd4pu8sahk8` (`menus_id`), + KEY `FKcovbsbmma6ibkomtg6y15oy4a` (`team_id`), + CONSTRAINT `FK8hdjys2iu86t1tm4iq492h3ti` FOREIGN KEY (`menus_id`) REFERENCES `menu` (`id`), + CONSTRAINT `FKcovbsbmma6ibkomtg6y15oy4a` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Export de données de la table jpa.team_menu : ~0 rows (environ) +/*!40000 ALTER TABLE `team_menu` DISABLE KEYS */; +/*!40000 ALTER TABLE `team_menu` ENABLE KEYS */; + +-- Export de la structure de la table jpa. team_todolist +CREATE TABLE IF NOT EXISTS `team_todolist` ( + `team_id` int(11) NOT NULL, + `todolists_id` int(11) NOT NULL, + UNIQUE KEY `UK_fjwjvprqqeeugglduq8rdhsyw` (`todolists_id`), + KEY `FK7jh4kgpji05rll7nagp4dsago` (`team_id`), + CONSTRAINT `FK4ntj6ub8hheh7f4w79qy3ql40` FOREIGN KEY (`todolists_id`) REFERENCES `todo_list` (`id`), + CONSTRAINT `FK7jh4kgpji05rll7nagp4dsago` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Export de données de la table jpa.team_todolist : ~0 rows (environ) +/*!40000 ALTER TABLE `team_todolist` DISABLE KEYS */; +INSERT INTO `team_todolist` (`team_id`, `todolists_id`) VALUES + (2, 2), + (2, 3), + (3, 1); +/*!40000 ALTER TABLE `team_todolist` ENABLE KEYS */; + +-- Export de la structure de la table jpa. todo_list +CREATE TABLE IF NOT EXISTS `todo_list` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `nom` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4; + +-- Export de données de la table jpa.todo_list : ~0 rows (environ) +/*!40000 ALTER TABLE `todo_list` DISABLE KEYS */; +INSERT INTO `todo_list` (`id`, `nom`) VALUES + (1, 'Pour Blandine'), + (2, 'Corvées'), + (3, 'Noel'); +/*!40000 ALTER TABLE `todo_list` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; +/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; From 1ed83733596b3551ae468655f5f96ae2bf004c89 Mon Sep 17 00:00:00 2001 From: Hedi Date: Sat, 8 Jan 2022 18:32:16 +0100 Subject: [PATCH 2/5] modif class membre et team --- .../controller/MembreController.java | 103 +++++++++++++----- .../organizee/controller/TeamController.java | 59 ++++++++++ src/main/java/fr/organizee/model/Contact.java | 17 ++- src/main/java/fr/organizee/model/Team.java | 11 +- .../repository/MembreRepository.java | 2 +- src/main/resources/application.properties | 4 +- 6 files changed, 159 insertions(+), 37 deletions(-) create mode 100644 src/main/java/fr/organizee/controller/TeamController.java diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java index 135413e..d200dc3 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; @@ -16,15 +16,16 @@ import java.util.Optional; /* toto */ @RestController @CrossOrigin("*") +@RequestMapping("/membres") public class MembreController { @Autowired private MembreRepository membreRepo; - @Autowired - private TeamRepository teamRepo; +// @Autowired +// private TeamRepository teamRepo; - @RequestMapping("/") +// @RequestMapping("/membres") @ResponseBody public String home() { @@ -34,7 +35,7 @@ public class MembreController { return sb.toString(); } - @GetMapping(value = "/membres/all") + @GetMapping(value = "/all") public ResponseEntity getAll(){ List liste = null; try @@ -47,20 +48,20 @@ public class MembreController { return ResponseEntity.status(HttpStatus.OK).body(liste); } - @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); - } +// @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); +// } - return ResponseEntity.status(HttpStatus.OK).body(liste); - } - - @GetMapping(value = "/membres/{id}") + @GetMapping(value = "/{id}") public ResponseEntity findById(@PathVariable int id){ Optional membre = null; try @@ -105,16 +106,64 @@ public class MembreController { return ResponseEntity.status(HttpStatus.CREATED).body(resultMembre); } - @GetMapping(value = "/team/{id}") - public ResponseEntity findTeamById(@PathVariable int id){ - Optional liste = null; - try - { - liste = teamRepo.findById(id); + @PutMapping("/update/{id}") + 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(null); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); } - return ResponseEntity.status(HttpStatus.OK).body(liste); + 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); +// } + + @PostMapping(value="/login", produces="application/json", consumes="application/json") + public ResponseEntity login(@RequestBody Membre membre){ + Membre resultMembre = null; + try { + resultMembre = membreRepo.findByNom(membre.getNom()); + if(resultMembre == null){ + throw new RuntimeException("User inexistant."); + } + if(!resultMembre.getPassword().equals(membre.getPassword())){ + throw new RuntimeException("mauvais password."); + } + } catch (Exception e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); + } + + return ResponseEntity.status(HttpStatus.CREATED).body(resultMembre); } } diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java new file mode 100644 index 0000000..68a2e1f --- /dev/null +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -0,0 +1,59 @@ +package fr.organizee.controller; + +import fr.organizee.model.Team; +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; + +/* toto */ +@RestController +@CrossOrigin("*") +@RequestMapping("/teams") +public class TeamController { + + @Autowired + private TeamRepository teamRepo; + +// @RequestMapping("/teams") + @ResponseBody + public String home() + { + StringBuilder sb = new StringBuilder(); + sb.append("

Affichages des teams

"); + sb.append("
  • Liste des teams
  • "); + return sb.toString(); + } + + @GetMapping(value = "/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); + } + + @GetMapping(value = "/{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/model/Contact.java b/src/main/java/fr/organizee/model/Contact.java index 38a8111..ccd14c6 100644 --- a/src/main/java/fr/organizee/model/Contact.java +++ b/src/main/java/fr/organizee/model/Contact.java @@ -1,5 +1,7 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.*; import java.time.LocalDate; @@ -14,20 +16,22 @@ public class Contact { private String email; private String adresse; private LocalDate dateNaissance; -/* @ManyToOne(fetch= FetchType.EAGER) + @ManyToOne(cascade = CascadeType.MERGE) @JoinColumn(name="TEAM_ID") - private Team team;*/ + @JsonIgnoreProperties("contact") + private Team team; public Contact() { } - public Contact(String nom, String prenom, String telephone, String email, String adresse, LocalDate dateNaissance) { + public Contact(String nom, String prenom, String telephone, String email, String adresse, LocalDate dateNaissance, Team team) { this.nom = nom; this.prenom = prenom; this.telephone = telephone; this.email = email; this.adresse = adresse; this.dateNaissance = dateNaissance; + this.team = team; } public int getId() { @@ -86,6 +90,13 @@ public class Contact { this.dateNaissance = dateNaissance; } + public Team getTeam() { + return team; + } + public void setTeam(Team team) { + this.team = team; + } + @Override public String toString() { return "Contact{" + diff --git a/src/main/java/fr/organizee/model/Team.java b/src/main/java/fr/organizee/model/Team.java index ce562e2..e21f803 100644 --- a/src/main/java/fr/organizee/model/Team.java +++ b/src/main/java/fr/organizee/model/Team.java @@ -1,5 +1,7 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.*; import java.util.ArrayList; import java.util.List; @@ -10,11 +12,12 @@ public class Team { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; - @OneToMany(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true) - //@OneToMany + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @JsonIgnoreProperties("team") private List membres = new ArrayList<>(); - @OneToMany - @JoinTable(name = "repertoire") + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @JsonIgnoreProperties("team") + //@JoinTable(name = "repertoire") private List contacts = new ArrayList<>(); @OneToMany @JoinTable(name = "team_todolist") diff --git a/src/main/java/fr/organizee/repository/MembreRepository.java b/src/main/java/fr/organizee/repository/MembreRepository.java index 61ec145..a8aafe8 100644 --- a/src/main/java/fr/organizee/repository/MembreRepository.java +++ b/src/main/java/fr/organizee/repository/MembreRepository.java @@ -6,5 +6,5 @@ import org.springframework.stereotype.Repository; @Repository public interface MembreRepository extends JpaRepository { - + Membre findByNom(String nom); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f53eb5c..773629d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,8 +2,8 @@ # base de données MySQL toto # =============================== spring.datasource.url=jdbc:mysql://192.168.1.16:3306/jpa?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC -spring.datasource.username= -spring.datasource.password= +spring.datasource.username=desktop +spring.datasource.password=Cosmoc4t$77 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # log #logging.level.root=INFO From cb3218ac1ed19fba8f08923efb56df7e72f5eb4c Mon Sep 17 00:00:00 2001 From: Hedi Date: Sat, 8 Jan 2022 18:39:36 +0100 Subject: [PATCH 3/5] sans properties --- .gitignore | 1 + src/main/resources/application.properties | 23 ----------------------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 src/main/resources/application.properties diff --git a/.gitignore b/.gitignore index ee31714..f368ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ !**/src/test/**/target/ +/src/main/resources/application.properties ### STS ### .apt_generated diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 773629d..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,23 +0,0 @@ -# =============================== -# base de données MySQL toto -# =============================== -spring.datasource.url=jdbc:mysql://192.168.1.16:3306/jpa?useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC -spring.datasource.username=desktop -spring.datasource.password=Cosmoc4t$77 -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -# log -#logging.level.root=INFO -logging.file=d:/data/log-hibernate-jpa.log -logging.level.org.springframework.jdbc.core.JdbcTemplate=debug -# =============================== -# JPA / HIBERNATE -# =============================== -spring.jpa.show-sql=true -#spring.jpa.hibernate.ddl-auto=update -spring.jpa.hibernate.ddl-auto=create-drop -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect -# =============================== -# Permet d'exécuter le data.sql -# =============================== -#spring.datasource.initialization-mode=always -server.port=4567 From 0c0f9467f10556510dd43f965396204f6f9d411c Mon Sep 17 00:00:00 2001 From: Hedi Date: Sat, 8 Jan 2022 18:46:36 +0100 Subject: [PATCH 4/5] comment --- src/main/java/fr/organizee/controller/TeamController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/fr/organizee/controller/TeamController.java b/src/main/java/fr/organizee/controller/TeamController.java index 68a2e1f..632f368 100644 --- a/src/main/java/fr/organizee/controller/TeamController.java +++ b/src/main/java/fr/organizee/controller/TeamController.java @@ -30,6 +30,7 @@ public class TeamController { return sb.toString(); } + // Récupération de toutes les teams @GetMapping(value = "/all") public ResponseEntity getAllTeam(){ List liste = null; From 48c83433b80099ad6621a10408220284c7cf69f4 Mon Sep 17 00:00:00 2001 From: Hedi Date: Fri, 14 Jan 2022 14:20:32 +0100 Subject: [PATCH 5/5] Modif class/repo/controller --- src/main/java/fr/organizee/model/Membre.java | 3 +- src/main/java/fr/organizee/model/Menu.java | 6 +- src/main/java/fr/organizee/model/Tache.java | 23 +++- src/main/java/fr/organizee/model/Team.java | 9 +- .../java/fr/organizee/model/TodoList.java | 8 +- src/main/resources/data.sql | 105 +++++------------- 6 files changed, 61 insertions(+), 93 deletions(-) diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java index c41d870..36f2bd8 100644 --- a/src/main/java/fr/organizee/model/Membre.java +++ b/src/main/java/fr/organizee/model/Membre.java @@ -23,11 +23,10 @@ public class Membre { // @ManyToOne // @JoinColumn(name="TEAM_ID") // @JsonIgnore - @ManyToOne(cascade = CascadeType.MERGE) @JoinColumn(name="TEAM_ID") @JsonIgnoreProperties("membre") - private Team team; + private Team team; public Membre() { } diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java index 0444921..67b1531 100644 --- a/src/main/java/fr/organizee/model/Menu.java +++ b/src/main/java/fr/organizee/model/Menu.java @@ -1,5 +1,7 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.*; import java.time.LocalDate; @@ -10,7 +12,9 @@ public class Menu { private int id; private String libelle; private LocalDate dateMenu; - @ManyToOne + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="TEAM_ID") + @JsonIgnoreProperties("menu") private Team team; @ManyToOne private Membre membre; diff --git a/src/main/java/fr/organizee/model/Tache.java b/src/main/java/fr/organizee/model/Tache.java index 28dd8b1..e3d9d03 100644 --- a/src/main/java/fr/organizee/model/Tache.java +++ b/src/main/java/fr/organizee/model/Tache.java @@ -1,5 +1,7 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.*; @Entity @@ -8,12 +10,13 @@ public class Tache { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String texte; - private boolean etat; - @ManyToOne - @JoinColumn(name = "todolist_id") + private Boolean etat; + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="TODOLIST_ID") + @JsonIgnoreProperties("tache") private TodoList todolist; - public Tache(String texte, boolean etat) { + public Tache(String texte, Boolean etat) { this.texte = texte; this.etat = etat; } @@ -37,14 +40,22 @@ public class Tache { this.texte = texte; } - public boolean isEtat() { + public Boolean getEtat() { return etat; } - public void setEtat(boolean etat) { + public void setEtat(Boolean etat) { this.etat = etat; } + public TodoList getTodolist() { + return todolist; + } + + public void setTodolist(TodoList todolist) { + this.todolist = todolist; + } + @Override public String toString() { return "Tache{" + diff --git a/src/main/java/fr/organizee/model/Team.java b/src/main/java/fr/organizee/model/Team.java index e21f803..0b9ddbe 100644 --- a/src/main/java/fr/organizee/model/Team.java +++ b/src/main/java/fr/organizee/model/Team.java @@ -17,13 +17,12 @@ public class Team { private List membres = new ArrayList<>(); @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) @JsonIgnoreProperties("team") - //@JoinTable(name = "repertoire") private List contacts = new ArrayList<>(); - @OneToMany - @JoinTable(name = "team_todolist") + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @JsonIgnoreProperties("team") private List todolists = new ArrayList<>(); - @OneToMany - @JoinTable(name="team_menu") + @OneToMany(mappedBy = "team", fetch=FetchType.LAZY) + @JsonIgnoreProperties("team") 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 c86b70c..01f0328 100644 --- a/src/main/java/fr/organizee/model/TodoList.java +++ b/src/main/java/fr/organizee/model/TodoList.java @@ -1,5 +1,7 @@ package fr.organizee.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import javax.persistence.*; import java.util.ArrayList; import java.util.List; @@ -10,8 +12,10 @@ public class TodoList { @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String nom; - @OneToMany(mappedBy = "todolist") - private List taches = new ArrayList<>(); + @ManyToOne(cascade = CascadeType.MERGE) + @JoinColumn(name="TEAM_ID") + @JsonIgnoreProperties("todolist") + private Team team; public TodoList() { } diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 995f262..298f168 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -20,22 +20,25 @@ CREATE TABLE IF NOT EXISTS `contact` ( `nom` varchar(255) DEFAULT NULL, `prenom` varchar(255) DEFAULT NULL, `telephone` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) + `team_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK7gyd9s84tx9eeuigeu3uv984x` (`team_id`), + 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) /*!40000 ALTER TABLE `contact` DISABLE KEYS */; -INSERT INTO `contact` (`id`, `adresse`, `date_naissance`, `email`, `nom`, `prenom`, `telephone`) VALUES - (1, '7554 Messerschmidt Center', '2021-01-24', 'oogleasane0@cargocollective.com', 'Ophelia', 'O\'Gleasane', '913-198-6499'), - (2, '534 Jay Way', '2021-03-26', 'fmowett1@ocn.ne.jp', 'Fiann', 'Mowett', '248-224-7233'), - (3, '077 Buell Place', '2021-06-24', 'vlewknor2@spotify.com', 'Vladamir', 'Lewknor', '922-822-3626'), - (4, '6226 Esker Street', '2021-04-13', 'jbarmadier3@opensource.org', 'Jervis', 'Barmadier', '838-581-8112'), - (5, '28531 Luster Circle', '2021-06-15', 'tmee4@ameblo.jp', 'Tuesday', 'Mee', '761-975-7324'), - (6, '96 Hallows Avenue', '2021-08-13', 'tcolvine5@elegantthemes.com', 'Toni', 'Colvine', '348-778-7679'), - (7, '6401 Jay Crossing', '2021-01-14', 'rrielly6@netlog.com', 'Riane', 'Rielly', '740-571-0835'), - (8, '3273 Cascade Pass', '2021-03-22', 'jlauder7@rambler.ru', 'Juieta', 'Lauder', '928-408-6855'), - (9, '1170 Burning Wood Road', '2021-05-31', 'tbolver8@google.ca', 'Thibaut', 'Bolver', '681-860-8291'), - (10, '1 Westridge Road', '2021-03-11', 'emebs9@uol.com.br', 'Evered', 'Mebs', '898-483-6075'); +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), + (2, '534 Jay Way', '2021-03-26', 'fmowett1@ocn.ne.jp', 'Fiann', 'Mowett', '248-224-7233', 1), + (3, '077 Buell Place', '2021-06-24', 'vlewknor2@spotify.com', 'Vladamir', 'Lewknor', '922-822-3626', 1), + (4, '6226 Esker Street', '2021-04-13', 'jbarmadier3@opensource.org', 'Jervis', 'Barmadier', '838-581-8112', 2), + (5, '28531 Luster Circle', '2021-06-15', 'tmee4@ameblo.jp', 'Tuesday', 'Mee', '761-975-7324', 2), + (6, '96 Hallows Avenue', '2021-08-13', 'tcolvine5@elegantthemes.com', 'Toni', 'Colvine', '348-778-7679', 2), + (7, '6401 Jay Crossing', '2021-01-14', 'rrielly6@netlog.com', 'Riane', 'Rielly', '740-571-0835', 3), + (8, '3273 Cascade Pass', '2021-03-22', 'jlauder7@rambler.ru', 'Juieta', 'Lauder', '928-408-6855', 3), + (9, '1170 Burning Wood Road', '2021-05-31', 'tbolver8@google.ca', 'Thibaut', 'Bolver', '681-860-8291', 4), + (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 @@ -53,7 +56,7 @@ CREATE TABLE IF NOT EXISTS `membre` ( PRIMARY KEY (`id`), KEY `FKll5mmgkw1h2kmxnuo4885x2fn` (`team_id`), CONSTRAINT `FKll5mmgkw1h2kmxnuo4885x2fn` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4; -- Export de données de la table jpa.membre : ~0 rows (environ) /*!40000 ALTER TABLE `membre` DISABLE KEYS */; @@ -61,7 +64,9 @@ INSERT INTO `membre` (`id`, `couleur`, `date_naissance`, `email`, `is_admin`, `n (1, '#fcba03', '2021-12-13', 'hedi@simplon.com', '0', 'SKYWALKER', 'toto', 'Hédi', NULL, 1), (2, '#8df505', '2021-07-03', 'aline@simplon.com', '0', 'FETT', 'tata', 'Aline', NULL, 1), (3, '#091ced', '2021-01-20', 'isabelle@simplon.com', '0', 'SOLO', 'titi', 'Isabelle', NULL, 2), - (4, '#ed09de', '2021-06-29', 'blandine@simplon.com', '0', 'VADER', 'tutu', 'Blandine', NULL, 3); + (4, '#ed09de', '2021-06-29', 'blandine@simplon.com', '0', 'VADER', 'tutu', 'Blandine', NULL, 3), + (5, '#ed09de', '2021-08-29', 'sana@simplon.com', '0', 'C3PO', 'riri', 'Sana', NULL, 4), + (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 @@ -82,35 +87,10 @@ CREATE TABLE IF NOT EXISTS `menu` ( /*!40000 ALTER TABLE `menu` DISABLE KEYS */; /*!40000 ALTER TABLE `menu` ENABLE KEYS */; --- Export de la structure de la table jpa. repertoire -CREATE TABLE IF NOT EXISTS `repertoire` ( - `team_id` int(11) NOT NULL, - `contacts_id` int(11) NOT NULL, - UNIQUE KEY `UK_g91q6p6ssjxdhcallbd9yfary` (`contacts_id`), - KEY `FK7u57nrpbtl5yhuh3nyx0ccy88` (`team_id`), - CONSTRAINT `FK7u57nrpbtl5yhuh3nyx0ccy88` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`), - CONSTRAINT `FKe3fy0q6urmw03kn29mj7h7vf5` FOREIGN KEY (`contacts_id`) REFERENCES `contact` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.repertoire : ~0 rows (environ) -/*!40000 ALTER TABLE `repertoire` DISABLE KEYS */; -INSERT INTO `repertoire` (`team_id`, `contacts_id`) VALUES - (1, 1), - (1, 2), - (1, 3), - (1, 4), - (2, 5), - (2, 6), - (2, 7), - (2, 8), - (3, 9), - (3, 10); -/*!40000 ALTER TABLE `repertoire` ENABLE KEYS */; - -- Export de la structure de la table jpa. tache CREATE TABLE IF NOT EXISTS `tache` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `etat` bit(1) NOT NULL, + `etat` bit(1) DEFAULT NULL, `texte` varchar(255) DEFAULT NULL, `todolist_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -144,51 +124,22 @@ INSERT INTO `team` (`id`, `nom`) VALUES (4, 'Team Bancal'); /*!40000 ALTER TABLE `team` ENABLE KEYS */; --- Export de la structure de la table jpa. team_menu -CREATE TABLE IF NOT EXISTS `team_menu` ( - `team_id` int(11) NOT NULL, - `menus_id` int(11) NOT NULL, - UNIQUE KEY `UK_bct73pef90yxrapd4pu8sahk8` (`menus_id`), - KEY `FKcovbsbmma6ibkomtg6y15oy4a` (`team_id`), - CONSTRAINT `FK8hdjys2iu86t1tm4iq492h3ti` FOREIGN KEY (`menus_id`) REFERENCES `menu` (`id`), - CONSTRAINT `FKcovbsbmma6ibkomtg6y15oy4a` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.team_menu : ~0 rows (environ) -/*!40000 ALTER TABLE `team_menu` DISABLE KEYS */; -/*!40000 ALTER TABLE `team_menu` ENABLE KEYS */; - --- Export de la structure de la table jpa. team_todolist -CREATE TABLE IF NOT EXISTS `team_todolist` ( - `team_id` int(11) NOT NULL, - `todolists_id` int(11) NOT NULL, - UNIQUE KEY `UK_fjwjvprqqeeugglduq8rdhsyw` (`todolists_id`), - KEY `FK7jh4kgpji05rll7nagp4dsago` (`team_id`), - CONSTRAINT `FK4ntj6ub8hheh7f4w79qy3ql40` FOREIGN KEY (`todolists_id`) REFERENCES `todo_list` (`id`), - CONSTRAINT `FK7jh4kgpji05rll7nagp4dsago` FOREIGN KEY (`team_id`) REFERENCES `team` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - --- Export de données de la table jpa.team_todolist : ~0 rows (environ) -/*!40000 ALTER TABLE `team_todolist` DISABLE KEYS */; -INSERT INTO `team_todolist` (`team_id`, `todolists_id`) VALUES - (2, 2), - (2, 3), - (3, 1); -/*!40000 ALTER TABLE `team_todolist` ENABLE KEYS */; - -- Export de la structure de la table jpa. todo_list CREATE TABLE IF NOT EXISTS `todo_list` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nom` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) + `team_id` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK6ty40hkdysbql7xaewhujsjg` (`team_id`), + 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) /*!40000 ALTER TABLE `todo_list` DISABLE KEYS */; -INSERT INTO `todo_list` (`id`, `nom`) VALUES - (1, 'Pour Blandine'), - (2, 'Corvées'), - (3, 'Noel'); +INSERT INTO `todo_list` (`id`, `nom`, `team_id`) VALUES + (1, 'Pour Blandine', 1), + (2, 'Corvées', 1), + (3, 'Noel', 1); /*!40000 ALTER TABLE `todo_list` ENABLE KEYS */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;