From 786d8b23d9a438a8a56a058812df54a55d99a22a Mon Sep 17 00:00:00 2001
From: Thomas Cardon <thomas.cardon35@gmail.com>
Date: Fri, 21 Jan 2022 20:04:05 +0100
Subject: [PATCH 1/6] export collec postman

---
 src/main/resources/Postman | 563 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 557 insertions(+), 6 deletions(-)

diff --git a/src/main/resources/Postman b/src/main/resources/Postman
index 0203063..94de556 100644
--- a/src/main/resources/Postman
+++ b/src/main/resources/Postman
@@ -1,6 +1,557 @@
-Nouvelle Requête POSTMAN:
-
-20/01/2022
-	GET  	localhost:8080/restaurantbytype/1
-
-
+{
+	"info": {
+		"_postman_id": "5edbac98-7561-4ccc-b517-87c01aef2a41",
+		"name": "Simpleat",
+		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+	},
+	"item": [
+		{
+			"name": "Personne",
+			"item": [
+				{
+					"name": "Accueil",
+					"protocolProfileBehavior": {
+						"disableBodyPruning": true
+					},
+					"request": {
+						"method": "GET",
+						"header": [],
+						"body": {
+							"mode": "formdata",
+							"formdata": []
+						},
+						"url": {
+							"raw": "localhost:8080/",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								""
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "affichPersonnes",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/users",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"users"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AffichUnePersonne",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/user/2",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"user",
+								"2"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AjoutPersonne",
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n        \"nom\": \"nouvel\",\r\n        \"prenom\": \"ajout\",\r\n        \"email\": \"role@ajout.fr\",\r\n        \"password\": \"root\",\r\n        \"roles\": [\r\n            {\r\n            \"id\": 2\r\n            }\r\n        ]\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8080/add-user",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"add-user"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "UpdatePersonne",
+					"request": {
+						"method": "PUT",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n        \"id\": 2,\r\n        \"nom\": \"salut\",\r\n        \"prenom\": \"enleve\",\r\n        \"email\": \"nouvel@ajout.fr\",\r\n        \"password\": \"root\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8080/update-user/2",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"update-user",
+								"2"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "DeletePersonne",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/delete-user/1",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"delete-user",
+								"1"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "Preference",
+			"item": [
+				{
+					"name": "AffichPreference",
+					"protocolProfileBehavior": {
+						"disableBodyPruning": true
+					},
+					"request": {
+						"method": "GET",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "localhost:8080/preference/5/5",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"preference",
+								"5",
+								"5"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AffichPreferences",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/preferences",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"preferences"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "Ajout preferences",
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"preferencePK\": {\r\n        \"personne\": {\r\n            \"id\": 10\r\n        },\r\n        \"restau\": {\r\n            \"id\": 2\r\n        }\r\n    },\r\n    \"note\": 5,\r\n    \"favori\": true\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "localhost:8080/add-preference",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"add-preference"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "Delete preferences",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/delete-preference/:idrestau/:iduser",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"delete-preference",
+								":idrestau",
+								":iduser"
+							],
+							"variable": [
+								{
+									"key": "idrestau",
+									"value": "3"
+								},
+								{
+									"key": "iduser",
+									"value": "1"
+								}
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "Del prefByRestau[OUT]",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/delete-pref-byrestau/3",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"delete-pref-byrestau",
+								"3"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "Restaurant",
+			"item": [
+				{
+					"name": "AffichRestaurants",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/restaurants",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"restaurants"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AfficheUnRestaurant",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/restaurant/2",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"restaurant",
+								"2"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AfficheRestoParType",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/restaurantbytype/1",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"restaurantbytype",
+								"1"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AjoutRestaurant",
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "    {\r\n        \"nom\": \"gevaudan\",\r\n        \"adresse\": \"Montreil\",\r\n        \"latitude\": \"31.45571\",\r\n        \"longitude\": \"34.43719\",\r\n        \"typerestaus\": [\r\n             {\r\n            \"id\": 3\r\n             },\r\n             {\r\n            \"id\": 4\r\n             }\r\n        ]\r\n    }",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8080/add-restaurant",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"add-restaurant"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "UpdateRestaurant",
+					"request": {
+						"method": "PUT",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "    {\r\n        \"id\": 2,\r\n        \"nom\": \"suepr\",\r\n        \"adresse\": \"93100 Montreuil\",\r\n        \"telephone\": \"6809964349\",\r\n        \"aEmporter\": false,\r\n        \"surPlace\": true,\r\n        \"prixMin\": 1.0,\r\n        \"prixMax\": 17.0,\r\n        \"accesPMR\": false,\r\n        \"latitude\": \"31.45571\",\r\n        \"longitude\": \"34.43719\",\r\n        \"typerestaus\": []\r\n    }",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "http://localhost:8080/update-restaurant/2",
+							"protocol": "http",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"update-restaurant",
+								"2"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "DeleteRestaurant",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/delete-restaurant/4",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"delete-restaurant",
+								"4"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "Type",
+			"item": [
+				{
+					"name": "AffichTypes",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/types",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"types"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "Affich1Type",
+					"request": {
+						"method": "GET",
+						"header": [],
+						"url": {
+							"raw": "localhost:8080/type/2",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"type",
+								"2"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "UpdateType",
+					"request": {
+						"method": "PUT",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"id\": 2,\r\n    \"libelle\": \"creperie\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "localhost:8080/update-type/2",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"update-type",
+								"2"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "AddType",
+					"event": [
+						{
+							"listen": "prerequest",
+							"script": {
+								"exec": [
+									""
+								],
+								"type": "text/javascript"
+							}
+						}
+					],
+					"request": {
+						"method": "POST",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": "{\r\n    \"libelle\": \"coucou\"\r\n}",
+							"options": {
+								"raw": {
+									"language": "json"
+								}
+							}
+						},
+						"url": {
+							"raw": "localhost:8080/add-type",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"add-type"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "DeleteType",
+					"request": {
+						"method": "DELETE",
+						"header": [],
+						"body": {
+							"mode": "raw",
+							"raw": ""
+						},
+						"url": {
+							"raw": "localhost:8080/delete-type/:id",
+							"host": [
+								"localhost"
+							],
+							"port": "8080",
+							"path": [
+								"delete-type",
+								":id"
+							],
+							"variable": [
+								{
+									"key": "id",
+									"value": "2"
+								}
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		}
+	]
+}
\ No newline at end of file

From 39c546794c4b23b017943f973b7a557031a5a711 Mon Sep 17 00:00:00 2001
From: Thomas Cardon <thomas.cardon35@gmail.com>
Date: Tue, 25 Jan 2022 11:38:20 +0100
Subject: [PATCH 2/6] url delete-pref

---
 .../simpleat/controller/PreferenceController.java      | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/fr/cardon/simpleat/controller/PreferenceController.java b/src/main/java/fr/cardon/simpleat/controller/PreferenceController.java
index 3dbca6b..b77e8a9 100644
--- a/src/main/java/fr/cardon/simpleat/controller/PreferenceController.java
+++ b/src/main/java/fr/cardon/simpleat/controller/PreferenceController.java
@@ -61,11 +61,11 @@ public class PreferenceController {
 //		return ResponseEntity.status(HttpStatus.OK).body(preferenceRepository.save(personne));
 //	}	
 //	
-//	@DeleteMapping(value = "/delete-restaurant/{id}")
-//	public void suppressionPerso(@PathVariable int id){
-//		
-//		preferenceRepository.deleteById(id);
-//	}
+	@DeleteMapping("/delete-preference/{idrestau}/{iduser}")
+	public void deletePreferenceById(@PathVariable int iduser, @PathVariable int idrestau ){
+		PreferencePK id = new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau));
+		preferenceRepository.deleteById(id);
+	}
 
 
 }

From 4dee7c966ff37c5a5d25e97fae518df62f76c937 Mon Sep 17 00:00:00 2001
From: Thomas Cardon <thomas.cardon35@gmail.com>
Date: Tue, 25 Jan 2022 16:02:30 +0100
Subject: [PATCH 3/6] CRUD pref resto personne=ok

---
 .../fr/cardon/simpleat/model/Personne.java    | 16 +++++++++++
 .../cardon/simpleat/model/PreferencePK.java   |  5 ++--
 .../fr/cardon/simpleat/model/Restaurant.java  | 16 ++++++++++-
 src/main/resources/Postman                    |  8 +++---
 src/main/resources/data.sql                   | 28 +++++++++----------
 5 files changed, 52 insertions(+), 21 deletions(-)

diff --git a/src/main/java/fr/cardon/simpleat/model/Personne.java b/src/main/java/fr/cardon/simpleat/model/Personne.java
index 9b9b7bf..68c58a8 100644
--- a/src/main/java/fr/cardon/simpleat/model/Personne.java
+++ b/src/main/java/fr/cardon/simpleat/model/Personne.java
@@ -4,6 +4,7 @@ package fr.cardon.simpleat.model;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -12,7 +13,9 @@ import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 
 @Entity
@@ -24,6 +27,7 @@ public class Personne {
     private String email;
     private String password;
     private Collection<Role> roles = new ArrayList<Role>();
+    private Collection<Preference> preference = new ArrayList<Preference>();
     
     
 	public Personne() {
@@ -106,5 +110,17 @@ public class Personne {
 	public void setRoles(Collection<Role> roles) {
 		this.roles = roles;
 	}
+	
+
+	@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
+	@JsonIgnore
+	public Collection<Preference> getPreference() {
+		return preference;
+	}
+
+
+	public void setPreference(Collection<Preference> preference) {
+		this.preference = preference;
+	}
 
 }
diff --git a/src/main/java/fr/cardon/simpleat/model/PreferencePK.java b/src/main/java/fr/cardon/simpleat/model/PreferencePK.java
index 8e17df1..ed364ae 100644
--- a/src/main/java/fr/cardon/simpleat/model/PreferencePK.java
+++ b/src/main/java/fr/cardon/simpleat/model/PreferencePK.java
@@ -8,6 +8,7 @@ import javax.persistence.Embeddable;
 import javax.persistence.FetchType;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
 
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 
@@ -37,7 +38,7 @@ public class PreferencePK implements Serializable {
 
 
 	@ManyToOne
-	@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
+	@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
 	@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) 
 	public Personne getPersonne() {
 		return personne;
@@ -50,7 +51,7 @@ public class PreferencePK implements Serializable {
 
 	
 	@ManyToOne // TODO mappedBy preferences dans restaurant
-	@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
+	@PrimaryKeyJoinColumn(name="id_restau",referencedColumnName ="id_restau" )
 	@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) 
 	public Restaurant getRestau() {
 		return restau;
diff --git a/src/main/java/fr/cardon/simpleat/model/Restaurant.java b/src/main/java/fr/cardon/simpleat/model/Restaurant.java
index 9035bd2..a85ca3f 100644
--- a/src/main/java/fr/cardon/simpleat/model/Restaurant.java
+++ b/src/main/java/fr/cardon/simpleat/model/Restaurant.java
@@ -3,6 +3,7 @@ package fr.cardon.simpleat.model;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -11,6 +12,7 @@ import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
 
 import com.fasterxml.jackson.annotation.JsonBackReference;
 import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -32,7 +34,7 @@ public class Restaurant {
     private String longitude;
     private String website;
     private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
-    
+    private Collection<Preference> preference = new ArrayList<Preference>();
     //TODO @OneToMany relier avec une collec de preferences
 
 	public Restaurant() {
@@ -150,5 +152,17 @@ public class Restaurant {
 	public void setTyperestaus(Collection<TypeRestau> typerestaus) {
 		this.typerestaus = typerestaus;
 	}
+	
+
+	@OneToMany(mappedBy = "preferencePK.restau", cascade = CascadeType.REMOVE)
+	@JsonIgnore
+	public Collection<Preference> getPreference() {
+		return preference;
+	}
+
+
+	public void setPreference(Collection<Preference> preference) {
+		this.preference = preference;
+	}
     
 }
diff --git a/src/main/resources/Postman b/src/main/resources/Postman
index 94de556..a222d5a 100644
--- a/src/main/resources/Postman
+++ b/src/main/resources/Postman
@@ -169,15 +169,15 @@
 							}
 						},
 						"url": {
-							"raw": "localhost:8080/preference/5/5",
+							"raw": "localhost:8080/preference/1/3",
 							"host": [
 								"localhost"
 							],
 							"port": "8080",
 							"path": [
 								"preference",
-								"5",
-								"5"
+								"1",
+								"3"
 							]
 						}
 					},
@@ -208,7 +208,7 @@
 						"header": [],
 						"body": {
 							"mode": "raw",
-							"raw": "{\r\n    \"preferencePK\": {\r\n        \"personne\": {\r\n            \"id\": 10\r\n        },\r\n        \"restau\": {\r\n            \"id\": 2\r\n        }\r\n    },\r\n    \"note\": 5,\r\n    \"favori\": true\r\n}",
+							"raw": "{\r\n    \"personne\": {\r\n        \"id\": 1\r\n    },\r\n    \"restau\": {\r\n        \"id\": 5\r\n    },\r\n    \"note\": 5,\r\n    \"favoris\": true\r\n}",
 							"options": {
 								"raw": {
 									"language": "json"
diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql
index 8dd4536..669d7b9 100644
--- a/src/main/resources/data.sql
+++ b/src/main/resources/data.sql
@@ -19,20 +19,20 @@ insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, ac
 insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('Physicians Total Care, Inc.', '462 Mosinee Lane', '8521719889', false, false, 4, true, '-13.5', '48.86667');
 insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('Triweld Industries, Inc.', '2482 Corscot Way', '7513208452', false, true, 2, true, '34.326903', '108.117456');
 
-insert into preference (id_restau, id_personne, note, favori) values (2, 9, 1, false);
-insert into preference (id_restau, id_personne, note, favori) values (3, 1, 5, false);
-insert into preference (id_restau, id_personne, note, favori) values (1, 9, 3, true);
-insert into preference (id_restau, id_personne, note, favori) values (4, 6, 2, false);
-insert into preference (id_restau, id_personne, note, favori) values (5, 5, 5, false);
-insert into preference (id_restau, id_personne, note, favori) values (1, 10, 1, false);
-insert into preference (id_restau, id_personne, note, favori) values (5, 3, 5, false);
-insert into preference (id_restau, id_personne, note, favori) values (1, 7, 1, true);
-insert into preference (id_restau, id_personne, note, favori) values (4, 2, 1, false);
-insert into preference (id_restau, id_personne, note, favori) values (1, 3, 5, false);
-insert into preference (id_restau, id_personne, note, favori) values (3, 10, 4, false);
-insert into preference (id_restau, id_personne, note, favori) values (3, 3, 4, true);
-insert into preference (id_restau, id_personne, note, favori) values (2, 3, 3, false);
-insert into preference (id_restau, id_personne, note, favori) values (2, 8, 3, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 9, 1, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 1, 5, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 9, 3, true);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (4, 6, 2, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 5, 5, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 10, 1, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (5, 3, 5, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 7, 1, true);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (4, 2, 1, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (1, 3, 5, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 10, 4, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 3, 4, true);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 3, 3, false);
+insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 8, 3, false);
 
 insert into type (id_type, libelle) values (1, 'Kebab');
 insert into type (id_type, libelle) values (2, 'Supermarché');

From 8f0cbdb7581f5e00a2d7f33a9bf4d774212015cd Mon Sep 17 00:00:00 2001
From: Thomas <37211499+thomascardon35@users.noreply.github.com>
Date: Tue, 25 Jan 2022 16:25:55 +0100
Subject: [PATCH 4/6] Update .gitignore

exclusion de application.properties
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index c2065bc..1acaf36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,5 @@ out/
 
 ### VS Code ###
 .vscode/
+
+application.properties

From 1f5f94ac6309b5ec46c6208e234f4e36de0c6a13 Mon Sep 17 00:00:00 2001
From: Thomas Cardon <thomas.cardon35@gmail.com>
Date: Mon, 14 Feb 2022 17:30:49 +0100
Subject: [PATCH 5/6] data.sql et bug Boolean null

---
 .../fr/cardon/simpleat/model/Restaurant.java  | 28 +++++------
 src/main/resources/data.sql                   | 49 +++++++++++++++++--
 2 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/src/main/java/fr/cardon/simpleat/model/Restaurant.java b/src/main/java/fr/cardon/simpleat/model/Restaurant.java
index a85ca3f..0a50a79 100644
--- a/src/main/java/fr/cardon/simpleat/model/Restaurant.java
+++ b/src/main/java/fr/cardon/simpleat/model/Restaurant.java
@@ -26,10 +26,10 @@ public class Restaurant {
     private String nom;
     private String adresse;
     private String telephone;
-    private boolean aEmporter;
-    private boolean surPlace;
-    private int prix;
-    private boolean accesPMR;
+    private Boolean aEmporter;
+    private Boolean surPlace;
+    private Integer prix;
+    private Boolean accesPMR;
     private String latitude;
     private String longitude;
     private String website;
@@ -42,8 +42,8 @@ public class Restaurant {
 		// TODO Auto-generated constructor stub
 	}
 	
-	public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, int prix,
-			boolean accesPMR, String latitude, String longitude, String website, Collection<TypeRestau> typerestaus) {
+	public Restaurant(String nom, String adresse, String telephone, Boolean aEmporter, Boolean surPlace, int prix,
+			Boolean accesPMR, String latitude, String longitude, String website, Collection<TypeRestau> typerestaus) {
 		super();
 		this.nom = nom;
 		this.adresse = adresse;
@@ -91,31 +91,31 @@ public class Restaurant {
 		this.telephone = telephone;
 	}
 	@Column(nullable = true)
-	public boolean isaEmporter() {
+	public Boolean isaEmporter() {
 		return aEmporter;
 	}
-	public void setaEmporter(boolean aEmporter) {
+	public void setaEmporter(Boolean aEmporter) {
 		this.aEmporter = aEmporter;
 	}
 	@Column(nullable = true)
-	public boolean isSurPlace() {
+	public Boolean isSurPlace() {
 		return surPlace;
 	}
-	public void setSurPlace(boolean surPlace) {
+	public void setSurPlace(Boolean surPlace) {
 		this.surPlace = surPlace;
 	}
 	@Column(nullable = true)
-	public int getPrix() {
+	public Integer getPrix() {
 		return prix;
 	}
-	public void setPrix(int prix) {
+	public void setPrix(Integer prix) {
 		this.prix = prix;
 	}
 	@Column(nullable = true)
-	public boolean isAccesPMR() {
+	public Boolean isAccesPMR() {
 		return accesPMR;
 	}
-	public void setAccesPMR(boolean accesPMR) {
+	public void setAccesPMR(Boolean accesPMR) {
 		this.accesPMR = accesPMR;
 	}
 	@Column(nullable = false)
diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql
index 669d7b9..6c955fa 100644
--- a/src/main/resources/data.sql
+++ b/src/main/resources/data.sql
@@ -13,11 +13,50 @@ insert into personne (nom, prenom, email, password) values ('Crick', 'Andris', '
 insert into role (id_role, intitule) values (1, 'Admin');
 insert into role (id_role, intitule) values (2, 'User');
 
-insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('L Perrigo Company', '301 Thierer Trail', '3092096786', false, true, 1, false, '2.1961772', '22.4708685');
-insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('Sanofi Pasteur Inc.', '9 Barnett Terrace', '6809964349', false, true, 2, false, '31.45571', '34.43719');
-insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('REMEDYREPACK INC.', '3 West Park', '4565542193', true, false, 3, true, '49.817777', '19.785536');
-insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('Physicians Total Care, Inc.', '462 Mosinee Lane', '8521719889', false, false, 4, true, '-13.5', '48.86667');
-insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix, accespmr, latitude, longitude) values ('Triweld Industries, Inc.', '2482 Corscot Way', '7513208452', false, true, 2, true, '34.326903', '108.117456');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,0,1,1,'Le Jardin de Montreuil','1 Rue du Sergent Godefroy, 93100 Montreuil','01 41 63 92 66','http://www.lejardindemontreuil.fr/','48.853391599999995','2.4347358');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,0,'La CaVe','45 Rue de Paris, 93100 Montreuil','01 42 87 09 48','http://www.lacaveestrestaurant.com/','48.8576152','2.4342148999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (3,0,1,1,'Villa 9 Trois','71 Rue Hoche, 93100 Montreuil','01 48 58 17 37','http://www.villa9trois.com/','48.8638352','2.4331966');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'L''Amourette','54 Rue Robespierre, 93100 Montreuil','01 48 59 99 94','http://www.lamourette.fr/','48.853121599999994','2.4234494');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'La Maison Montreuil','31 Rue du Capitaine Dreyfus, 93100 Montreuil','09 87 18 18 81','https://www.lamaisonmontreuil.com/','48.859359700000006','2.4399254999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,1,'le poulet en feu','63 Rue Danton, 93100 Montreuil','09 87 51 10 90','https://www.pouletenfeu.fr/','48.8653553','2.4514297');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,0,1,1,'Les Tonneaux','62 Rue Robespierre, 93100 Montreuil','01 48 58 95 01',NULL,'48.85205','2.4238472');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Les Pianos','26 Rue Robespierre, 93100 Montreuil','09 63 53 85 17','https://www.facebook.com/lespianosmontreuilofficiel/','48.854841799999996','2.4230319');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,0,1,1,'M I M','113 Rue Marceau, 93100 Montreuil','01 43 63 31 13',NULL,'48.849849999999996','2.4265312999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,1,'Le Gévaudan','1 Bd Rouget de Lisle, 93100 Montreuil','01 42 87 42 83',NULL,'48.8617445','2.4412374');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Restaurant Filippo','6 Bd Chanzy, 93100 Montreuil','01 48 18 08 16',NULL,'48.8583964','2.4349743');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,0,1,1,'Le Mange Disc','50 Rue de Romainville, 93100 Montreuil','09 83 54 60 27','https://m.facebook.com/Le-Mange-Disc-102557926519195/?locale2=fr_FR','48.8658457','2.4466363');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,NULL,'Restaurant El Kahina','227 Rue de Paris, 93100 Montreuil','01 48 70 95 46',NULL,'48.8550124','2.4195686');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (NULL,1,1,1,'La Baraka','262 Rue de Paris, 93100 Montreuil','01 42 87 19 27','http://www.labarakamontreuil.fr/?lang=fr','48.8549268','2.4177603999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'La Bottega Della Pizza','34 Bd Rouget de Lisle, 93100 Montreuil','01 43 63 04 35','http://www.labottegadellapizza.fr/','48.860204200000005','2.4387626');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,0,1,NULL,'Restaurant de la Paix','11 Rue Armand Carrel, 93100 Montreuil','01 73 55 21 72',NULL,'48.853764','2.4177003999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'La Fontaine Bar Restaurant','47 Rue Armand Carrel, 93100 Montreuil','01 48 70 08 84','https://www.facebook.com/pages/la-fontaine-de-montreuil-Restaurant/213852528659590?fref=ts','48.8512132','2.4183881');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (3,1,1,NULL,'La Cantine Arkose Montreuil','33 Rue du Progrès, 93100 Montreuil','01 49 88 45 07','https://lacantine.arkose.com/montreuil/','48.8516335','2.419278');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (3,1,1,NULL,'Kashmir Café.','14 Rue du Capitaine Dreyfus, 93100 Montreuil','01 43 63 33 86','http://www.kashmircafe.fr/','48.8582843','2.4378471999999998');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'W Lounge','37 Rue de Valmy, 93100 Montreuil','01 48 37 61 17','http://wlounge-montreuil.com/?utm_source=gmb&utm_medium=referral','48.8507208','2.4187186');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,1,'L''Oasis','171 Rue de Paris, 93100 Montreuil','01 48 70 70 52','https://loasis-montreuil.fr/fr','48.855555599999995','2.4230556');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Obrigado','8 Av. de la Prte de Montreuil, 75020 Paris','09 84 58 24 21','http://obrigado.paris/','48.8534995','2.4118692');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Le Xanthos','30 Rue du Capitaine Dreyfus, 93100 Montreuil','01 55 86 26 77',NULL,'48.858785','2.4388468999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Thé Vert','43 Rue du Capitaine Dreyfus, 93100 Montreuil','01 42 87 79 57','http://www.thevertenligne.fr/','48.8596741','2.4405049');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Gramophone','1 Rue Pépin, 93100 Montreuil','01 49 88 74 56','http://www.restaurantlegramophone.com/','48.8641275','2.4449753');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,0,1,NULL,'La Grosse Mignonne','56 Rue Carnot, 93100 Montreuil','01 42 87 54 51','https://www.facebook.com/LaGrosseMignonne','48.855322','2.4413144');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,NULL,'La Galetiere','126 Rue de Paris, 93100 Montreuil','01 42 87 47 32','http://lagaletiere.eatbu.com/','48.8563999','2.4263293');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (3,1,1,1,'Le Mamaju','36 Rue de Lagny, 93100 Montreuil','01 83 74 02 26','https://mamaju-restaurant-montreuil.eatbu.com/','48.8490247','2.4265491');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,NULL,'Le Pizzo','15 Rue du Capitaine Dreyfus, 93100 Montreuil','09 88 46 71 29',NULL,'48.8588721','2.4385882999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,NULL,'L''Olivier','211 Rue de Paris, 93100 Montreuil','06 47 82 43 41',NULL,'48.855081','2.4203481');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Louise','27 Rue du Capitaine Dreyfus, 93100 Montreuil','06 75 32 56 81','https://instagram.com/cafelouisemontreuil?utm_medium=copy_link','48.859237','2.4394462');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,1,'Ô Bar Lié','16 Rue de la République, 93100 Montreuil','01 48 58 71 95','http://www.obarlie.com/','48.8531155','2.4209562');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,NULL,'Gabycook','27 Rue du Progrès, 93100 Montreuil',NULL,NULL,'48.851772999999994','2.4202114');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'L''ALEMBERT','268 Rue de Paris, 93100 Montreuil','01 42 87 29 61','http://www.lalembert.fr/','48.8549126','2.4174881999999998');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,NULL,'Gujarat','35 Bd Paul Vaillant Couturier, 93100 Montreuil','01 48 58 77 16','http://restaurantgujarat.fr/','48.865111','2.443053');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,NULL,'L''effiloché Montreuil','5 Rue du Centenaire, 93100 Montreuil',NULL,NULL,'48.8579636','2.4270348');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,NULL,'Famille-CMC','6 Av. Pasteur, 93100 Montreuil',NULL,NULL,'48.862999300000006','2.441328');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,NULL,'O''Villagio','28 Rue du Capitaine Dreyfus, 93100 Montreuil','01 57 42 63 82','https://ovillaggio93.wixsite.com/o-villaggio','48.858722','2.4386695');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'La Brasserie des Laitières','38 Rue de Lagny, 93100 Montreuil','01 48 51 50 70','https://le-bl.metro.biz/','48.8490399','2.4262376999999997');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (1,1,1,1,'LE HAVANE','248 Rue de Paris, 93100 Montreuil','01 48 57 17 23',NULL,'48.855091599999994','2.4187965');
+INSERT INTO restaurant(prix,a_emporter,sur_place,accespmr,nom,adresse,telephone,website,latitude,longitude) VALUES (2,1,1,1,'Chez Carla','6 Rue Claude Bernard, 93100 Montreuil','01 48 18 00 53','http://www.chezcarla.fr/','48.8699343','2.4507599');
+
+
+
 
 insert into preference (restau_id_restau, personne_id_personne, note, favori) values (2, 9, 1, false);
 insert into preference (restau_id_restau, personne_id_personne, note, favori) values (3, 1, 5, false);

From 73a352973ee0f555a7b15ef6fc232acf207751e1 Mon Sep 17 00:00:00 2001
From: Thomas Cardon <thomas.cardon35@gmail.com>
Date: Mon, 14 Feb 2022 23:28:20 +0100
Subject: [PATCH 6/6] acces aux types par restau

---
 src/main/java/fr/cardon/simpleat/model/Restaurant.java | 1 -
 src/main/java/fr/cardon/simpleat/model/TypeRestau.java | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/fr/cardon/simpleat/model/Restaurant.java b/src/main/java/fr/cardon/simpleat/model/Restaurant.java
index 0a50a79..7f94abe 100644
--- a/src/main/java/fr/cardon/simpleat/model/Restaurant.java
+++ b/src/main/java/fr/cardon/simpleat/model/Restaurant.java
@@ -144,7 +144,6 @@ public class Restaurant {
 	@JoinTable(name="type_restau",
 	joinColumns = @JoinColumn(name = "id_restau"/*classe en cours*/,referencedColumnName = "id_restau" /*classe reliée*/) ,
 	inverseJoinColumns =  @JoinColumn(name = "id_type",referencedColumnName = "id_type"))
-	@JsonBackReference("typerestaus")
 	public Collection<TypeRestau> getTyperestaus() {
 		return typerestaus;
 	}
diff --git a/src/main/java/fr/cardon/simpleat/model/TypeRestau.java b/src/main/java/fr/cardon/simpleat/model/TypeRestau.java
index 01f6d51..0d85160 100644
--- a/src/main/java/fr/cardon/simpleat/model/TypeRestau.java
+++ b/src/main/java/fr/cardon/simpleat/model/TypeRestau.java
@@ -10,6 +10,7 @@ import javax.persistence.Id;
 import javax.persistence.ManyToMany;
 import javax.persistence.Table;
 
+import com.fasterxml.jackson.annotation.JsonBackReference;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 
 
@@ -49,7 +50,7 @@ public class TypeRestau {
 	}
 
 	@ManyToMany(mappedBy="typerestaus")
-	@JsonIgnoreProperties("typerestaus")
+	@JsonBackReference("restaurants")
 	public List<Restaurant> getRestaurants() {
 		return restaurants;
 	}