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;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
@Table(name = "restaurant")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class Restaurant implements Serializable {
|
||||
|
||||
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
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_restau")
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
private int id;
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
private String nom;
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public Boolean isaEmporter() {
|
||||
return aEmporter;
|
||||
}
|
||||
public void setaEmporter(Boolean aEmporter) {
|
||||
this.aEmporter = aEmporter;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
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;
|
||||
}
|
||||
private String adresse;
|
||||
|
||||
@Column
|
||||
private String telephone;
|
||||
|
||||
@Column(name = "a_emporter")
|
||||
private Boolean aEmporter;
|
||||
|
||||
@Column(name = "sur_place")
|
||||
private Boolean surPlace;
|
||||
|
||||
@Column
|
||||
private Integer prix;
|
||||
|
||||
@Column(name = "accespmr")
|
||||
private Boolean accesPMR;
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
public void setLatitude(String latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
private String 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;
|
||||
}
|
||||
private String longitude;
|
||||
|
||||
@Column
|
||||
private String website;
|
||||
|
||||
@ManyToMany
|
||||
@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"))
|
||||
public Collection<TypeRestau> getTyperestaus() {
|
||||
return typerestaus;
|
||||
}
|
||||
public void setTyperestaus(Collection<TypeRestau> typerestaus) {
|
||||
this.typerestaus = typerestaus;
|
||||
}
|
||||
@JoinTable(
|
||||
name = "type_restau",
|
||||
joinColumns = @JoinColumn(name = "id_restau", referencedColumnName = "id_restau"),
|
||||
inverseJoinColumns = @JoinColumn(name = "id_type", referencedColumnName = "id_type")
|
||||
)
|
||||
@Builder.Default
|
||||
private Collection<TypeRestau> typerestaus = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "preferencePK.restau", cascade = CascadeType.REMOVE)
|
||||
@JsonIgnore
|
||||
public Collection<Preference> getPreference() {
|
||||
return preference;
|
||||
}
|
||||
|
||||
|
||||
public void setPreference(Collection<Preference> preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Builder.Default
|
||||
private Collection<Preference> preference = new ArrayList<>();
|
||||
}
|
||||
|
|
|
@ -1,63 +1,33 @@
|
|||
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.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
|
||||
@Table(name = "type")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class TypeRestau implements Serializable {
|
||||
|
||||
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
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_type")
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
private int id;
|
||||
|
||||
@Column(nullable = false)
|
||||
public String getLibelle() {
|
||||
return libelle;
|
||||
}
|
||||
public void setLibelle(String libelle) {
|
||||
this.libelle = libelle;
|
||||
}
|
||||
private String libelle;
|
||||
|
||||
@ManyToMany(mappedBy = "typerestaus")
|
||||
@JsonBackReference("restaurants")
|
||||
public List<Restaurant> getRestaurants() {
|
||||
return restaurants;
|
||||
}
|
||||
|
||||
public void setRestaurants(List<Restaurant> restaurants) {
|
||||
this.restaurants = restaurants;
|
||||
}
|
||||
|
||||
@Builder.Default
|
||||
private List<Restaurant> restaurants = new ArrayList<>();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue