mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 06:45:49 +00:00
[feat] Append age field
기선님 과제 3
This commit is contained in:
parent
52e1a9f18c
commit
0d997824ec
6 changed files with 30 additions and 13 deletions
|
@ -26,6 +26,7 @@ import javax.persistence.Column;
|
|||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
|
@ -46,6 +47,9 @@ import org.springframework.samples.petclinic.model.Person;
|
|||
@Table(name = "owners")
|
||||
public class Owner extends Person {
|
||||
|
||||
@Column(name = "age")
|
||||
private Integer age;
|
||||
|
||||
@Column(name = "address")
|
||||
@NotEmpty
|
||||
private String address;
|
||||
|
@ -62,9 +66,13 @@ public class Owner extends Person {
|
|||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
|
||||
private Set<Pet> pets;
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
public Integer getAge() { return this.age; }
|
||||
|
||||
public void setAge(Integer age) { this.age = age; }
|
||||
|
||||
public String getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
|
|
|
@ -22,16 +22,16 @@ INSERT INTO types VALUES (4, 'snake');
|
|||
INSERT INTO types VALUES (5, 'bird');
|
||||
INSERT INTO types VALUES (6, 'hamster');
|
||||
|
||||
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
INSERT INTO owners VALUES (1, 'George', 'Franklin', 25, '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT INTO owners VALUES (2, 'Betty', 'Davis', 25, '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', 25, '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT INTO owners VALUES (4, 'Harold', 'Davis', 25, '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', 25, '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', 25, '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT INTO owners VALUES (7, 'Jeff', 'Black', 25, '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', 25, '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', 25, '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', 25, '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
|
||||
INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1);
|
||||
INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2);
|
||||
|
|
|
@ -37,6 +37,7 @@ CREATE TABLE owners (
|
|||
id INTEGER IDENTITY PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR_IGNORECASE(30),
|
||||
age INTEGER,
|
||||
address VARCHAR(255),
|
||||
city VARCHAR(80),
|
||||
telephone VARCHAR(20)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
th:replace="~{fragments/inputField :: input ('First Name', 'firstName', 'text')}" />
|
||||
<input
|
||||
th:replace="~{fragments/inputField :: input ('Last Name', 'lastName', 'text')}" />
|
||||
<input
|
||||
th:replace="~{fragments/inputField :: input ('Age', 'age', 'text')}" />
|
||||
<input
|
||||
th:replace="~{fragments/inputField :: input ('Address', 'address', 'text')}" />
|
||||
<input
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
<th>Name</th>
|
||||
<td><b th:text="*{firstName + ' ' + lastName}"></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Age</th>
|
||||
<td th:text="*{age}" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Address</th>
|
||||
<td th:text="*{address}" /></td>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<tr>
|
||||
<th style="width: 150px;">Name</th>
|
||||
<th style="width: 200px;">Address</th>
|
||||
<th>Age</th>
|
||||
<th>City</th>
|
||||
<th style="width: 120px">Telephone</th>
|
||||
<th>Pets</th>
|
||||
|
@ -21,6 +22,7 @@
|
|||
<td>
|
||||
<a th:href="@{/owners/__${owner.id}__}" th:text="${owner.firstName + ' ' + owner.lastName}"/></a>
|
||||
</td>
|
||||
<td th:text="${owner.age}"/>
|
||||
<td th:text="${owner.address}"/>
|
||||
<td th:text="${owner.city}"/>
|
||||
<td th:text="${owner.telephone}"/>
|
||||
|
|
Loading…
Reference in a new issue