Lombok et buider sur les derniers models
This commit is contained in:
parent
447d2d07a7
commit
2cfd096660
2 changed files with 71 additions and 196 deletions
|
@ -1,164 +1,69 @@
|
||||||
package fr.vincent.ramiere.mangerautourdesimplonback.models;
|
package fr.vincent.ramiere.mangerautourdesimplonback.models;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.GeneratedValue;
|
|
||||||
import jakarta.persistence.GenerationType;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.persistence.JoinColumn;
|
|
||||||
import jakarta.persistence.JoinTable;
|
|
||||||
import jakarta.persistence.ManyToMany;
|
|
||||||
import jakarta.persistence.OneToMany;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name = "restaurant")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
public class Restaurant implements Serializable {
|
public class Restaurant implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String nom;
|
|
||||||
private String adresse;
|
|
||||||
private String telephone;
|
|
||||||
private Boolean aEmporter;
|
|
||||||
private Boolean surPlace;
|
|
||||||
private Integer prix;
|
|
||||||
private Boolean accesPMR;
|
|
||||||
private String latitude;
|
|
||||||
private String longitude;
|
|
||||||
private String website;
|
|
||||||
private Collection<TypeRestau> typerestaus = new ArrayList<>();
|
|
||||||
private Collection<Preference> preference = new ArrayList<>();
|
|
||||||
|
|
||||||
public Restaurant() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
this.telephone = telephone;
|
|
||||||
this.aEmporter = aEmporter;
|
|
||||||
this.surPlace = surPlace;
|
|
||||||
this.prix = prix;
|
|
||||||
this.accesPMR = accesPMR;
|
|
||||||
this.latitude = latitude;
|
|
||||||
this.longitude = longitude;
|
|
||||||
this.website = website;
|
|
||||||
this.typerestaus = typerestaus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_restau")
|
@Column(name = "id_restau")
|
||||||
public int getId() {
|
private int id;
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String getNom() {
|
private String nom;
|
||||||
return nom;
|
|
||||||
}
|
@Column(nullable = false)
|
||||||
public void setNom(String nom) {
|
private String adresse;
|
||||||
this.nom = nom;
|
|
||||||
}
|
@Column
|
||||||
@Column(nullable = false)
|
private String telephone;
|
||||||
public String getAdresse() {
|
|
||||||
return adresse;
|
@Column(name = "a_emporter")
|
||||||
}
|
private Boolean aEmporter;
|
||||||
public void setAdresse(String adresse) {
|
|
||||||
this.adresse = adresse;
|
@Column(name = "sur_place")
|
||||||
}
|
private Boolean surPlace;
|
||||||
@Column(nullable = true)
|
|
||||||
public String getTelephone() {
|
@Column
|
||||||
return telephone;
|
private Integer prix;
|
||||||
}
|
|
||||||
public void setTelephone(String telephone) {
|
@Column(name = "accespmr")
|
||||||
this.telephone = telephone;
|
private Boolean accesPMR;
|
||||||
}
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = false)
|
||||||
public Boolean isaEmporter() {
|
private String latitude;
|
||||||
return aEmporter;
|
|
||||||
}
|
@Column(nullable = false)
|
||||||
public void setaEmporter(Boolean aEmporter) {
|
private String longitude;
|
||||||
this.aEmporter = aEmporter;
|
|
||||||
}
|
@Column
|
||||||
@Column(nullable = true)
|
private String website;
|
||||||
public Boolean isSurPlace() {
|
|
||||||
return surPlace;
|
|
||||||
}
|
|
||||||
public void setSurPlace(Boolean surPlace) {
|
|
||||||
this.surPlace = surPlace;
|
|
||||||
}
|
|
||||||
@Column(nullable = true)
|
|
||||||
public Integer getPrix() {
|
|
||||||
return prix;
|
|
||||||
}
|
|
||||||
public void setPrix(Integer prix) {
|
|
||||||
this.prix = prix;
|
|
||||||
}
|
|
||||||
@Column(nullable = true)
|
|
||||||
public Boolean isAccesPMR() {
|
|
||||||
return accesPMR;
|
|
||||||
}
|
|
||||||
public void setAccesPMR(Boolean accesPMR) {
|
|
||||||
this.accesPMR = accesPMR;
|
|
||||||
}
|
|
||||||
@Column(nullable = false)
|
|
||||||
public String getLatitude() {
|
|
||||||
return latitude;
|
|
||||||
}
|
|
||||||
public void setLatitude(String latitude) {
|
|
||||||
this.latitude = latitude;
|
|
||||||
}
|
|
||||||
@Column(nullable = false)
|
|
||||||
public String getLongitude() {
|
|
||||||
return longitude;
|
|
||||||
}
|
|
||||||
public void setLongitude(String longitude) {
|
|
||||||
this.longitude = longitude;
|
|
||||||
}
|
|
||||||
@Column(nullable = true)
|
|
||||||
public String getWebsite() {
|
|
||||||
return website;
|
|
||||||
}
|
|
||||||
public void setWebsite(String website) {
|
|
||||||
this.website = website;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(name="type_restau",
|
@JoinTable(
|
||||||
joinColumns = @JoinColumn(name = "id_restau"/*classe en cours*/,referencedColumnName = "id_restau" /*classe reliée*/) ,
|
name = "type_restau",
|
||||||
inverseJoinColumns = @JoinColumn(name = "id_type",referencedColumnName = "id_type"))
|
joinColumns = @JoinColumn(name = "id_restau", referencedColumnName = "id_restau"),
|
||||||
public Collection<TypeRestau> getTyperestaus() {
|
inverseJoinColumns = @JoinColumn(name = "id_type", referencedColumnName = "id_type")
|
||||||
return typerestaus;
|
)
|
||||||
}
|
@Builder.Default
|
||||||
public void setTyperestaus(Collection<TypeRestau> typerestaus) {
|
private Collection<TypeRestau> typerestaus = new ArrayList<>();
|
||||||
this.typerestaus = typerestaus;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "preferencePK.restau", cascade = CascadeType.REMOVE)
|
@OneToMany(mappedBy = "preferencePK.restau", cascade = CascadeType.REMOVE)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public Collection<Preference> getPreference() {
|
@Builder.Default
|
||||||
return preference;
|
private Collection<Preference> preference = new ArrayList<>();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setPreference(Collection<Preference> preference) {
|
|
||||||
this.preference = preference;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +1,33 @@
|
||||||
package fr.vincent.ramiere.mangerautourdesimplonback.models;
|
package fr.vincent.ramiere.mangerautourdesimplonback.models;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.GeneratedValue;
|
|
||||||
import jakarta.persistence.GenerationType;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import jakarta.persistence.ManyToMany;
|
|
||||||
import jakarta.persistence.Table;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="type")
|
@Table(name = "type")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
public class TypeRestau implements Serializable {
|
public class TypeRestau implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String libelle;
|
|
||||||
private List<Restaurant> restaurants;
|
|
||||||
|
|
||||||
public TypeRestau() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TypeRestau(int id, String libelle) {
|
|
||||||
super();
|
|
||||||
this.id = id;
|
|
||||||
this.libelle = libelle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id_type")
|
@Column(name = "id_type")
|
||||||
public int getId() {
|
private int id;
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public String getLibelle() {
|
private String libelle;
|
||||||
return libelle;
|
|
||||||
}
|
|
||||||
public void setLibelle(String libelle) {
|
|
||||||
this.libelle = libelle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ManyToMany(mappedBy="typerestaus")
|
|
||||||
@JsonBackReference("restaurants")
|
|
||||||
public List<Restaurant> getRestaurants() {
|
|
||||||
return restaurants;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRestaurants(List<Restaurant> restaurants) {
|
|
||||||
this.restaurants = restaurants;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ManyToMany(mappedBy = "typerestaus")
|
||||||
|
@JsonBackReference("restaurants")
|
||||||
|
@Builder.Default
|
||||||
|
private List<Restaurant> restaurants = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue