source: src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java@ e15e8d9

main
Last change on this file since e15e8d9 was deea3c4, checked in by Aleksandar Panovski <apano77@…>, 3 weeks ago

Big change done fully handle_reservation_update() trigger works

  • Property mode set to 100644
File size: 7.6 KB
Line 
1package com.example.rezevirajmasa.demo.model;
2
3import com.fasterxml.jackson.annotation.JsonIgnore;
4import com.fasterxml.jackson.annotation.JsonManagedReference;
5import jakarta.persistence.*;
6
7import java.math.BigDecimal;
8import java.time.LocalDateTime;
9import java.util.List;
10
11@Entity
12@Table(name = "restaurants")
13public class Restaurant {
14 @Id
15 @GeneratedValue(strategy = GenerationType.IDENTITY)
16 @Column(name = "RestaurantID")
17 private Long restaurantId;
18
19 @Column(name = "Name", length = 100)
20 private String name;
21
22 @Column(name = "CuisineType", length = 50)
23 private String cuisineType;
24
25 @Column(name = "Address", length = 1000)
26 private String address;
27
28 @Column(name = "Phone", length = 20)
29 private String phone;
30
31 @Column(name = "OperatingHours", length = 100)
32 private String operatingHours;
33
34 @Column(name = "Website", length = 100)
35 private String website;
36
37 @Column(name = "SocialMediaLinks")
38 private String socialMediaLinks;
39
40 @Column(name = "Rating", precision = 3, scale = 2)
41 private BigDecimal rating;
42
43 @JsonIgnore
44 @OneToMany(mappedBy = "restaurant", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
45 private List<TableEntity> tablesList;
46
47 public Restaurant() {
48 }
49
50 public Restaurant(String name, String cuisineType, String address, String phone, String operatingHours, String website, String socialMediaLinks, BigDecimal rating, List<TableEntity> tablesList) {
51 this.name = name;
52 this.cuisineType = cuisineType;
53 this.address = address;
54 this.phone = phone;
55 this.operatingHours = operatingHours;
56 this.website = website;
57 this.socialMediaLinks = socialMediaLinks;
58 this.rating = rating;
59 this.tablesList = tablesList;
60 }
61
62 public String getName() {
63 return name;
64 }
65
66 public void setName(String name) {
67 this.name = name;
68 }
69
70 public String getCuisineType() {
71 return cuisineType;
72 }
73
74 public void setCuisineType(String cuisineType) {
75 this.cuisineType = cuisineType;
76 }
77
78 public String getAddress() {
79 return address;
80 }
81
82 public void setAddress(String address) {
83 this.address = address;
84 }
85
86 public String getPhone() {
87 return phone;
88 }
89
90 public void setPhone(String phone) {
91 this.phone = phone;
92 }
93
94 public String getOperatingHours() {
95 return operatingHours;
96 }
97
98 public void setOperatingHours(String operatingHours) {
99 this.operatingHours = operatingHours;
100 }
101
102 public String getWebsite() {
103 return website;
104 }
105
106 public void setWebsite(String website) {
107 this.website = website;
108 }
109
110 public String getSocialMediaLinks() {
111 return socialMediaLinks;
112 }
113
114 public void setSocialMediaLinks(String socialMediaLinks) {
115 this.socialMediaLinks = socialMediaLinks;
116 }
117
118 public BigDecimal getRating() {
119 return rating;
120 }
121
122 public void setRating(BigDecimal rating) {
123 this.rating = rating;
124 }
125
126 public List<TableEntity> getTablesList() {
127 return tablesList;
128 }
129
130 public void setTablesList(List<TableEntity> tablesList) {
131 this.tablesList = tablesList;
132 }
133
134 public Long getRestaurantId() {
135 return restaurantId;
136 }
137
138 public void setRestaurantId(Long restaurantId) {
139 this.restaurantId = restaurantId;
140 }
141
142 @Entity
143 @Table(name = "reservation_history")
144 public static class ReservationHistory {
145
146 @Id
147 @GeneratedValue(strategy = GenerationType.IDENTITY)
148 private Long id;
149
150 @ManyToOne
151 @JoinColumn(name = "customer_id")
152 private User user;
153
154 @ManyToOne
155 @JoinColumn(name = "table_id")
156 private TableEntity table;
157
158 @ManyToOne
159 @JoinColumn(name = "restaurant_id")
160 private Restaurant restaurant; // Add this field
161
162 @Column(name = "reservation_datetime")
163 private LocalDateTime reservationDateTime;
164
165 @Column(name = "party_size")
166 private int partySize;
167
168 @Column(name = "special_requests")
169 private String specialRequests;
170
171 @Column(name = "status")
172 private String status; // Completed, Canceled, etc.
173
174 @Column(name = "cancellation_reason")
175 private String cancellationReason;
176
177 @Column(name = "check_in_date") // Add this field
178 private LocalDateTime checkInDate;
179
180 public ReservationHistory(User user, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, String cancellationReason, LocalDateTime checkInDate) {
181 this.user = user;
182 this.table = table;
183 this.restaurant = restaurant;
184 this.reservationDateTime = reservationDateTime;
185 this.partySize = partySize;
186 this.specialRequests = specialRequests;
187 this.status = status;
188 this.cancellationReason = cancellationReason;
189 this.checkInDate = checkInDate;
190 }
191
192 public ReservationHistory() {
193 }
194
195 public Long getId() {
196 return id;
197 }
198
199 public void setId(Long id) {
200 this.id = id;
201 }
202
203 public User getUser() {
204 return user;
205 }
206
207 public void setUser(User user) {
208 this.user = user;
209 }
210
211 public TableEntity getTable() {
212 return table;
213 }
214
215 public void setTable(TableEntity table) {
216 this.table = table;
217 }
218
219 public LocalDateTime getReservationDateTime() {
220 return reservationDateTime;
221 }
222
223 public void setReservationDateTime(LocalDateTime reservationDateTime) {
224 this.reservationDateTime = reservationDateTime;
225 }
226
227 public int getPartySize() {
228 return partySize;
229 }
230
231 public void setPartySize(int partySize) {
232 this.partySize = partySize;
233 }
234
235 public String getSpecialRequests() {
236 return specialRequests;
237 }
238
239 public void setSpecialRequests(String specialRequests) {
240 this.specialRequests = specialRequests;
241 }
242
243 public String getStatus() {
244 return status;
245 }
246
247 public void setStatus(String status) {
248 this.status = status;
249 }
250
251 public String getCancellationReason() {
252 return cancellationReason;
253 }
254
255 public void setCancellationReason(String cancellationReason) {
256 this.cancellationReason = cancellationReason;
257 }
258
259 public Restaurant getRestaurant() {
260 return restaurant;
261 }
262
263 public void setRestaurant(Restaurant restaurant) {
264 this.restaurant = restaurant;
265 }
266
267 public LocalDateTime getCheckInDate() {
268 return checkInDate;
269 }
270
271 public void setCheckInDate(LocalDateTime checkInDate) {
272 this.checkInDate = checkInDate;
273 }
274
275 @Override
276 public String toString() {
277 return "ReservationHistory{" +
278 "id=" + id +
279 ", user=" + user +
280 ", table=" + table +
281 ", restaurant=" + restaurant +
282 ", reservationDateTime=" + reservationDateTime +
283 ", partySize=" + partySize +
284 ", specialRequests='" + specialRequests + '\'' +
285 ", status='" + status + '\'' +
286 ", cancellationReason='" + cancellationReason + '\'' +
287 ", checkInDate=" + checkInDate +
288 '}';
289 }
290 }
291}
Note: See TracBrowser for help on using the repository browser.