fin du merge dev->thomas sans bug

This commit is contained in:
Thomas Cardon 2022-02-15 00:05:55 +01:00
parent 6ae5799eac
commit c3ef5f63b3
5 changed files with 17 additions and 81 deletions

View File

@ -36,12 +36,6 @@ public class Personne {
} }
public Personne(int id) {
super();
this.id = id;
}
public Personne(String nom, String prenom, String email, String password) { public Personne(String nom, String prenom, String email, String password) {
super(); super();
this.nom = nom; this.nom = nom;
@ -129,7 +123,4 @@ public class Personne {
this.preference = preference; this.preference = preference;
} }
} }

View File

@ -1,20 +1,13 @@
package fr.cardon.simpleat.model; package fr.cardon.simpleat.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity @Entity
@IdClass(PreferencePK.class)
public class Preference { public class Preference {
private Personne personne; private PreferencePK preferencePK;
private Restaurant restau;
private int note; private int note;
private boolean favoris; private boolean favoris;
@ -26,79 +19,36 @@ public class Preference {
} }
public Preference(PreferencePK preferencePK, int note, boolean favoris) {
public Preference(Personne personne, Restaurant restau) {
super(); super();
this.personne = personne; this.preferencePK = preferencePK;
this.restau = restau;
}
public Preference(Personne personne, Restaurant restau, int note, boolean favoris) {
super();
this.personne = personne;
this.restau = restau;
this.note = note; this.note = note;
this.favoris = favoris; this.favoris = favoris;
} }
@EmbeddedId
@Id public PreferencePK getPreferencePK() {
@ManyToOne return preferencePK;
@JoinColumn(name="id_personne" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public Personne getPersonne() {
return personne;
} }
public void setPreferencePK(PreferencePK preferencePK) {
this.preferencePK = preferencePK;
public void setPersonne(Personne personne) {
this.personne = personne;
} }
@Id
@ManyToOne
@JoinColumn(name="id_restau" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public Restaurant getRestau() {
return restau;
}
public void setRestau(Restaurant restau) {
this.restau = restau;
}
@Column(nullable = true) @Column(nullable = true)
public int getNote() { public int getNote() {
return note; return note;
} }
public void setNote(int note) { public void setNote(int note) {
this.note = note; this.note = note;
} }
@Column(nullable = true) @Column(nullable = true)
public boolean isFavoris() { public boolean isFavori() {
return favoris; return favoris;
} }
public void setFavori(boolean favoris) {
public void setFavoris(boolean favoris) {
this.favoris = favoris; this.favoris = favoris;
} }
} }

View File

@ -3,6 +3,7 @@ package fr.cardon.simpleat.model;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
@ -12,7 +13,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Embeddable
public class PreferencePK implements Serializable { public class PreferencePK implements Serializable {
/** /**
@ -48,6 +49,7 @@ public class PreferencePK implements Serializable {
this.personne = personne; this.personne = personne;
} }
@ManyToOne // TODO mappedBy preferences dans restaurant @ManyToOne // TODO mappedBy preferences dans restaurant
@PrimaryKeyJoinColumn(name="id_restau",referencedColumnName ="id_restau" ) @PrimaryKeyJoinColumn(name="id_restau",referencedColumnName ="id_restau" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})

View File

@ -169,19 +169,15 @@
} }
}, },
"url": { "url": {
"raw": "localhost:8080/preference/1/3", "raw": "localhost:8080/preference/1/3",
"host": [ "host": [
"localhost" "localhost"
], ],
"port": "8080", "port": "8080",
"path": [ "path": [
"preference", "preference",
"1", "1",
"3" "3"
] ]
} }
}, },
@ -212,9 +208,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"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}", "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"

View File

@ -73,7 +73,6 @@ insert into preference (restau_id_restau, personne_id_personne, note, favori) va
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, 3, 3, false);
insert into preference (restau_id_restau, personne_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é');
insert into type (id_type, libelle) values (3, 'Boulangerie'); insert into type (id_type, libelle) values (3, 'Boulangerie');