From 36b96e8170cf61d9826c62c479db5e384b2d0633 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Wed, 19 Jan 2022 15:49:07 +0100 Subject: [PATCH 1/5] first commit dev --- src/main/java/fr/cardon/simpleat/model/Restaurant.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/cardon/simpleat/model/Restaurant.java b/src/main/java/fr/cardon/simpleat/model/Restaurant.java index 65e3ceb..54a6066 100644 --- a/src/main/java/fr/cardon/simpleat/model/Restaurant.java +++ b/src/main/java/fr/cardon/simpleat/model/Restaurant.java @@ -38,7 +38,6 @@ public class Restaurant { super(); // TODO Auto-generated constructor stub } - public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, double prix, boolean accesPMR, String latitude, String longitude, String website, Collection typerestaus) { From 1d6ee8fe64efcc0777a8daaab8406784157fa923 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Wed, 19 Jan 2022 16:00:37 +0100 Subject: [PATCH 2/5] MAJ gitignore --- .gitignore | 4 ++++ src/main/resources/application.properties | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index c2065bc..ae613fd 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,7 @@ out/ ### VS Code ### .vscode/ + + +### Empêcher ses fichiers d'être mis à jour +application.properties \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 180efdc..3e5ddc8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -20,3 +20,5 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDial # Permet d'exécuter le data.sql # =============================== ##spring.sql.init.mode=always + +## coucou \ No newline at end of file From 3bedab20e8105030ba15547a81a10b0a5b4b8bf9 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Wed, 19 Jan 2022 16:18:09 +0100 Subject: [PATCH 3/5] Revert "MAJ gitignore" This reverts commit 1d6ee8fe64efcc0777a8daaab8406784157fa923. --- .gitignore | 4 ---- src/main/resources/application.properties | 2 -- 2 files changed, 6 deletions(-) diff --git a/.gitignore b/.gitignore index ae613fd..c2065bc 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,3 @@ out/ ### VS Code ### .vscode/ - - -### Empêcher ses fichiers d'être mis à jour -application.properties \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3e5ddc8..180efdc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -20,5 +20,3 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDial # Permet d'exécuter le data.sql # =============================== ##spring.sql.init.mode=always - -## coucou \ No newline at end of file From 228e013a75a558b715c585584c990c7ae7e96f5a Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Thu, 20 Jan 2022 16:16:16 +0100 Subject: [PATCH 4/5] controller restauParType --- .../simpleat/controller/TypeRestauController.java | 7 +++++++ .../java/fr/cardon/simpleat/model/Restaurant.java | 15 ++++++++------- src/main/resources/application.properties | 7 ++++--- src/main/resources/data.sql | 10 +++++----- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/main/java/fr/cardon/simpleat/controller/TypeRestauController.java b/src/main/java/fr/cardon/simpleat/controller/TypeRestauController.java index cf2a3ce..4aa388e 100644 --- a/src/main/java/fr/cardon/simpleat/controller/TypeRestauController.java +++ b/src/main/java/fr/cardon/simpleat/controller/TypeRestauController.java @@ -2,6 +2,7 @@ package fr.cardon.simpleat.controller; import java.util.Collection; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import fr.cardon.simpleat.model.Restaurant; import fr.cardon.simpleat.model.TypeRestau; import fr.cardon.simpleat.repository.TypeRestauRepository; @@ -36,6 +38,11 @@ public class TypeRestauController { return typeRestauRepository.findById(id); } + @GetMapping("/restaurantbytype/{id}") + public List findRestauByType(@PathVariable int id){ + return findTypetById(id).getRestaurants(); + } + @PostMapping("/add-type") public ResponseEntity ajoutType(@RequestBody TypeRestau type){ return ResponseEntity.status(HttpStatus.OK).body(typeRestauRepository.save(type)); diff --git a/src/main/java/fr/cardon/simpleat/model/Restaurant.java b/src/main/java/fr/cardon/simpleat/model/Restaurant.java index 65e3ceb..2f19041 100644 --- a/src/main/java/fr/cardon/simpleat/model/Restaurant.java +++ b/src/main/java/fr/cardon/simpleat/model/Restaurant.java @@ -3,7 +3,6 @@ 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; @@ -13,6 +12,8 @@ import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -25,7 +26,7 @@ public class Restaurant { private String telephone; private boolean aEmporter; private boolean surPlace; - private double prix; + private int prix; private boolean accesPMR; private String latitude; private String longitude; @@ -40,7 +41,7 @@ public class Restaurant { } - public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, double prix, + public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, int prix, boolean accesPMR, String latitude, String longitude, String website, Collection typerestaus) { super(); this.nom = nom; @@ -103,11 +104,11 @@ public class Restaurant { this.surPlace = surPlace; } @Column(nullable = true) - public double getPrix() { + public int getPrix() { return prix; } - public void setPrix(double prixMin) { - this.prix = prixMin; + public void setPrix(int prix) { + this.prix = prix; } @Column(nullable = true) public boolean isAccesPMR() { @@ -142,7 +143,7 @@ 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")) - @JsonIgnoreProperties("typerestaus") + @JsonBackReference("typerestaus") public Collection getTyperestaus() { return typerestaus; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 180efdc..875e116 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -13,10 +13,11 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # JPA / HIBERNATE # =============================== spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=update -##spring.jpa.hibernate.ddl-auto=create-drop +##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.sql.init.mode=always +spring.sql.init.mode=always +spring.jpa.defer-datasource-initialization=true \ No newline at end of file diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index b075246..8dd4536 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -13,11 +13,11 @@ 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_min, prix_max, accespmr, latitude, longitude) values ('L Perrigo Company', '301 Thierer Trail', '3092096786', false, true, 10, 16, false, '2.1961772', '22.4708685'); -insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('Sanofi Pasteur Inc.', '9 Barnett Terrace', '6809964349', false, true, 1, 17, false, '31.45571', '34.43719'); -insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('REMEDYREPACK INC.', '3 West Park', '4565542193', true, false, 2, 20, true, '49.817777', '19.785536'); -insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('Physicians Total Care, Inc.', '462 Mosinee Lane', '8521719889', false, false, 1, 22, true, '-13.5', '48.86667'); -insert into restaurant (nom, adresse, telephone, a_emporter, sur_place, prix_min, prix_max, accespmr, latitude, longitude) values ('Triweld Industries, Inc.', '2482 Corscot Way', '7513208452', false, true, 5, 13, true, '34.326903', '108.117456'); +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 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); From d06c06b5959ccd612d8d87f05efad5bb28d633f0 Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Thu, 20 Jan 2022 16:35:56 +0100 Subject: [PATCH 5/5] ajout fichier tx Postman --- src/main/resources/Postman | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/resources/Postman diff --git a/src/main/resources/Postman b/src/main/resources/Postman new file mode 100644 index 0000000..0203063 --- /dev/null +++ b/src/main/resources/Postman @@ -0,0 +1,6 @@ +Nouvelle Requête POSTMAN: + +20/01/2022 + GET localhost:8080/restaurantbytype/1 + +