CRUD pref resto personne=ok
This commit is contained in:
parent
39c546794c
commit
4dee7c966f
@ -4,6 +4,7 @@ package fr.cardon.simpleat.model;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
@ -12,7 +13,9 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -24,6 +27,7 @@ public class Personne {
|
|||||||
private String email;
|
private String email;
|
||||||
private String password;
|
private String password;
|
||||||
private Collection<Role> roles = new ArrayList<Role>();
|
private Collection<Role> roles = new ArrayList<Role>();
|
||||||
|
private Collection<Preference> preference = new ArrayList<Preference>();
|
||||||
|
|
||||||
|
|
||||||
public Personne() {
|
public Personne() {
|
||||||
@ -107,4 +111,16 @@ public class Personne {
|
|||||||
this.roles = 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import javax.persistence.Embeddable;
|
|||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.PrimaryKeyJoinColumn;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ public class PreferencePK implements Serializable {
|
|||||||
|
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||||
public Personne getPersonne() {
|
public Personne getPersonne() {
|
||||||
return personne;
|
return personne;
|
||||||
@ -50,7 +51,7 @@ public class PreferencePK implements Serializable {
|
|||||||
|
|
||||||
|
|
||||||
@ManyToOne // TODO mappedBy preferences dans restaurant
|
@ManyToOne // TODO mappedBy preferences dans restaurant
|
||||||
@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
@PrimaryKeyJoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
||||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||||
public Restaurant getRestau() {
|
public Restaurant getRestau() {
|
||||||
return restau;
|
return restau;
|
||||||
|
@ -3,6 +3,7 @@ package fr.cardon.simpleat.model;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
@ -11,6 +12,7 @@ import javax.persistence.Id;
|
|||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
@ -32,7 +34,7 @@ public class Restaurant {
|
|||||||
private String longitude;
|
private String longitude;
|
||||||
private String website;
|
private String website;
|
||||||
private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
|
private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
|
||||||
|
private Collection<Preference> preference = new ArrayList<Preference>();
|
||||||
//TODO @OneToMany relier avec une collec de preferences
|
//TODO @OneToMany relier avec une collec de preferences
|
||||||
|
|
||||||
public Restaurant() {
|
public Restaurant() {
|
||||||
@ -151,4 +153,16 @@ public class Restaurant {
|
|||||||
this.typerestaus = 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,15 +169,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "localhost:8080/preference/5/5",
|
"raw": "localhost:8080/preference/1/3",
|
||||||
"host": [
|
"host": [
|
||||||
"localhost"
|
"localhost"
|
||||||
],
|
],
|
||||||
"port": "8080",
|
"port": "8080",
|
||||||
"path": [
|
"path": [
|
||||||
"preference",
|
"preference",
|
||||||
"5",
|
"1",
|
||||||
"5"
|
"3"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -208,7 +208,7 @@
|
|||||||
"header": [],
|
"header": [],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"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": {
|
"options": {
|
||||||
"raw": {
|
"raw": {
|
||||||
"language": "json"
|
"language": "json"
|
||||||
|
@ -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 ('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 (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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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 (restau_id_restau, personne_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, 8, 3, false);
|
||||||
|
|
||||||
insert into type (id_type, libelle) values (1, 'Kebab');
|
insert into type (id_type, libelle) values (1, 'Kebab');
|
||||||
insert into type (id_type, libelle) values (2, 'Supermarché');
|
insert into type (id_type, libelle) values (2, 'Supermarché');
|
||||||
|
Loading…
Reference in New Issue
Block a user