Adding email field

This commit is contained in:
mizanur-rahman-m4 2023-07-18 12:27:58 +06:00
parent a30b0bd143
commit d74b9245e2
5 changed files with 28 additions and 1 deletions

View file

@ -58,6 +58,11 @@ public class Owner extends Person {
@NotEmpty
@Digits(fraction = 0, integer = 10)
private String telephone;
@Column(name = "email")
@NotEmpty
private String email;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "owner_id")
@ -87,6 +92,17 @@ public class Owner extends Person {
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public List<Pet> getPets() {
return this.pets;

View file

@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS owners (
last_name TEXT,
address TEXT,
city TEXT,
telephone TEXT
telephone TEXT,
Email TEXT
);
CREATE INDEX ON owners (last_name);

View file

@ -16,6 +16,9 @@
th:replace="~{fragments/inputField :: input ('City', 'city', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Telephone', 'telephone', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Email', 'email', 'text')}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">

View file

@ -26,6 +26,11 @@
<th>Telephone</th>
<td th:text="*{telephone}"></td>
</tr>
<tr>
<th>Email</th>
<td th:text="*{email}"></td>
</tr>
</table>
<a th:href="@{__${owner.id}__/edit}" class="btn btn-primary">Edit

View file

@ -13,6 +13,7 @@
<th style="width: 200px;">Address</th>
<th>City</th>
<th style="width: 120px">Telephone</th>
<th style="width: 200px">Email</th>
<th>Pets</th>
</tr>
</thead>
@ -24,6 +25,7 @@
<td th:text="${owner.address}"/>
<td th:text="${owner.city}"/>
<td th:text="${owner.telephone}"/>
<td th:text="${owner.email}"/>
<td><span th:text="${#strings.listJoin(owner.pets, ', ')}"/></td>
</tr>
</tbody>