forked from Celebes/spring-boot-pet-clinic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
78 additions
and
156 deletions.
There are no files selected for viewing
15 changes: 8 additions & 7 deletions
15
pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/BaseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
package guru.springframework.sfgpetclinic.model; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.MappedSuperclass; | ||
import java.io.Serializable; | ||
|
||
@MappedSuperclass | ||
@EqualsAndHashCode | ||
@Getter | ||
@Setter | ||
public abstract class BaseEntity implements Serializable { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
} |
44 changes: 9 additions & 35 deletions
44
pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/Owner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,32 @@ | ||
package guru.springframework.sfgpetclinic.model; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.CascadeType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.OneToMany; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
public class Owner extends Person { | ||
|
||
private String address; | ||
|
||
private String city; | ||
|
||
private String telephone; | ||
|
||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") | ||
private Set<Pet> pets = new HashSet<>(); | ||
|
||
public Owner() { | ||
} | ||
|
||
public Owner(String firstName, String lastName, String address, String city, String telephone) { | ||
super(firstName, lastName); | ||
this.address = address; | ||
this.city = city; | ||
this.telephone = telephone; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
|
||
public String getCity() { | ||
return city; | ||
} | ||
|
||
public void setCity(String city) { | ||
this.city = city; | ||
} | ||
|
||
public String getTelephone() { | ||
return telephone; | ||
} | ||
|
||
public void setTelephone(String telephone) { | ||
this.telephone = telephone; | ||
} | ||
|
||
public Set<Pet> getPets() { | ||
return pets; | ||
} | ||
|
||
public void setPets(Set<Pet> pets) { | ||
this.pets = pets; | ||
} | ||
} |
26 changes: 8 additions & 18 deletions
26
pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/Person.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
package guru.springframework.sfgpetclinic.model; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.MappedSuperclass; | ||
|
||
@MappedSuperclass | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public abstract class Person extends BaseEntity { | ||
|
||
@Column(name = "first_name") | ||
private String firstName; | ||
|
||
@Column(name = "last_name") | ||
private String lastName; | ||
|
||
protected Person() { | ||
} | ||
|
||
protected Person(String firstName, String lastName) { | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 7 additions & 10 deletions
17
pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/PetType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
package guru.springframework.sfgpetclinic.model; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class PetType extends BaseEntity { | ||
|
||
private String name; | ||
|
||
public PetType() { | ||
} | ||
|
||
public PetType(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
18 changes: 8 additions & 10 deletions
18
pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/Speciality.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
package guru.springframework.sfgpetclinic.model; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Entity; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class Speciality extends BaseEntity { | ||
private String description; | ||
|
||
public Speciality() { | ||
} | ||
private String description; | ||
|
||
public Speciality(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 9 additions & 23 deletions
32
pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/Visit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,26 @@ | ||
package guru.springframework.sfgpetclinic.model; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import java.time.LocalDate; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class Visit extends BaseEntity { | ||
|
||
private LocalDate date; | ||
|
||
private String description; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "pet_id") | ||
private Pet pet; | ||
|
||
public LocalDate getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(LocalDate date) { | ||
this.date = date; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public Pet getPet() { | ||
return pet; | ||
} | ||
|
||
public void setPet(Pet pet) { | ||
this.pet = pet; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...inic-web/src/main/java/guru/springframework/sfgpetclinic/controllers/CrashController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.