mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-23 15:55:49 +00:00
Entidades con error OneToOne en Users y Authorities
This commit is contained in:
parent
aa068be971
commit
8b13d4b2a5
9 changed files with 579 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "authorities")
|
||||||
|
public class Authorities extends BaseEntity {
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "username")
|
||||||
|
User user;
|
||||||
|
|
||||||
|
@Size(min = 3, max = 50)
|
||||||
|
String authority;
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthority() {
|
||||||
|
return authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthority(String authority) {
|
||||||
|
this.authority = authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
94
src/main/java/org/springframework/cheapy/model/Client.java
Normal file
94
src/main/java/org/springframework/cheapy/model/Client.java
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Digits;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "clients")
|
||||||
|
public class Client extends User {
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String timetable;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
@Digits(fraction = 0, integer = 10)
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
|
private String food;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private Set<FoodOffer> foodOffers;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private Set<NuOffer> nuOffers;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private Set<SpeedOffer> speedOffers;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
private Set<TimeOffer> timeOffers;
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimetable() {
|
||||||
|
return timetable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimetable(String timetable) {
|
||||||
|
this.timetable = timetable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTelephone() {
|
||||||
|
return telephone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTelephone(String telephone) {
|
||||||
|
this.telephone = telephone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFood() {
|
||||||
|
return food;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood(String food) {
|
||||||
|
this.food = food;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "food_offers")
|
||||||
|
public class FoodOffer extends Offer {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String food;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String discount;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer units; // revisar
|
||||||
|
|
||||||
|
public String getFood() {
|
||||||
|
return food;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFood(String food) {
|
||||||
|
this.food = food;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscount() {
|
||||||
|
return discount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscount(String discount) {
|
||||||
|
this.discount = discount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUnits() {
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnits(Integer units) {
|
||||||
|
this.units = units;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
96
src/main/java/org/springframework/cheapy/model/NuOffer.java
Normal file
96
src/main/java/org/springframework/cheapy/model/NuOffer.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "nu_offers")
|
||||||
|
public class NuOffer extends Offer {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer gold;
|
||||||
|
|
||||||
|
@Column(name = "discount_gold")
|
||||||
|
@NotBlank
|
||||||
|
private String discountGold;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer silver;
|
||||||
|
|
||||||
|
@Column(name = "discount_silver")
|
||||||
|
@NotBlank
|
||||||
|
private String discountSilver;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer bronze;
|
||||||
|
|
||||||
|
@Column(name = "discount_bronze")
|
||||||
|
@NotBlank
|
||||||
|
private String discountBronze;
|
||||||
|
|
||||||
|
public Integer getGold() {
|
||||||
|
return gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGold(Integer gold) {
|
||||||
|
this.gold = gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscountGold() {
|
||||||
|
return discountGold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountGold(String discountGold) {
|
||||||
|
this.discountGold = discountGold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSilver() {
|
||||||
|
return silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSilver(Integer silver) {
|
||||||
|
this.silver = silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscountSilver() {
|
||||||
|
return discountSilver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountSilver(String discountSilver) {
|
||||||
|
this.discountSilver = discountSilver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBronze() {
|
||||||
|
return bronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBronze(Integer bronze) {
|
||||||
|
this.bronze = bronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscountBronze() {
|
||||||
|
return discountBronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountBronze(String discountBronze) {
|
||||||
|
this.discountBronze = discountBronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
85
src/main/java/org/springframework/cheapy/model/Offer.java
Normal file
85
src/main/java/org/springframework/cheapy/model/Offer.java
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Future;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public class Offer extends BaseEntity {
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||||
|
@NotBlank
|
||||||
|
@Future
|
||||||
|
private LocalDateTime start;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "dd/MM/yyyy HH:mm")
|
||||||
|
@NotBlank
|
||||||
|
@Future
|
||||||
|
private LocalDateTime end;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
private StatusOffer type;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
private Client client;
|
||||||
|
|
||||||
|
public LocalDateTime getStart() {
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStart(LocalDateTime start) {
|
||||||
|
this.start = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEnd() {
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnd(LocalDateTime end) {
|
||||||
|
this.end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusOffer getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(StatusOffer type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "speed_offers")
|
||||||
|
public class SpeedOffer extends Offer {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer gold; // x minutos
|
||||||
|
|
||||||
|
@Column(name = "discount_gold")
|
||||||
|
@NotBlank
|
||||||
|
private String discountGold;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer silver;
|
||||||
|
|
||||||
|
@Column(name = "discount_silver")
|
||||||
|
@NotBlank
|
||||||
|
private String discountSilver;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private Integer bronze;
|
||||||
|
|
||||||
|
@Column(name = "discount_bronze")
|
||||||
|
@NotBlank
|
||||||
|
private String discountBronze;
|
||||||
|
|
||||||
|
public Integer getGold() {
|
||||||
|
return gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGold(Integer gold) {
|
||||||
|
this.gold = gold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscountGold() {
|
||||||
|
return discountGold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountGold(String discountGold) {
|
||||||
|
this.discountGold = discountGold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSilver() {
|
||||||
|
return silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSilver(Integer silver) {
|
||||||
|
this.silver = silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscountSilver() {
|
||||||
|
return discountSilver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountSilver(String discountSilver) {
|
||||||
|
this.discountSilver = discountSilver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBronze() {
|
||||||
|
return bronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBronze(Integer bronze) {
|
||||||
|
this.bronze = bronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscountBronze() {
|
||||||
|
return discountBronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountBronze(String discountBronze) {
|
||||||
|
this.discountBronze = discountBronze;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
public enum StatusOffer {
|
||||||
|
active, inactive, hidden
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "time_offers")
|
||||||
|
public class TimeOffer extends Offer {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String schedule;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String discount;
|
||||||
|
|
||||||
|
public String getSchedule() {
|
||||||
|
return schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchedule(String schedule) {
|
||||||
|
this.schedule = schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDiscount() {
|
||||||
|
return discount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscount(String discount) {
|
||||||
|
this.discount = discount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
src/main/java/org/springframework/cheapy/model/User.java
Normal file
59
src/main/java/org/springframework/cheapy/model/User.java
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
package org.springframework.cheapy.model;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@NotBlank
|
||||||
|
String username;
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
String password;
|
||||||
|
|
||||||
|
@Email
|
||||||
|
@NotBlank
|
||||||
|
String email;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
Authorities authority;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Authorities getAuthority() {
|
||||||
|
return authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthority(Authorities authority) {
|
||||||
|
this.authority = authority;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue