mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 05:25:50 +00:00
Added Doctor Address
Yung Money
This commit is contained in:
parent
e7238582ff
commit
c68507bdc4
4 changed files with 54 additions and 7 deletions
|
@ -21,6 +21,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
|
@ -29,6 +30,7 @@ import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.beans.support.MutableSortDefinition;
|
import org.springframework.beans.support.MutableSortDefinition;
|
||||||
import org.springframework.beans.support.PropertyComparator;
|
import org.springframework.beans.support.PropertyComparator;
|
||||||
import org.springframework.samples.kidclinic.model.Person;
|
import org.springframework.samples.kidclinic.model.Person;
|
||||||
|
@ -49,6 +51,18 @@ public class Doctor extends Person {
|
||||||
@JoinTable(name = "doctor_specialties", joinColumns = @JoinColumn(name = "doctor_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
@JoinTable(name = "doctor_specialties", joinColumns = @JoinColumn(name = "doctor_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id"))
|
||||||
private Set<Specialty> specialties;
|
private Set<Specialty> specialties;
|
||||||
|
|
||||||
|
@Column(name = "address")
|
||||||
|
@NotEmpty
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Column(name = "city")
|
||||||
|
@NotEmpty
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@Column(name = "state")
|
||||||
|
@NotEmpty
|
||||||
|
private String state;
|
||||||
|
|
||||||
protected Set<Specialty> getSpecialtiesInternal() {
|
protected Set<Specialty> getSpecialtiesInternal() {
|
||||||
if (this.specialties == null) {
|
if (this.specialties == null) {
|
||||||
this.specialties = new HashSet<>();
|
this.specialties = new HashSet<>();
|
||||||
|
@ -76,4 +90,28 @@ public class Doctor extends Person {
|
||||||
getSpecialtiesInternal().add(specialty);
|
getSpecialtiesInternal().add(specialty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return this.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return this.city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState(){
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(String state){
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
INSERT INTO doctors VALUES (1, 'James', 'Carter');
|
INSERT INTO doctors VALUES (1, 'James', 'Carter', '3424 University Ave.', 'Madison', 'WI');
|
||||||
INSERT INTO doctors VALUES (2, 'Helen', 'Leary');
|
INSERT INTO doctors VALUES (2, 'Helen', 'Leary', '750 Hilldale Way', 'Madison', 'WI');
|
||||||
INSERT INTO doctors VALUES (3, 'Linda', 'Douglas');
|
INSERT INTO doctors VALUES (3, 'Linda', 'Douglas', '6136 University Ave.', 'Middleton', 'WI');
|
||||||
INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega');
|
INSERT INTO doctors VALUES (4, 'Rafael', 'Ortega', '8300 Airport Rd.', 'Middleton', 'WI');
|
||||||
INSERT INTO doctors VALUES (5, 'Henry', 'Stevens');
|
INSERT INTO doctors VALUES (5, 'Henry', 'Stevens', '876 Jupiter Dr.', 'Madison', 'WI');
|
||||||
INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins');
|
INSERT INTO doctors VALUES (6, 'Sharon', 'Jenkins', '4905 Monona Dr.', 'Monona', 'WI');
|
||||||
|
|
||||||
INSERT INTO specialties VALUES (1, 'radiology');
|
INSERT INTO specialties VALUES (1, 'radiology');
|
||||||
INSERT INTO specialties VALUES (2, 'surgery');
|
INSERT INTO specialties VALUES (2, 'surgery');
|
||||||
|
|
|
@ -10,7 +10,10 @@ DROP TABLE parents IF EXISTS;
|
||||||
CREATE TABLE doctors (
|
CREATE TABLE doctors (
|
||||||
id INTEGER IDENTITY PRIMARY KEY,
|
id INTEGER IDENTITY PRIMARY KEY,
|
||||||
first_name VARCHAR(30),
|
first_name VARCHAR(30),
|
||||||
last_name VARCHAR(30)
|
last_name VARCHAR(30),
|
||||||
|
address VARCHAR(255),
|
||||||
|
city VARCHAR(80),
|
||||||
|
state VARCHAR(80)
|
||||||
);
|
);
|
||||||
CREATE INDEX doctors_last_name ON doctors (last_name);
|
CREATE INDEX doctors_last_name ON doctors (last_name);
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,18 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Address</th>
|
||||||
|
<th>City</th>
|
||||||
|
<th>State</th>
|
||||||
<th>Specialties</th>
|
<th>Specialties</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="doctor : ${doctors.doctorList}">
|
<tr th:each="doctor : ${doctors.doctorList}">
|
||||||
<td th:text="${doctor.firstName + ' ' + doctor.lastName}"></td>
|
<td th:text="${doctor.firstName + ' ' + doctor.lastName}"></td>
|
||||||
|
<td th:text="${doctor.address}"></td>
|
||||||
|
<td th:text="${doctor.city}"></td>
|
||||||
|
<td th:text="${doctor.state}"></td>
|
||||||
<td><span th:each="specialty : ${doctor.specialties}"
|
<td><span th:each="specialty : ${doctor.specialties}"
|
||||||
th:text="${specialty.name + ' '}" /> <span
|
th:text="${specialty.name + ' '}" /> <span
|
||||||
th:if="${doctor.nrOfSpecialties == 0}">none</span></td>
|
th:if="${doctor.nrOfSpecialties == 0}">none</span></td>
|
||||||
|
|
Loading…
Reference in a new issue