Skip to content

Commit ab7a2e4

Browse files
Adds a few properties to Restaurant for the demonstration.
1 parent 020142e commit ab7a2e4

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/main/java/dev/drugowick/jpaqueriesblogpost/domain/model/Restaurant.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class Restaurant {
3030
private Cuisine cuisine;
3131

3232
private String address;
33+
private String city;
34+
private boolean grabAndGo;
35+
private boolean active;
3336

3437
@CreationTimestamp
3538
@Column(nullable = false, columnDefinition = "datetime", updatable = false)

src/main/resources/import.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ insert into cuisine (name) values ('Brazilian');
33
insert into cuisine (name) values ('American');
44
insert into cuisine (name) values ('French');
55

6-
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date) values ('Mamma Mia', 'Mamma Street, 14', 10.0, 1, current_timestamp, current_timestamp);
7-
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date) values ('Churrascaria', 'Disorder Avenue, 5000', 8.0, 2, current_timestamp, current_timestamp);
8-
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date) values ('Burguer Place', 'Clueless Alley, 10', 5.0, 3, current_timestamp, current_timestamp);
9-
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date) values ('La Maison du Croissant ', 'Rue Paris, 7', 15.0, 4, current_timestamp, current_timestamp);
6+
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date, city, grab_and_go, active) values ('Mamma Mia', 'Mamma Street, 14', 10.0, 1, current_timestamp, current_timestamp, 'Venice', false, true);
7+
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date, city, grab_and_go, active) values ('Churrascaria', 'Disorder Avenue, 5000', 8.0, 2, current_timestamp, current_timestamp, 'Sertãozinho', true, true);
8+
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date, city, grab_and_go, active) values ('Burguer Place', 'Clueless Alley, 10', 5.0, 3, current_timestamp, current_timestamp, 'San Francisco', true, false);
9+
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date, city, grab_and_go, active) values ('La Maison du Croissant ', 'Rue Paris, 7', 15.0, 4, current_timestamp, current_timestamp, 'Paris', false, true);
1010

11-
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date) values ('Pasta Buona', 'Pasta Street, 4', 2.0, 1, current_timestamp, current_timestamp);
12-
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date) values ('Marcante Pizzaria', 'Bricks Street, 21', 9.0, 2, current_timestamp, current_timestamp);
11+
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date, city, grab_and_go, active) values ('Pasta Buona', 'Pasta Street, 4', 2.0, 1, current_timestamp, current_timestamp, 'Roma', true, true);
12+
insert into restaurant (name, address, delivery_fee, cuisine_id, created_date, updated_date, city, grab_and_go, active) values ('Marcante Pizzaria', 'Bricks Street, 21', 9.0, 2, current_timestamp, current_timestamp, 'São Paulo', true, false);

src/main/resources/templates/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ <h4>Filter Restaurants</h4>
4646
<th>Address</th>
4747
<th>Delivery Fee</th>
4848
<th>Cuisine</th>
49+
<th>City</th>
50+
<th>Grab'n'Go</th>
51+
<th>Active</th>
4952
</tr>
5053
</thead>
5154
<tr th:each="restaurant : ${restaurants}">
@@ -57,6 +60,9 @@ <h4>Filter Restaurants</h4>
5760
<td th:text="${restaurant.getAddress()}"></td>
5861
<td th:text="${restaurant.getDeliveryFee()}"></td>
5962
<td th:text="${restaurant.getCuisine().getName()}"></td>
63+
<td th:text="${restaurant.getCity()}"></td>
64+
<td><input type="checkbox" th:checked="${restaurant.isGrabAndGo()}" disabled="true"></td>
65+
<td><input type="checkbox" th:checked="${restaurant.isActive()}" disabled="true"></td>
6066
</tr>
6167
<tbody>
6268

src/main/resources/templates/restaurant.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ <h1 th:text="${restaurant.getName()}">Restaurant 1</h1>
3939
th:text="${restaurant.getCuisine().getName()}"></button>
4040
</td>
4141
</tr>
42+
<tr>
43+
<td>City</td>
44+
<td th:text="${restaurant.getCity()}"></td>
45+
</tr>
46+
<tr>
47+
<td>Grab'n'Go</td>
48+
<td th:if="${restaurant.isGrabAndGo()}">Yes</td>
49+
<td th:if="${!restaurant.isGrabAndGo()}">No</td>
50+
</tr>
51+
<tr>
52+
<td>Active</td>
53+
<td th:if="${restaurant.isActive()}">Yes</td>
54+
<td th:if="${!restaurant.isActive()}">No</td>
55+
</tr>
4256
<tr>
4357
<td>Updated Date</td>
4458
<td th:text="${restaurant.getUpdatedDate()}"></td>

0 commit comments

Comments
 (0)